fix: Update frontend to indicate lack of WhatsApp connection and adjust backend to return 422 status for WhatsApp number validation issues

feat-scaling-ticket-remote-creation
adriano 2024-03-07 18:03:46 -03:00
parent c5c5ddb5a4
commit e020a5f75d
3 changed files with 13 additions and 10 deletions

View File

@ -93,7 +93,7 @@ export const index = async (req: Request, res: Response): Promise<Response> => {
let queueIds: number[] = [];
if (queueIdsStringified) {
if (queueIdsStringified && queueIdsStringified.trim().length > 0) {
queueIds = JSON.parse(queueIdsStringified);
}

View File

@ -27,9 +27,10 @@ const CheckIsValidContact = async (
}
try {
if (!isValidNumber) {
let _status: any;
const { data } = await axios.post(
if (!isValidNumber) {
const { data, status } = await axios.post(
`${process.env.WHATS_NUMBER_VALIDATOR_URL}/api/validate`,
{ mobile: number },
{
@ -40,10 +41,12 @@ const CheckIsValidContact = async (
);
isValidNumber = data;
_status = status;
}
if (ignoreThrow) return isValidNumber?.number;
if (_status && _status == 422) throw new AppError("ERR_NO_WAPP_FOUND");
if (!isValidNumber || (isValidNumber && !isValidNumber.isValid)) {
throw new AppError("invalidNumber");
}

View File

@ -126,10 +126,10 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
handleClose()
}
toast.success(i18n.t("contactModal.success"))
setSaving(false)
} catch (err) {
toastError(err)
}
setSaving(false)
}
return (