vchikalkin 5018560f29 feat(customer): implement banned customer check and enhance customer data handling
- Added `isCustomerBanned` function to determine if a customer is banned based on the `bannedUntil` field.
- Updated the `BaseService` to throw an error if a banned customer attempts to access certain functionalities.
- Enhanced the GraphQL operations to include the `bannedUntil` field in customer queries and mutations, improving data integrity and user experience.
- Integrated the `CheckBanned` component in the layout to manage banned customer states effectively.
2025-08-25 19:15:00 +03:00

21 lines
509 B
TypeScript

/* eslint-disable sonarjs/function-return-type */
'use client';
import { useIsBanned } from '@/hooks/api/customers';
import { redirect, RedirectType } from 'next/navigation';
import { type PropsWithChildren, useEffect } from 'react';
export function CheckBanned({ children }: Readonly<PropsWithChildren>) {
const isBanned = useIsBanned();
useEffect(() => {
if (isBanned) {
redirect('/banned', RedirectType.replace);
}
}, [isBanned]);
if (isBanned) return null;
return children;
}