filter with bill id

This commit is contained in:
hamid zarghami
2026-02-17 11:19:23 +03:30
parent a939d3bb4c
commit ca528e8478
5 changed files with 11 additions and 7 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ const CreateBill: FC = () => {
{ {
onSuccess: () => { onSuccess: () => {
toast.success('قبض آب با موفقیت ثبت شد') toast.success('قبض آب با موفقیت ثبت شد')
navigate(Pages.company.list) navigate(Pages.bill.list)
}, },
onError: (error: ErrorType) => { onError: (error: ErrorType) => {
toast.error(error.response?.data?.error?.message?.[0] ?? 'خطا در ثبت قبض') toast.error(error.response?.data?.error?.message?.[0] ?? 'خطا در ثبت قبض')
+1 -1
View File
@@ -36,7 +36,7 @@ const CreateCharge: FC = () => {
await mutateAsync(payload, { await mutateAsync(payload, {
onSuccess: () => { onSuccess: () => {
toast.success('قبض شارژ با موفقیت ثبت شد') toast.success('قبض شارژ با موفقیت ثبت شد')
navigate(Pages.bill.ListBillCharge) navigate(Pages.bill.list)
}, },
onError: (error: ErrorType) => { onError: (error: ErrorType) => {
toast.error( toast.error(
+2 -1
View File
@@ -21,12 +21,13 @@ const ReceiptsList: FC = () => {
const { t } = useTranslation('global') const { t } = useTranslation('global')
const [page, setPage] = useState<number>(1) const [page, setPage] = useState<number>(1)
const [searchParams] = useSearchParams() const [searchParams] = useSearchParams()
const billIdFromUrl = searchParams.get('bill') ?? ''
const [activeTab, setActiveTab] = useState<InvoiceStatus>('PENDING') const [activeTab, setActiveTab] = useState<InvoiceStatus>('PENDING')
const [customerId, setCustomerId] = useState<string>('') const [customerId, setCustomerId] = useState<string>('')
const [search, setSearch] = useState<string>('') const [search, setSearch] = useState<string>('')
const [date, setDate] = useState<string>('') const [date, setDate] = useState<string>('')
const [endDate, setEndDate] = useState<string>('') const [endDate, setEndDate] = useState<string>('')
const getInvoices = useGetInvoices(activeTab, customerId, search, date, endDate) const getInvoices = useGetInvoices(activeTab, customerId, search, date, endDate, billIdFromUrl || undefined)
useEffect(() => { useEffect(() => {
const urlCustomerId = searchParams.get('user') const urlCustomerId = searchParams.get('user')
+4 -3
View File
@@ -7,11 +7,12 @@ export const useGetInvoices = (
customerId: string, customerId: string,
search: string, search: string,
date: string, date: string,
endDate: string endDate: string,
billId?: string
) => { ) => {
return useQuery({ return useQuery({
queryKey: ["invoices", status, customerId, search, date, endDate], queryKey: ["invoices", status, customerId, search, date, endDate, billId],
queryFn: () => api.getInvoces(status, customerId, search, date, endDate), queryFn: () => api.getInvoces(status, customerId, search, date, endDate, billId),
}); });
}; };
+3 -1
View File
@@ -6,7 +6,8 @@ export const getInvoces = async (
customerId: string, customerId: string,
search: string, search: string,
date: string, date: string,
endDate: string endDate: string,
billId?: string
) => { ) => {
const params = new URLSearchParams(); const params = new URLSearchParams();
if (status) params.append("status", status); if (status) params.append("status", status);
@@ -14,6 +15,7 @@ export const getInvoces = async (
if (search) params.append("q", search); if (search) params.append("q", search);
if (date) params.append("since", date); if (date) params.append("since", date);
if (endDate) params.append("to", endDate); if (endDate) params.append("to", endDate);
if (billId) params.append("billId", billId);
const query = params.toString(); const query = params.toString();
const { data } = await axios.get(`/invoices?${query}`); const { data } = await axios.get(`/invoices?${query}`);
return data; return data;