Skip to content

Commit

Permalink
Merge pull request #6 from HewageNKM/dev
Browse files Browse the repository at this point in the history
Remove invoice preview and direct physical invoice printing
  • Loading branch information
EthanBlake00 authored Dec 26, 2024
2 parents 35166ce + 87cee44 commit e642b70
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 57 deletions.
2 changes: 0 additions & 2 deletions app/dashboard/components/InvoiceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { ScrollArea } from "@/components/ui/scroll-area";
import LoadingScreen from "@/components/LoadingScreen";
import { getPosCartItems, setShowPaymentDialog } from "@/lib/invoiceSlice/invoiceSlice";
import PaymentForm from "@/app/dashboard/components/PaymentForm";
import InvoicePreview from "@/app/dashboard/components/PreviewInvoice";
import { collection, onSnapshot, query, where, Timestamp } from "@firebase/firestore";
import {db} from "@/firebase/firebaseClient";

Expand Down Expand Up @@ -110,7 +109,6 @@ const InvoiceDetails = () => {
</Button>
</div>
{showPaymentDialog && <PaymentForm />}
<InvoicePreview />
</div>
);
};
Expand Down
14 changes: 4 additions & 10 deletions app/dashboard/components/InvoicesForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ import React, {useState} from 'react';
import {Dialog, DialogContent, DialogHeader, DialogTitle} from "@/components/ui/dialog";
import {Input} from "@/components/ui/input";
import {Button} from "@/components/ui/button";
import InvoicePreview from "@/app/dashboard/components/PreviewInvoice";
import {getAOrder} from "@/app/actions/invoiceAction";
import {getAOrder, sendPrintInvoice} from "@/app/actions/invoiceAction";
import {useToast} from "@/hooks/use-toast";
import LoadingScreen from "@/components/LoadingScreen";
import {useAppDispatch} from "@/lib/hooks";
import {setPreviewInvoice, setPreviewOrder} from "@/lib/invoiceSlice/invoiceSlice";

const InvoicesForm = ({showInvoicesForm, setShowInvoicesForm}: {
setShowInvoicesForm: React.Dispatch<React.SetStateAction<boolean>>,
showInvoicesForm: boolean
}) => {
const [loading, setLoading] = useState(false)
const [invoiceId, setInvoiceId] = useState("")
const dispatch = useAppDispatch();
const {toast} = useToast()


Expand All @@ -24,15 +20,14 @@ const InvoicesForm = ({showInvoicesForm, setShowInvoicesForm}: {
setLoading(true)
try {
const fetchedOrder = await getAOrder(invoiceId.toLowerCase());
dispatch(setPreviewOrder(fetchedOrder))
dispatch(setPreviewInvoice(true))
await sendPrintInvoice(fetchedOrder);
setShowInvoicesForm(false)
evt.target.reset()
} catch (e) {
console.error(e)
toast({
title: "Error",
description: e.message,
description: `Something went wrong ${e.message}`,
variant: "destructive",
})
} finally {
Expand All @@ -55,13 +50,12 @@ const InvoicesForm = ({showInvoicesForm, setShowInvoicesForm}: {
value={invoiceId}
onChange={(event) => setInvoiceId(event.target.value)}/>
<Button type={"submit"}>
Get Invoice
Print Invoice
</Button>
</form>
</DialogHeader>
</DialogContent>
</Dialog>)}
<InvoicePreview/>
</>
);
};
Expand Down
45 changes: 0 additions & 45 deletions app/dashboard/components/PreviewInvoice.tsx

This file was deleted.

0 comments on commit e642b70

Please sign in to comment.