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