service and hooks request

This commit is contained in:
hamid zarghami
2026-02-21 10:31:30 +03:30
parent 593d771f71
commit ff9072b8d9
4 changed files with 52 additions and 2 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import Filters from '@/components/Filters'
import Table from '@/components/Table'
import { type FC } from 'react'
import { useGetRequests } from '../order/hooks/useOrderData'
import { useGetRequests } from './hooks/useRequestData'
import moment from 'moment-jalaali'
import { Link } from 'react-router-dom'
import { Paths } from '@/config/Paths'
@@ -48,7 +48,7 @@ const RequestList: FC = () => {
<Table
columns={[
{
key: 'orderNumber',
key: 'requestNumber',
title: 'شماره',
},
{
@@ -0,0 +1,9 @@
import * as api from "../service/RequestService";
import { useQuery } from "@tanstack/react-query";
export const useGetRequests = () => {
return useQuery({
queryKey: ["requests"],
queryFn: api.getRequests,
});
};
@@ -0,0 +1,7 @@
import axios from "@/config/axios";
import type { RequestResponseType } from "@/pages/requests/types/Types";
export const getRequests = async () => {
const { data } = await axios.get<RequestResponseType>("/admin/request");
return data;
};
+34
View File
@@ -0,0 +1,34 @@
import type { UserType } from "@/pages/order/types/Types";
import type { ProductType } from "@/pages/product/types/Types";
import type { BaseResponse } from "@/shared/types/Types";
export type RequestItemAttributeType = {
value: string;
attributeId: string;
};
export type RequestItemType = {
id: string;
createdAt: string;
deletedAt: string | null;
product: ProductType;
attributes: RequestItemAttributeType[];
request: string;
quantity: number;
description: string;
attachments: string[];
};
export type RequestStatus = "pending" | string;
export type RequestType = {
id: string;
createdAt: string;
deletedAt: string | null;
user: UserType;
requestNumber: number;
status: RequestStatus;
items: RequestItemType[];
};
export type RequestResponseType = BaseResponse<RequestType[]>;