fix: subscription middleare

This commit is contained in:
Ahmed Bouhuolia
2024-08-25 12:42:42 +02:00
parent 959ef7a691
commit ee2d8d3065
5 changed files with 77 additions and 14 deletions

View File

@@ -64,12 +64,20 @@ export default function useApiRequest() {
setGlobalErrors({ too_many_requests: true });
}
if (status === 400) {
const lockedError = data.errors.find(
(error) => error.type === 'TRANSACTIONS_DATE_LOCKED',
);
if (lockedError) {
if (
data.errors.find(
(error) => error.type === 'TRANSACTIONS_DATE_LOCKED',
)
) {
setGlobalErrors({ transactionsLocked: { ...lockedError.data } });
}
if (
data.errors.find(
(e) => e.type === 'ORGANIZATION.SUBSCRIPTION.INACTIVE',
)
) {
setGlobalErrors({ subscriptionInactive: true });
}
if (data.errors.find((e) => e.type === 'USER_INACTIVE')) {
setGlobalErrors({ userInactive: true });
setLogout();