fix: Update frontend to indicate lack of WhatsApp connection and adjust backend to return 422 status for WhatsApp number validation issues
parent
c5c5ddb5a4
commit
e020a5f75d
|
@ -93,9 +93,9 @@ export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||||
|
|
||||||
let queueIds: number[] = [];
|
let queueIds: number[] = [];
|
||||||
|
|
||||||
if (queueIdsStringified) {
|
if (queueIdsStringified && queueIdsStringified.trim().length > 0) {
|
||||||
queueIds = JSON.parse(queueIdsStringified);
|
queueIds = JSON.parse(queueIdsStringified);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { tickets, count, hasMore } = await ListTicketsService({
|
const { tickets, count, hasMore } = await ListTicketsService({
|
||||||
searchParam,
|
searchParam,
|
||||||
|
@ -109,7 +109,7 @@ export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||||
unlimited,
|
unlimited,
|
||||||
searchParamContent
|
searchParamContent
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(200).json({ tickets, count, hasMore });
|
return res.status(200).json({ tickets, count, hasMore });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,13 @@ const CheckIsValidContact = async (
|
||||||
if (data?.isValid) {
|
if (data?.isValid) {
|
||||||
isValidNumber = data;
|
isValidNumber = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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`,
|
`${process.env.WHATS_NUMBER_VALIDATOR_URL}/api/validate`,
|
||||||
{ mobile: number },
|
{ mobile: number },
|
||||||
{
|
{
|
||||||
|
@ -40,10 +41,12 @@ const CheckIsValidContact = async (
|
||||||
);
|
);
|
||||||
|
|
||||||
isValidNumber = data;
|
isValidNumber = data;
|
||||||
|
_status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoreThrow) return isValidNumber?.number;
|
if (ignoreThrow) return isValidNumber?.number;
|
||||||
|
|
||||||
|
if (_status && _status == 422) throw new AppError("ERR_NO_WAPP_FOUND");
|
||||||
|
|
||||||
if (!isValidNumber || (isValidNumber && !isValidNumber.isValid)) {
|
if (!isValidNumber || (isValidNumber && !isValidNumber.isValid)) {
|
||||||
throw new AppError("invalidNumber");
|
throw new AppError("invalidNumber");
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,11 +125,11 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
|
||||||
}
|
}
|
||||||
handleClose()
|
handleClose()
|
||||||
}
|
}
|
||||||
toast.success(i18n.t("contactModal.success"))
|
toast.success(i18n.t("contactModal.success"))
|
||||||
setSaving(false)
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toastError(err)
|
toastError(err)
|
||||||
}
|
}
|
||||||
|
setSaving(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue