service and hooks request
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import Filters from '@/components/Filters'
|
import Filters from '@/components/Filters'
|
||||||
import Table from '@/components/Table'
|
import Table from '@/components/Table'
|
||||||
import { type FC } from 'react'
|
import { type FC } from 'react'
|
||||||
import { useGetRequests } from '../order/hooks/useOrderData'
|
import { useGetRequests } from './hooks/useRequestData'
|
||||||
import moment from 'moment-jalaali'
|
import moment from 'moment-jalaali'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { Paths } from '@/config/Paths'
|
import { Paths } from '@/config/Paths'
|
||||||
@@ -48,7 +48,7 @@ const RequestList: FC = () => {
|
|||||||
<Table
|
<Table
|
||||||
columns={[
|
columns={[
|
||||||
{
|
{
|
||||||
key: 'orderNumber',
|
key: 'requestNumber',
|
||||||
title: 'شماره',
|
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;
|
||||||
|
};
|
||||||
@@ -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[]>;
|
||||||
Reference in New Issue
Block a user