fix(voice): handle 422 permission-blocked response in WhatsApp call composable

The BE now returns 422 (instead of 200) when the contact hasn't opted in
yet — see companion fix in WhatsappCallsController#render_permission_request.
Detect that shape in the catch block and surface it as a normal response so
the existing banner branch in ConversationHeader.vue keeps working without
falling into the error toast path.
This commit is contained in:
Tanmay Deep Sharma
2026-05-05 17:30:31 +07:00
parent 17ff977b07
commit c1e3e61671
@@ -297,6 +297,16 @@ export function useWhatsappCallSession() {
return response;
} catch (e) {
cleanup();
// BE returns 422 when the contact hasn't opted in (permission template
// sent or already pending). Surface it to the caller as a normal
// response shape so it can render the banner instead of an error toast.
const data = e?.response?.data;
if (
data?.status === 'permission_requested' ||
data?.status === 'permission_pending'
) {
return { status: data.status };
}
throw e;
} finally {
isInitiating.value = false;