diff --git a/src/pages/bill/Create.tsx b/src/pages/bill/Create.tsx index edbaa0e..6fc9adb 100644 --- a/src/pages/bill/Create.tsx +++ b/src/pages/bill/Create.tsx @@ -55,7 +55,7 @@ const CreateBill: FC = () => { { onSuccess: () => { toast.success('قبض آب با موفقیت ثبت شد') - navigate(Pages.company.list) + navigate(Pages.bill.list) }, onError: (error: ErrorType) => { toast.error(error.response?.data?.error?.message?.[0] ?? 'خطا در ثبت قبض') diff --git a/src/pages/bill/CreateCharge.tsx b/src/pages/bill/CreateCharge.tsx index dc1ebc7..949d45a 100644 --- a/src/pages/bill/CreateCharge.tsx +++ b/src/pages/bill/CreateCharge.tsx @@ -36,7 +36,7 @@ const CreateCharge: FC = () => { await mutateAsync(payload, { onSuccess: () => { toast.success('قبض شارژ با موفقیت ثبت شد') - navigate(Pages.bill.ListBillCharge) + navigate(Pages.bill.list) }, onError: (error: ErrorType) => { toast.error( diff --git a/src/pages/receipts/List.tsx b/src/pages/receipts/List.tsx index 78f50c6..dc04b45 100644 --- a/src/pages/receipts/List.tsx +++ b/src/pages/receipts/List.tsx @@ -21,12 +21,13 @@ const ReceiptsList: FC = () => { const { t } = useTranslation('global') const [page, setPage] = useState(1) const [searchParams] = useSearchParams() + const billIdFromUrl = searchParams.get('bill') ?? '' const [activeTab, setActiveTab] = useState('PENDING') const [customerId, setCustomerId] = useState('') const [search, setSearch] = useState('') const [date, setDate] = useState('') const [endDate, setEndDate] = useState('') - const getInvoices = useGetInvoices(activeTab, customerId, search, date, endDate) + const getInvoices = useGetInvoices(activeTab, customerId, search, date, endDate, billIdFromUrl || undefined) useEffect(() => { const urlCustomerId = searchParams.get('user') diff --git a/src/pages/receipts/hooks/useReceiptData.ts b/src/pages/receipts/hooks/useReceiptData.ts index f146a1d..53e330d 100644 --- a/src/pages/receipts/hooks/useReceiptData.ts +++ b/src/pages/receipts/hooks/useReceiptData.ts @@ -7,11 +7,12 @@ export const useGetInvoices = ( customerId: string, search: string, date: string, - endDate: string + endDate: string, + billId?: string ) => { return useQuery({ - queryKey: ["invoices", status, customerId, search, date, endDate], - queryFn: () => api.getInvoces(status, customerId, search, date, endDate), + queryKey: ["invoices", status, customerId, search, date, endDate, billId], + queryFn: () => api.getInvoces(status, customerId, search, date, endDate, billId), }); }; diff --git a/src/pages/receipts/service/ReceiptService.ts b/src/pages/receipts/service/ReceiptService.ts index 981d524..18fe1ec 100644 --- a/src/pages/receipts/service/ReceiptService.ts +++ b/src/pages/receipts/service/ReceiptService.ts @@ -6,7 +6,8 @@ export const getInvoces = async ( customerId: string, search: string, date: string, - endDate: string + endDate: string, + billId?: string ) => { const params = new URLSearchParams(); if (status) params.append("status", status); @@ -14,6 +15,7 @@ export const getInvoces = async ( if (search) params.append("q", search); if (date) params.append("since", date); if (endDate) params.append("to", endDate); + if (billId) params.append("billId", billId); const query = params.toString(); const { data } = await axios.get(`/invoices?${query}`); return data;