"chore: update frontend dev script to include lint checks and add ESLint config file"

This commit is contained in:
louiscklaw
2025-06-04 02:35:32 +08:00
parent c0fad42f0a
commit 22fb620eef
48 changed files with 3315 additions and 97 deletions

View File

@@ -37,19 +37,22 @@ export function InvoiceDetails({ invoice }: Props) {
const { t } = useTranslation();
const [currentStatus, setCurrentStatus] = useState(invoice?.status);
const handleChangeStatus = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
// setCurrentStatus(event.target.value);
const handleChangeStatus = useCallback(
(event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
// setCurrentStatus(event.target.value);
try {
changeStatus(invoice.id, event.target.value);
setCurrentStatus(event.target.value);
try {
changeStatus(invoice.id, event.target.value);
setCurrentStatus(event.target.value);
toast.success('status changed!');
} catch (error) {
console.error(error);
toast.warning('error during changing status');
}
}, []);
toast.success('status changed!');
} catch (error) {
console.error(error);
toast.warning('error during changing status');
}
},
[]
);
const renderFooter = () => (
<Box

View File

@@ -1,4 +1,4 @@
import type { IInvoiceItem } from 'src/types/invoice';
import type { IInvoiceItem, IInvoiceItemItem } from 'src/types/invoice';
import { sumBy } from 'es-toolkit';
import { useEffect, useCallback } from 'react';
@@ -22,7 +22,7 @@ import { InvoiceTotalSummary } from './invoice-total-summary';
// ----------------------------------------------------------------------
export const defaultItem: Omit<IInvoiceItem, 'id'> = {
export const defaultItem: Omit<IInvoiceItemItem, 'id'> = {
title: '',
description: '',
service: INVOICE_SERVICE_OPTIONS[0].name,
@@ -50,7 +50,7 @@ export function InvoiceNewEditDetails() {
const discount = getValues('discount');
const shipping = getValues('shipping');
const subtotal = sumBy(items, (item: IInvoiceItem) => item.quantity * item.price);
const subtotal = sumBy(items, (item: IInvoiceItemItem) => item.quantity * item.price);
const subtotalWithTax = subtotal + subtotal * (taxes / 100);
const totalAmount = subtotalWithTax - discount - shipping;

View File

@@ -81,6 +81,8 @@ export function InvoiceNewEditForm({ currentInvoice }: Props) {
const loadingSend = useBoolean();
const defaultValues: NewInvoiceSchemaType = {
id: '',
sent: 0,
invoiceNumber: 'INV-1990',
createDate: today(),
dueDate: null,
@@ -129,6 +131,8 @@ export function InvoiceNewEditForm({ currentInvoice }: Props) {
try {
if (currentInvoice) {
data.dueDate = '2029-01-01';
await saveInvoice(currentInvoice.id, data);
}

View File

@@ -27,7 +27,7 @@ type Props = {
invoice?: IInvoiceItem;
currentStatus: string;
statusOptions: { value: string; label: string }[];
onChangeStatus: (event: React.ChangeEvent<HTMLInputElement>) => void;
onChangeStatus: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
};
export function InvoiceToolbar({ invoice, currentStatus, statusOptions, onChangeStatus }: Props) {