filter with bill id
This commit is contained in:
@@ -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] ?? 'خطا در ثبت قبض')
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -21,12 +21,13 @@ const ReceiptsList: FC = () => {
|
||||
const { t } = useTranslation('global')
|
||||
const [page, setPage] = useState<number>(1)
|
||||
const [searchParams] = useSearchParams()
|
||||
const billIdFromUrl = searchParams.get('bill') ?? ''
|
||||
const [activeTab, setActiveTab] = useState<InvoiceStatus>('PENDING')
|
||||
const [customerId, setCustomerId] = useState<string>('')
|
||||
const [search, setSearch] = useState<string>('')
|
||||
const [date, setDate] = 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(() => {
|
||||
const urlCustomerId = searchParams.get('user')
|
||||
|
||||
@@ -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),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user