restaurants

This commit is contained in:
hamid zarghami
2025-12-31 08:53:07 +03:30
parent bc61ea6a20
commit cd73c22c3f
5 changed files with 37 additions and 9 deletions
+2 -1
View File
@@ -885,7 +885,8 @@
"inactive": "غیرفعال",
"admins": "مدیران",
"add_admin": "افزودن مدیر",
"sms_count": "تعداد پیامک"
"sms_count": "تعداد پیامک",
"role": "نقش"
},
"cancel": "لغو"
}
+2 -1
View File
@@ -4,6 +4,7 @@ import {
GroupIconsResponse,
ReportsResponse,
SystemRolesResponse,
RestaurantAdminsResponse,
} from "../types/Types";
export const useGetIcons = () => {
@@ -59,7 +60,7 @@ export const useGetRestaurants = () => {
};
export const useGetRestaurantAdmins = (restaurantId: string) => {
return useQuery({
return useQuery<RestaurantAdminsResponse>({
queryKey: ["restaurant-admins", restaurantId],
queryFn: () => api.getRestaurantAdmins(restaurantId),
enabled: !!restaurantId,
@@ -23,7 +23,7 @@ const RestaurantAdminsModal: FC<RestaurantAdminsModalProps> = ({ open, close, re
const { data: adminsData, isLoading, refetch } = useGetRestaurantAdmins(restaurantId)
const [showAddForm, setShowAddForm] = useState(false)
const adminsList = (adminsData as { data?: RestaurantAdminType[] })?.data || []
const adminsList = adminsData?.data || []
const { mutate: deleteAdmin, isPending } = useDeleteRestaurantAdmin()
@@ -85,6 +85,7 @@ const RestaurantAdminsModal: FC<RestaurantAdminsModalProps> = ({ open, close, re
<tr>
<Td text={t('user.name')} />
<Td text={t('restaurant.phone')} />
<Td text={t('restaurant.role')} />
<Td text={t('restaurant.created_at')} />
<Td text={''} />
</tr>
@@ -96,6 +97,7 @@ const RestaurantAdminsModal: FC<RestaurantAdminsModalProps> = ({ open, close, re
<tr key={admin.id} className='tr'>
<Td text={`${admin.firstName} ${admin.lastName}`} />
<Td text={admin.phone || '-'} />
<Td text={admin.roles[0].role?.name || '-'} />
<Td text={''}>
<div className='dltr text-right'>
{moment(admin.createdAt).format('jYYYY-jMM-jDD HH:mm')}
+4 -1
View File
@@ -9,6 +9,7 @@ import {
RestaurantSmsCountResponse,
AddAdminRestaurantType,
SystemRolesResponse,
RestaurantAdminsResponse,
} from "../types/Types";
export const getIcons = async (): Promise<IconsResponse> => {
@@ -51,7 +52,9 @@ export const getRestaurants = async (): Promise<RestaurantsResponse> => {
return data;
};
export const getRestaurantAdmins = async (restaurantId: string) => {
export const getRestaurantAdmins = async (
restaurantId: string
): Promise<RestaurantAdminsResponse> => {
const { data } = await axios.get(
`/admin/dmenu/restaurants/${restaurantId}/admins`
);
+26 -5
View File
@@ -107,14 +107,35 @@ export interface RestaurantsResponse extends IResponse<RestaurantType[]> {
statusCode: number;
}
export type RestaurantAdminType = {
export type RestaurantAdminRoleType = {
id: string;
firstName: string;
lastName: string;
email: string;
phone: string;
createdAt: string;
updatedAt: string;
deletedAt: string | null;
name: string;
isSystem: boolean;
restaurant: string | null;
};
export type RestaurantAdminRoleItemType = {
id: string;
createdAt: string;
updatedAt: string;
deletedAt: string | null;
admin: string;
role: RestaurantAdminRoleType;
restaurant: string;
};
export type RestaurantAdminType = {
id: string;
createdAt: string;
updatedAt: string;
deletedAt: string | null;
firstName: string;
lastName: string;
phone: string;
roles: RestaurantAdminRoleItemType[];
};
export interface RestaurantAdminsResponse