diff --git a/components/expenses/EditExpenseDialog.tsx b/components/expenses/EditExpenseDialog.tsx index 0dc2c03f2b2..d5985ce7912 100644 --- a/components/expenses/EditExpenseDialog.tsx +++ b/components/expenses/EditExpenseDialog.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { gql, useMutation } from '@apollo/client'; import { DialogClose } from '@radix-ui/react-dialog'; -import type { FormikProps } from 'formik'; import { Form, FormikProvider, useFormikContext } from 'formik'; import { pick } from 'lodash'; import { Pen } from 'lucide-react'; @@ -58,7 +57,7 @@ const EditPayee = ({ expense, onSubmit }) => { allowInvite: false, }); const transformedOnSubmit = React.useCallback( - async (values, h, formOptions, startOptions) => { + async (values, h, formOptions) => { const editValues = { payee: { slug: formOptions.payee?.slug, @@ -107,7 +106,6 @@ const EditPayee = ({ expense, onSubmit }) => { description: '', }, ], - additionalAttachments: [], hasInvoiceOption: YesNoOption.YES, inviteeNewIndividual: {}, inviteeNewOrganization: { @@ -198,8 +196,6 @@ const EditPayoutMethod = ({ expense, onSubmit }) => { description: '', }, ], - additionalAttachments: [], - hasInvoiceOption: YesNoOption.YES, inviteeNewIndividual: {}, inviteeNewOrganization: { organization: {}, @@ -344,9 +340,12 @@ const EditExpenseTitle = ({ expense, onSubmit }) => { }); return ( - - - + onSubmit(schema.parse(values))}> +
+ + + +
); }; @@ -364,47 +363,18 @@ function EditExpenseActionButtons({ return ( - + ); } -function EditExpenseFormikContainer({ schema, initialValues, onSubmit, children }) { - return ( - onSubmit(schema.parse(values))}> - {(formik: FormikProps>) => ( -
- {children} - - - )} -
- ); -} - -// const buildEditExpenseSchema = (field, intl) => { -// const schema = buildFormSchema({}, {}, intl); -// let pick; -// switch (field) { -// case 'description': -// pick = { description: true }; -// break; -// case 'expenseItems': -// pick = { currency: true }; -// break; -// case 'payee': -// pick = { name: true }; -// break; -// default: -// break; -// } -// return schema.pick(pick); -// }; export default function EditExpenseDialog({ expense, field, @@ -416,6 +386,11 @@ export default function EditExpenseDialog({ }: { expense: Expense; field: 'title' | 'expenseItems' | 'payoutMethod' | 'payee' | 'type' | 'attachments'; + title: string; + description?: string; + dialogContentClassName?: string; + triggerClassName?: string; + goToLegacyEdit?: () => void; }) { const [open, setOpen] = React.useState(false); @@ -487,7 +462,7 @@ export default function EditExpenseDialog({ setOpen(false); }} > - Go to edit + ) : ( diff --git a/components/expenses/ExpenseSummary.js b/components/expenses/ExpenseSummary.js index 57d2b49805c..744956b3562 100644 --- a/components/expenses/ExpenseSummary.js +++ b/components/expenses/ExpenseSummary.js @@ -193,7 +193,7 @@ const ExpenseSummary = ({ )} @@ -220,8 +220,11 @@ const ExpenseSummary = ({ {useInlineExpenseEdit && ( @@ -398,7 +401,7 @@ const ExpenseSummary = ({ expense={expense} dialogContentClassName="sm:max-w-xl" field="expenseItems" - title={intl.formatMessage({ defaultMessage: 'Edit expense items', id: 'lzRZ91' })} + title={intl.formatMessage({ defaultMessage: 'Edit expense items', id: 'expense.editItems' })} /> )} @@ -536,7 +539,12 @@ const ExpenseSummary = ({ )} {useInlineExpenseEdit && ( - + )} diff --git a/components/expenses/ExpenseSummaryAdditionalInformation.js b/components/expenses/ExpenseSummaryAdditionalInformation.js index e7f38118fed..0c1458c4054 100644 --- a/components/expenses/ExpenseSummaryAdditionalInformation.js +++ b/components/expenses/ExpenseSummaryAdditionalInformation.js @@ -211,7 +211,7 @@ const ExpenseSummaryAdditionalInformation = ({ )} @@ -279,7 +279,7 @@ const ExpenseSummaryAdditionalInformation = ({ )}