add authToastMiddleware back and fix parsing

This commit is contained in:
Mary Hipp
2023-12-20 14:47:44 -05:00
committed by Kent Keirsey
parent a4f9bfc8f7
commit 562fb1f3a1
2 changed files with 9 additions and 9 deletions

View File

@@ -5,12 +5,10 @@ import { t } from 'i18next';
import { z } from 'zod';
const zRejectedForbiddenAction = z.object({
action: z.object({
payload: z.object({
status: z.literal(403),
data: z.object({
detail: z.string(),
}),
payload: z.object({
status: z.literal(403),
data: z.object({
detail: z.string(),
}),
}),
});
@@ -22,8 +20,8 @@ export const authToastMiddleware: Middleware =
const parsed = zRejectedForbiddenAction.parse(action);
const { dispatch } = api;
const customMessage =
parsed.action.payload.data.detail !== 'Forbidden'
? parsed.action.payload.data.detail
parsed.payload.data.detail !== 'Forbidden'
? parsed.payload.data.detail
: undefined;
dispatch(
addToast({
@@ -32,7 +30,7 @@ export const authToastMiddleware: Middleware =
description: customMessage,
})
);
} catch {
} catch (error) {
// no-op
}
}