Ignore:
Timestamp:
02/26/25 14:27:26 (6 weeks ago)
Author:
Naum Shapkarovski <naumshapkarovski@…>
Branches:
main
Children:
3c5302a
Parents:
057453c
Message:

chore

Location:
src/sections/invoice
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sections/invoice/invoice-new-edit-form.tsx

    r057453c r299af01  
    209209      const invoicePdf = <InvoicePDF invoice={writeData as Invoice} currentStatus="pending" />;
    210210      const blob: Blob = await pdf(invoicePdf).toBlob();
    211       const storagePath: string = `invoices/${writeData.invoiceTo.name}/${id}-${writeData.invoiceNumber}.pdf`;
     211      const storagePath: string = `invoices/${writeData.invoiceTo.name}-${writeData.invoiceNumber}.pdf`;
    212212      await uploadToFirebaseStorage(blob, storagePath);
    213213
     
    269269        const invoicePdf = <InvoicePDF invoice={writeData as Invoice} currentStatus="pending" />;
    270270        const blob: Blob = await pdf(invoicePdf).toBlob();
    271         const storagePath: string = `invoices/${data.invoiceTo.name}/${currentInvoice.id}-${data.invoiceNumber}.pdf`;
     271        const storagePath: string = `invoices/${data.invoiceTo.name}-${data.invoiceNumber}.pdf`;
    272272        await uploadToFirebaseStorage(blob, storagePath);
    273273
     
    335335        const invoicePdf = <InvoicePDF invoice={writeData as Invoice} currentStatus="pending" />;
    336336        const blob: Blob = await pdf(invoicePdf).toBlob();
    337         const storagePath: string = `invoices/${data.invoiceTo.name}/${id}-${data.invoiceNumber}.pdf`;
     337        const storagePath: string = `invoices/${data.invoiceTo.name}-${data.invoiceNumber}.pdf`;
    338338        await uploadToFirebaseStorage(blob, storagePath);
    339339
  • src/sections/invoice/view/invoice-list-view.tsx

    r057453c r299af01  
    4949import InvoiceTableToolbar from '../invoice-table-toolbar';
    5050import MailCompose from '../mail-compose';
     51import { useFetchAnalytics } from 'src/api/invoice/use-fetch-analytics';
     52import { endpoints } from 'src/utils/axios';
    5153
    5254// ----------------------------------------------------------------------
     
    208210  //   );
    209211
     212  const {
     213    analytics: analyticsData,
     214    isAnalyticsLoading,
     215    analyticsError,
     216  } = useFetchAnalytics(filters.startDate);
     217
    210218  useEffect(() => {
    211     if (tableData) {
    212       const getAnalytics = async () => {
    213         const analyticsStats = await getTotalAmountForAllStatuses(tableData);
    214         setAnalytics(analyticsStats);
    215       };
    216       getAnalytics();
     219    if (analyticsData) {
     220      setAnalytics(analyticsData);
    217221    }
    218   }, [tableData]);
     222  }, [analyticsData]);
     223
     224  useEffect(() => {
     225    if (analyticsError) {
     226      console.error('Failed to load analytics:', analyticsError);
     227    }
     228  }, [analyticsError]);
    219229
    220230  const getPercentByStatus = (status: string) =>
     
    272282      await deleteInvoiceMutation(invoice.id);
    273283      await deleteFromFirebaseStorage(
    274         `invoices/${invoice.invoiceTo.name}/${invoice.id}-${invoice.invoiceNumber}.pdf`
     284        `invoices/${invoice.invoiceTo.name}-${invoice.invoiceNumber}.pdf`
    275285      );
    276286
    277       mutate(invoiceMutationKey);
     287      mutate(endpoints.invoice);
    278288    },
    279289    [filters.startDate, invoiceMutationKey]
     
    332342    setFilters(defaultFilters);
    333343  }, []);
     344
     345  if (isAnalyticsLoading) {
     346    // Show loading state
     347  }
    334348
    335349  return (
Note: See TracChangeset for help on using the changeset viewer.