Skip to content

Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.

feat: enhance buyer and seller management with new functionality and improved toast notifications (#195)

Vlad Sazonau0b968a3ac5dd
diff --git a/e2e/buyer.test.ts b/e2e/buyer.test.ts
index 06f7621..39cf964 100644
--- a/e2e/buyer.test.ts
+++ b/e2e/buyer.test.ts
@@ -112,7 +112,7 @@ test.describe("Buyer management", () => {
// Verify success toast message is visible
await expect(
- page.getByText("Buyer added successfully", { exact: true }),
+ page.getByText("Buyer added and applied to invoice", { exact: true }),
).toBeVisible();
// Verify buyer data is actually saved in localStorage
@@ -323,6 +323,155 @@ test.describe("Buyer management", () => {
await expect(notesSwitchNotInDialog).not.toBeChecked();
});
+ test("add buyer without applying to invoice", async ({ page }) => {
+ await page.getByRole("button", { name: "New Buyer" }).click();
+
+ const TEST_BUYER_DATA = {
+ name: "Unapplied Test Client",
+ address: "99 Unapplied Avenue",
+ email: "[email protected]",
+
+ vatNoFieldIsVisible: true,
+ vatNo: "VAT999",
+ vatNoLabelText: "Tax Number",
+
+ notesFieldIsVisible: true,
+ notes: "",
+ } as const satisfies BuyerData;
+
+ const manageBuyerDialog = page.getByTestId(`manage-buyer-dialog`);
+
+ await manageBuyerDialog
+ .getByRole("textbox", { name: "Name" })
+ .fill(TEST_BUYER_DATA.name);
+ await manageBuyerDialog
+ .getByRole("textbox", { name: "Address" })
+ .fill(TEST_BUYER_DATA.address);
+ await manageBuyerDialog
+ .getByRole("textbox", { name: "Email" })
+ .fill(TEST_BUYER_DATA.email);
+
+ // Uncheck "Apply to Current Invoice" switch
+ const applyToInvoiceSwitch = manageBuyerDialog.getByRole("switch", {
+ name: "Apply to Current Invoice",
+ });
+ await expect(applyToInvoiceSwitch).toBeChecked();
+ await applyToInvoiceSwitch.click();
+ await expect(applyToInvoiceSwitch).not.toBeChecked();
+
+ await manageBuyerDialog.getByRole("button", { name: "Save Buyer" }).click();
+
+ // Verify "Buyer added successfully" toast (NOT "applied to invoice")
+ await expect(
+ page.getByText("Buyer added successfully", { exact: true }),
+ ).toBeVisible();
+
+ const buyerForm = page.getByTestId(`buyer-information-section`);
+
+ // Buyer should appear in dropdown options but not be selected
+ await expect(
+ buyerForm.getByRole("combobox", { name: "Select Buyer" }),
+ ).toBeVisible();
+ await expect(
+ buyerForm.getByRole("combobox", { name: "Select Buyer" }),
+ ).toHaveValue("");
+
+ // Form fields should still contain default values (buyer was not applied)
+ await expect(buyerForm.getByRole("textbox", { name: "Name" })).toHaveValue(
+ DEFAULT_BUYER_DATA.name,
+ );
+ await expect(
+ buyerForm.getByRole("textbox", { name: "Address" }),
+ ).toHaveValue(DEFAULT_BUYER_DATA.address);
+ await expect(buyerForm.getByRole("textbox", { name: "Email" })).toHaveValue(
+ DEFAULT_BUYER_DATA.email,
+ );
+ });
+
+ test("switch and restore buyer via dropdown", async ({ page }) => {
+ // Add a buyer with "Apply to Current Invoice" checked (default)
+ await page.getByRole("button", { name: "New Buyer" }).click();
+
+ const TEST_BUYER_DATA = {
+ name: "Dropdown Test Client",
+ address: "42 Dropdown Boulevard",
+ email: "[email protected]",
+
+ vatNoFieldIsVisible: true,
+ vatNo: "VAT-DROP-001",
+ vatNoLabelText: "Tax Number",
+
+ notesFieldIsVisible: true,
+ notes: "",
+ } as const satisfies BuyerData;
+
+ const manageBuyerDialog = page.getByTestId(`manage-buyer-dialog`);
+
+ await manageBuyerDialog
+ .getByRole("textbox", { name: "Name" })
+ .fill(TEST_BUYER_DATA.name);
+ await manageBuyerDialog
+ .getByRole("textbox", { name: "Address" })
+ .fill(TEST_BUYER_DATA.address);
+ await manageBuyerDialog
+ .getByRole("textbox", { name: "Email" })
+ .fill(TEST_BUYER_DATA.email);
+
+ await manageBuyerDialog.getByRole("button", { name: "Save Buyer" }).click();
+
+ await expect(
+ page.getByText("Buyer added and applied to invoice", { exact: true }),
+ ).toBeVisible();
+
+ const buyerForm = page.getByTestId(`buyer-information-section`);
+ const buyerDropdown = buyerForm.getByRole("combobox", {
+ name: "Select Buyer",
+ });
+
+ // Buyer is currently selected in dropdown
+ await expect(buyerDropdown).not.toHaveValue("");
+
+ // Restore to default by selecting the empty option
+ await buyerDropdown.selectOption("");
+
+ // Verify "Buyer restored to default" toast
+ await expect(
+ page.getByText("Buyer restored to default", { exact: true }),
+ ).toBeVisible();
+
+ // Verify form reset to default values
+ await expect(buyerForm.getByRole("textbox", { name: "Name" })).toHaveValue(
+ DEFAULT_BUYER_DATA.name,
+ );
+ await expect(
+ buyerForm.getByRole("textbox", { name: "Address" }),
+ ).toHaveValue(DEFAULT_BUYER_DATA.address);
+ await expect(buyerForm.getByRole("textbox", { name: "Email" })).toHaveValue(
+ DEFAULT_BUYER_DATA.email,
+ );
+
+ // Reselect the saved buyer from the dropdown
+ await buyerDropdown.selectOption({ label: TEST_BUYER_DATA.name });
+
+ // Verify `Buyer "${name}" applied to invoice` toast
+ await expect(
+ page.getByText(`Buyer "${TEST_BUYER_DATA.name}" applied to invoice`, {
+ exact: true,
+ }),
+ ).toBeVisible();
+
+ // Verify form fields are populated with the buyer's data
+ await expect(buyerForm.getByRole("textbox", { name: "Name" })).toHaveValue(
+ TEST_BUYER_DATA.name,
+ );
+ await expect(
+ buyerForm.getByRole("textbox", { name: "Address" }),
+ ).toHaveValue(TEST_BUYER_DATA.address);
+ await expect(buyerForm.getByRole("textbox", { name: "Email" })).toHaveValue(
+ TEST_BUYER_DATA.email,
+ );
+ });
+
test("delete buyer", async ({ page }) => {
// First add a buyer
await page.getByRole("button", { name: "New Buyer" }).click();
diff --git a/e2e/seller.test.ts b/e2e/seller.test.ts
index 952d0f8..d9aa0fe 100644
--- a/e2e/seller.test.ts
+++ b/e2e/seller.test.ts
@@ -175,7 +175,7 @@ test.describe("Seller management", () => {
// Verify success toast message is visible
await expect(
- page.getByText("Seller added successfully", { exact: true }),
+ page.getByText("Seller added and applied to invoice", { exact: true }),
).toBeVisible();
/*
@@ -340,6 +340,171 @@ test.describe("Seller management", () => {
await expect(notesManageSellerDialogFormSwitch).toBeEnabled();
});
+ test("add seller without applying to invoice", async ({ page }) => {
+ await page.getByRole("button", { name: "New Seller" }).click();
+
+ const TEST_SELLER_DATA = {
+ name: "Unapplied Test Seller",
+ address: "99 Unapplied Street",
+ email: "[email protected]",
+
+ vatNoFieldIsVisible: true,
+ vatNo: "VAT999",
+ vatNoLabelText: "Tax Number",
+
+ accountNumberFieldIsVisible: true,
+ accountNumber: "ACCT-999",
+
+ swiftBicFieldIsVisible: true,
+ swiftBic: "SWIFT999",
+
+ notesFieldIsVisible: true,
+ notes: "",
+ } as const satisfies SellerData;
+
+ const manageSellerDialog = page.getByTestId(`manage-seller-dialog`);
+
+ await manageSellerDialog
+ .getByRole("textbox", { name: "Name" })
+ .fill(TEST_SELLER_DATA.name);
+ await manageSellerDialog
+ .getByRole("textbox", { name: "Address" })
+ .fill(TEST_SELLER_DATA.address);
+ await manageSellerDialog
+ .getByRole("textbox", { name: "Email" })
+ .fill(TEST_SELLER_DATA.email);
+
+ // Uncheck "Apply to Current Invoice" switch
+ const applyToInvoiceSwitch = manageSellerDialog.getByRole("switch", {
+ name: "Apply to Current Invoice",
+ });
+ await expect(applyToInvoiceSwitch).toBeChecked();
+ await applyToInvoiceSwitch.click();
+ await expect(applyToInvoiceSwitch).not.toBeChecked();
+
+ await manageSellerDialog
+ .getByRole("button", { name: "Save Seller" })
+ .click();
+
+ // Verify "Seller added successfully" toast (NOT "applied to invoice")
+ await expect(
+ page.getByText("Seller added successfully", { exact: true }),
+ ).toBeVisible();
+
+ const sellerForm = page.getByTestId(`seller-information-section`);
+
+ // Seller should appear in dropdown options but not be selected
+ await expect(
+ sellerForm.getByRole("combobox", { name: "Select Seller" }),
+ ).toBeVisible();
+ await expect(
+ sellerForm.getByRole("combobox", { name: "Select Seller" }),
+ ).toHaveValue("");
+
+ // Form fields should still contain default values (seller was not applied)
+ await expect(sellerForm.getByRole("textbox", { name: "Name" })).toHaveValue(
+ DEFAULT_SELLER_DATA.name,
+ );
+ await expect(
+ sellerForm.getByRole("textbox", { name: "Address" }),
+ ).toHaveValue(DEFAULT_SELLER_DATA.address);
+ await expect(
+ sellerForm.getByRole("textbox", { name: "Email" }),
+ ).toHaveValue(DEFAULT_SELLER_DATA.email);
+ });
+
+ test("switch and restore seller via dropdown", async ({ page }) => {
+ // Add a seller with "Apply to Current Invoice" checked (default)
+ await page.getByRole("button", { name: "New Seller" }).click();
+
+ const TEST_SELLER_DATA = {
+ name: "Dropdown Test Seller",
+ address: "42 Dropdown Lane",
+ email: "[email protected]",
+
+ vatNoFieldIsVisible: true,
+ vatNo: "VAT-DROP-001",
+ vatNoLabelText: "Tax Number",
+
+ accountNumberFieldIsVisible: true,
+ accountNumber: "ACCT-DROP-001",
+
+ swiftBicFieldIsVisible: true,
+ swiftBic: "SWIFTDROP",
+
+ notesFieldIsVisible: true,
+ notes: "",
+ } as const satisfies SellerData;
+
+ const manageSellerDialog = page.getByTestId(`manage-seller-dialog`);
+
+ await manageSellerDialog
+ .getByRole("textbox", { name: "Name" })
+ .fill(TEST_SELLER_DATA.name);
+ await manageSellerDialog
+ .getByRole("textbox", { name: "Address" })
+ .fill(TEST_SELLER_DATA.address);
+ await manageSellerDialog
+ .getByRole("textbox", { name: "Email" })
+ .fill(TEST_SELLER_DATA.email);
+
+ await manageSellerDialog
+ .getByRole("button", { name: "Save Seller" })
+ .click();
+
+ await expect(
+ page.getByText("Seller added and applied to invoice", { exact: true }),
+ ).toBeVisible();
+
+ const sellerForm = page.getByTestId(`seller-information-section`);
+ const sellerDropdown = sellerForm.getByRole("combobox", {
+ name: "Select Seller",
+ });
+
+ // Seller is currently selected in dropdown
+ await expect(sellerDropdown).not.toHaveValue("");
+
+ // Restore to default by selecting the empty option
+ await sellerDropdown.selectOption("");
+
+ // Verify "Seller restored to default" toast
+ await expect(
+ page.getByText("Seller restored to default", { exact: true }),
+ ).toBeVisible();
+
+ // Verify form reset to default values
+ await expect(sellerForm.getByRole("textbox", { name: "Name" })).toHaveValue(
+ DEFAULT_SELLER_DATA.name,
+ );
+ await expect(
+ sellerForm.getByRole("textbox", { name: "Address" }),
+ ).toHaveValue(DEFAULT_SELLER_DATA.address);
+ await expect(
+ sellerForm.getByRole("textbox", { name: "Email" }),
+ ).toHaveValue(DEFAULT_SELLER_DATA.email);
+
+ // Reselect the saved seller from the dropdown
+ await sellerDropdown.selectOption({ label: TEST_SELLER_DATA.name });
+
+ // Verify `Seller "${name}" applied to invoice` toast
+ await expect(
+ page.getByText(`Seller "${TEST_SELLER_DATA.name}" applied to invoice`, {
+ exact: true,
+ }),
+ ).toBeVisible();
+
+ // Verify form fields are populated with the seller's data
+ await expect(sellerForm.getByRole("textbox", { name: "Name" })).toHaveValue(
+ TEST_SELLER_DATA.name,
+ );
+ await expect(
+ sellerForm.getByRole("textbox", { name: "Address" }),
+ ).toHaveValue(TEST_SELLER_DATA.address);
+ await expect(
+ sellerForm.getByRole("textbox", { name: "Email" }),
+ ).toHaveValue(TEST_SELLER_DATA.email);
+ });
+
test("delete seller", async ({ page }) => {
// First add a seller
await page.getByRole("button", { name: "New Seller" }).click();
diff --git a/src/app/(app)/components/invoice-form/index.tsx b/src/app/(app)/components/invoice-form/index.tsx
index b474e00..5f6f729 100644
--- a/src/app/(app)/components/invoice-form/index.tsx
+++ b/src/app/(app)/components/invoice-form/index.tsx
@@ -377,6 +377,7 @@ export const InvoiceForm = memo(function InvoiceForm({
errors={errors}
setValue={setValue}
dateOfIssue={dateOfIssue}
+ isMobile={isMobile}
/>
</AccordionContent>
</AccordionItem>
@@ -396,6 +397,7 @@ export const InvoiceForm = memo(function InvoiceForm({
errors={errors}
setValue={setValue}
invoiceData={invoiceData}
+ isMobile={isMobile}
/>
</AccordionContent>
</AccordionItem>
@@ -415,6 +417,7 @@ export const InvoiceForm = memo(function InvoiceForm({
errors={errors}
setValue={setValue}
invoiceData={invoiceData}
+ isMobile={isMobile}
/>
</AccordionContent>
</AccordionItem>
diff --git a/src/app/(app)/components/invoice-form/sections/buyer-information.tsx b/src/app/(app)/components/invoice-form/sections/buyer-information.tsx
index ec2a4f9..71f2271 100644
--- a/src/app/(app)/components/invoice-form/sections/buyer-information.tsx
+++ b/src/app/(app)/components/invoice-form/sections/buyer-information.tsx
@@ -29,6 +29,7 @@ interface BuyerInformationProps {
errors: FieldErrors<InvoiceData>;
setValue: UseFormSetValue<InvoiceData>;
invoiceData: InvoiceData;
+ isMobile: boolean;
}
export const BuyerInformation = memo(function BuyerInformation({
@@ -36,6 +37,7 @@ export const BuyerInformation = memo(function BuyerInformation({
errors,
setValue,
invoiceData,
+ isMobile,
}: BuyerInformationProps) {
const [selectedBuyerId, setSelectedBuyerId] = useState("");
const isBuyerSelected = !!selectedBuyerId;
@@ -63,6 +65,7 @@ export const BuyerInformation = memo(function BuyerInformation({
selectedBuyerId={selectedBuyerId}
setSelectedBuyerId={setSelectedBuyerId}
formValues={currentFormValues}
+ isMobile={isMobile}
/>
</div>
<fieldset className="mt-5 space-y-4" disabled={isBuyerSelected}>
diff --git a/src/app/(app)/components/invoice-form/sections/general-information.tsx b/src/app/(app)/components/invoice-form/sections/general-information.tsx
index f3a157f..20497b4 100644
--- a/src/app/(app)/components/invoice-form/sections/general-information.tsx
+++ b/src/app/(app)/components/invoice-form/sections/general-information.tsx
@@ -66,6 +66,7 @@ interface GeneralInformationProps {
errors: FieldErrors<InvoiceData>;
setValue: UseFormSetValue<InvoiceData>;
dateOfIssue: string;
+ isMobile: boolean;
}
export const GeneralInformation = memo(function GeneralInformation({
@@ -73,6 +74,7 @@ export const GeneralInformation = memo(function GeneralInformation({
errors,
setValue,
dateOfIssue,
+ isMobile,
}: GeneralInformationProps) {
const fileInputRef = useRef<HTMLInputElement>(null);
@@ -136,13 +138,23 @@ export const GeneralInformation = memo(function GeneralInformation({
try {
const base64 = await convertFileToBase64(file);
setValue("logo", base64);
- toast.success("Logo uploaded successfully!");
+ toast.success("Logo uploaded successfully!", {
+ id: "logo-uploaded-success-toast",
+ closeButton: true,
+ richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
+ });
} catch (error) {
console.error("Error converting file to base64:", error);
- toast.error("Error uploading image. Please try again.");
+ toast.error("Error uploading image", {
+ description: "Please try again",
+ closeButton: true,
+ richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
+ });
}
},
- [setValue],
+ [isMobile, setValue],
);
const handleLogoRemove = useCallback(() => {
@@ -150,8 +162,13 @@ export const GeneralInformation = memo(function GeneralInformation({
if (fileInputRef.current) {
fileInputRef.current.value = "";
}
- toast.success("Logo removed successfully!");
- }, [setValue]);
+ toast.success("Logo removed successfully!", {
+ id: "logo-removed-success-toast",
+ closeButton: true,
+ richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
+ });
+ }, [isMobile, setValue]);
return (
<div>
diff --git a/src/app/(app)/components/invoice-form/sections/seller-information.tsx b/src/app/(app)/components/invoice-form/sections/seller-information.tsx
index 9fb9882..e9ed0da 100644
--- a/src/app/(app)/components/invoice-form/sections/seller-information.tsx
+++ b/src/app/(app)/components/invoice-form/sections/seller-information.tsx
@@ -27,6 +27,7 @@ interface SellerInformationProps {
errors: FieldErrors<InvoiceData>;
setValue: UseFormSetValue<InvoiceData>;
invoiceData: InvoiceData;
+ isMobile: boolean;
}
export const SellerInformation = memo(function SellerInformation({
@@ -34,6 +35,7 @@ export const SellerInformation = memo(function SellerInformation({
errors,
setValue,
invoiceData,
+ isMobile,
}: SellerInformationProps) {
const [selectedSellerId, setSelectedSellerId] = useState("");
const isSellerSelected = !!selectedSellerId;
@@ -65,6 +67,7 @@ export const SellerInformation = memo(function SellerInformation({
selectedSellerId={selectedSellerId}
setSelectedSellerId={setSelectedSellerId}
formValues={currentFormValues}
+ isMobile={isMobile}
/>
</div>
<fieldset className="mt-5 space-y-4">
diff --git a/src/app/(app)/page.client.tsx b/src/app/(app)/page.client.tsx
index e057641..7ca64d9 100644
--- a/src/app/(app)/page.client.tsx
+++ b/src/app/(app)/page.client.tsx
@@ -492,7 +492,7 @@ export function AppPageClient({
if (!canShareInvoice) {
toast.error("Unable to Share Invoice", {
id: "unable-to-share-invoice-error-toast",
- duration: 5000,
+ duration: 10_000,
description: (
<>
<p className="text-pretty text-xs leading-relaxed text-red-700">
diff --git a/src/components/buyer-management.tsx b/src/components/buyer-management.tsx
index f47867b..609bd7a 100644
--- a/src/components/buyer-management.tsx
+++ b/src/components/buyer-management.tsx
@@ -33,6 +33,7 @@ interface BuyerManagementProps {
selectedBuyerId: string;
setSelectedBuyerId: (id: string) => void;
formValues?: Partial<BuyerData>;
+ isMobile: boolean;
}
/**
@@ -61,6 +62,7 @@ export function BuyerManagement({
selectedBuyerId,
setSelectedBuyerId,
formValues,
+ isMobile,
}: BuyerManagementProps) {
const [isBuyerDialogOpen, setIsBuyerDialogOpen] = useState(false);
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
@@ -131,10 +133,16 @@ export function BuyerManagement({
setSelectedBuyerId(newBuyerWithId?.id);
}
- toast.success("Buyer added successfully", {
- id: "add_buyer_success_toast",
- richColors: true,
- });
+ toast.success(
+ shouldApplyNewBuyerToInvoice
+ ? "Buyer added and applied to invoice"
+ : "Buyer added successfully",
+ {
+ id: "add_buyer_success_toast",
+ richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
+ },
+ );
// analytics track event
umamiTrackEvent("add_buyer_success");
@@ -143,7 +151,9 @@ export function BuyerManagement({
toast.error("Failed to add buyer", {
id: "add_buyer_error_toast",
+ description: "Please try again",
closeButton: true,
+ position: isMobile ? "top-center" : "bottom-right",
});
Sentry.captureException(error);
@@ -171,6 +181,7 @@ export function BuyerManagement({
toast.success("Buyer updated successfully", {
id: "edit_buyer_success_toast",
richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
});
// analytics track event
@@ -180,7 +191,9 @@ export function BuyerManagement({
toast.error("Failed to edit buyer", {
id: "edit_buyer_error_toast",
+ description: "Please try again",
closeButton: true,
+ position: isMobile ? "top-center" : "bottom-right",
});
Sentry.captureException(error);
@@ -198,11 +211,22 @@ export function BuyerManagement({
if (selectedBuyer) {
setValue("buyer", selectedBuyer);
+ toast.success(`Buyer "${selectedBuyer.name}" applied to invoice`, {
+ id: "change_buyer_success_toast",
+ richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
+ });
}
} else {
// Clear the buyer from the form if the user selects the empty option
setSelectedBuyerId("");
setValue("buyer", DEFAULT_BUYER_DATA);
+
+ toast.success("Buyer restored to default", {
+ id: "reset_buyer_success_toast",
+ richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
+ });
}
// analytics track event
@@ -233,6 +257,7 @@ export function BuyerManagement({
toast.success("Buyer deleted successfully", {
id: "delete_buyer_success_toast",
richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
});
// analytics track event
@@ -242,7 +267,9 @@ export function BuyerManagement({
toast.error("Failed to delete buyer", {
id: "delete_buyer_error_toast",
+ description: "Please try again",
closeButton: true,
+ position: isMobile ? "top-center" : "bottom-right",
});
Sentry.captureException(error);
@@ -346,6 +373,7 @@ export function BuyerManagement({
setIsBuyerDialogOpen(true);
} else {
toast.error("Unable to add buyer", {
+ id: "unable-to-add-buyer-error-toast",
description: (
<>
<p className="text-pretty text-xs leading-relaxed text-red-700">
@@ -354,6 +382,7 @@ export function BuyerManagement({
</p>
</>
),
+ position: isMobile ? "top-center" : "bottom-right",
});
}
}}
diff --git a/src/components/seller-management.tsx b/src/components/seller-management.tsx
index 842a138..b75d816 100644
--- a/src/components/seller-management.tsx
+++ b/src/components/seller-management.tsx
@@ -40,6 +40,7 @@ interface SellerManagementProps {
selectedSellerId: string;
setSelectedSellerId: Dispatch<SetStateAction<string>>;
formValues?: Partial<SellerData>;
+ isMobile: boolean;
}
/**
@@ -68,6 +69,7 @@ export function SellerManagement({
selectedSellerId,
setSelectedSellerId,
formValues,
+ isMobile,
}: SellerManagementProps) {
const [isSellerDialogOpen, setIsSellerDialogOpen] = useState(false);
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
@@ -147,10 +149,16 @@ export function SellerManagement({
setSelectedSellerId(newSellerWithId?.id);
}
- toast.success("Seller added successfully", {
- id: "add_seller_success_toast",
- richColors: true,
- });
+ toast.success(
+ shouldApplyNewSellerToInvoice
+ ? "Seller added and applied to invoice"
+ : "Seller added successfully",
+ {
+ id: "add_seller_success_toast",
+ richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
+ },
+ );
// analytics track event
umamiTrackEvent("add_seller_success");
@@ -159,7 +167,9 @@ export function SellerManagement({
toast.error("Failed to add seller", {
id: "add_seller_error_toast",
+ description: "Please try again",
closeButton: true,
+ position: isMobile ? "top-center" : "bottom-right",
});
Sentry.captureException(error);
@@ -187,6 +197,7 @@ export function SellerManagement({
toast.success("Seller updated successfully", {
id: "edit_seller_success_toast",
richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
});
// analytics track event
@@ -196,7 +207,9 @@ export function SellerManagement({
toast.error("Failed to edit seller", {
id: "edit_seller_error_toast",
+ description: "Please try again",
closeButton: true,
+ position: isMobile ? "top-center" : "bottom-right",
});
Sentry.captureException(error);
@@ -214,11 +227,22 @@ export function SellerManagement({
if (selectedSeller) {
setValue("seller", selectedSeller);
+ toast.success(`Seller "${selectedSeller.name}" applied to invoice`, {
+ id: "change_seller_success_toast",
+ richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
+ });
}
} else {
// Clear the seller from the form if the user selects the empty option
setSelectedSellerId("");
setValue("seller", DEFAULT_SELLER_DATA);
+
+ toast.success("Seller restored to default", {
+ id: "reset_seller_success_toast",
+ richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
+ });
}
// analytics track event
@@ -249,6 +273,7 @@ export function SellerManagement({
toast.success("Seller deleted successfully", {
id: "delete_seller_success_toast",
richColors: true,
+ position: isMobile ? "top-center" : "bottom-right",
});
// analytics track event
@@ -258,7 +283,9 @@ export function SellerManagement({
toast.error("Failed to delete seller", {
id: "delete_seller_error_toast",
+ description: "Please try again",
closeButton: true,
+ position: isMobile ? "top-center" : "bottom-right",
});
Sentry.captureException(error);
@@ -362,6 +389,8 @@ export function SellerManagement({
setIsSellerDialogOpen(true);
} else {
toast.error("Unable to add seller", {
+ id: "unable-to-add-seller-error-toast",
+ closeButton: true,
description: (
<>
<p className="text-pretty text-xs leading-relaxed text-red-700">
@@ -370,6 +399,7 @@ export function SellerManagement({
</p>
</>
),
+ position: isMobile ? "top-center" : "bottom-right",
});
}
}}