|
|
@@ -31,6 +31,7 @@ import { FooterPropsOverrides } from "@mui/x-data-grid"; |
|
|
|
import { th } from "@faker-js/faker"; |
|
|
|
import { GridRowIdGetter } from "@mui/x-data-grid"; |
|
|
|
import { useFormContext } from "react-hook-form"; |
|
|
|
import { ProjectResult } from "@/app/api/projects"; |
|
|
|
|
|
|
|
type InvoiceListError = { |
|
|
|
[field in keyof invoiceList]?: string; |
|
|
@@ -43,6 +44,10 @@ type invoiceListRow = Partial< |
|
|
|
} |
|
|
|
>; |
|
|
|
|
|
|
|
interface Props { |
|
|
|
projects: ProjectResult[]; |
|
|
|
} |
|
|
|
|
|
|
|
class ProcessRowUpdateError extends Error { |
|
|
|
public readonly row: invoiceListRow; |
|
|
|
public readonly errors: InvoiceListError | undefined; |
|
|
@@ -58,15 +63,19 @@ class ProcessRowUpdateError extends Error { |
|
|
|
Object.setPrototypeOf(this, ProcessRowUpdateError.prototype); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const InvoiceTable: React.FC = () => { |
|
|
|
type project = { |
|
|
|
label: string; |
|
|
|
value: number; |
|
|
|
} |
|
|
|
const InvoiceTable: React.FC<Props> = ({ projects }) => { |
|
|
|
console.log(projects) |
|
|
|
const { t } = useTranslation() |
|
|
|
const [rowModesModel, setRowModesModel] = useState<GridRowModesModel>({}); |
|
|
|
const [selectedRow, setSelectedRow] = useState<invoiceListRow[] | []>([]); |
|
|
|
const { getValues, setValue, clearErrors, setError } = |
|
|
|
useFormContext<any>(); |
|
|
|
const apiRef = useGridApiRef(); |
|
|
|
|
|
|
|
const [projectCode, setProjectCode] = useState<project>({label: "", value: 0}) |
|
|
|
const validateInvoiceEntry = ( |
|
|
|
entry: Partial<invoiceList>, |
|
|
|
): InvoiceListError | undefined => { |
|
|
|