mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
chore: rename ExpenseForm to ExpenseRequestForm
This commit is contained in:
+45
-11
@@ -10,12 +10,15 @@ import Button from '@/components/Button';
|
|||||||
import TextInput from '@/components/input/TextInput';
|
import TextInput from '@/components/input/TextInput';
|
||||||
import { useModal } from '@/components/Modal';
|
import { useModal } from '@/components/Modal';
|
||||||
import ConfirmationModal from '@/components/modal/ConfirmationModal';
|
import ConfirmationModal from '@/components/modal/ConfirmationModal';
|
||||||
|
import SelectInput from '@/components/input/SelectInput';
|
||||||
|
import DateInput from '@/components/input/DateInput';
|
||||||
|
import ExpenseKandangsTable from '@/components/pages/expense/form/ExpenseKandangsTable';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ExpenseFormSchema,
|
ExpenseRequestFormSchema,
|
||||||
ExpenseFormValues,
|
ExpenseRequestFormValues,
|
||||||
UpdateExpenseFormSchema,
|
UpdateExpenseRequestFormSchema,
|
||||||
} from '@/components/pages/expense/form/ExpenseForm.schema';
|
} from '@/components/pages/expense/form/ExpenseRequestForm.schema';
|
||||||
import { isResponseError } from '@/lib/api-helper';
|
import { isResponseError } from '@/lib/api-helper';
|
||||||
import {
|
import {
|
||||||
Expense,
|
Expense,
|
||||||
@@ -31,7 +34,10 @@ interface ExpenseFormProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: integrate this with real API
|
// TODO: integrate this with real API
|
||||||
const ExpenseForm = ({ type = 'add', initialValues }: ExpenseFormProps) => {
|
const ExpenseRequestForm = ({
|
||||||
|
type = 'add',
|
||||||
|
initialValues,
|
||||||
|
}: ExpenseFormProps) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
// Modal hooks
|
// Modal hooks
|
||||||
@@ -72,16 +78,18 @@ const ExpenseForm = ({ type = 'add', initialValues }: ExpenseFormProps) => {
|
|||||||
[router]
|
[router]
|
||||||
);
|
);
|
||||||
|
|
||||||
const formikInitialValues = useMemo<ExpenseFormValues>(() => {
|
const formikInitialValues = useMemo<ExpenseRequestFormValues>(() => {
|
||||||
return {
|
return {
|
||||||
name: initialValues?.name ?? '',
|
name: initialValues?.name ?? '',
|
||||||
};
|
};
|
||||||
}, [initialValues]);
|
}, [initialValues]);
|
||||||
|
|
||||||
const formik = useFormik<ExpenseFormValues>({
|
const formik = useFormik<ExpenseRequestFormValues>({
|
||||||
initialValues: formikInitialValues,
|
initialValues: formikInitialValues,
|
||||||
validationSchema:
|
validationSchema:
|
||||||
type === 'edit' ? UpdateExpenseFormSchema : ExpenseFormSchema,
|
type === 'edit'
|
||||||
|
? UpdateExpenseRequestFormSchema
|
||||||
|
: ExpenseRequestFormSchema,
|
||||||
onSubmit: async (values) => {
|
onSubmit: async (values) => {
|
||||||
setExpenseFormErrorMessage('');
|
setExpenseFormErrorMessage('');
|
||||||
|
|
||||||
@@ -161,8 +169,15 @@ const ExpenseForm = ({ type = 'add', initialValues }: ExpenseFormProps) => {
|
|||||||
onReset={formik.handleReset}
|
onReset={formik.handleReset}
|
||||||
className='w-full mt-8 flex flex-col gap-6'
|
className='w-full mt-8 flex flex-col gap-6'
|
||||||
>
|
>
|
||||||
<div className='flex flex-col gap-4'>
|
<div className='grid grid-cols-12 gap-4'>
|
||||||
<TextInput
|
<SelectInput
|
||||||
|
label='Lokasi'
|
||||||
|
placeholder='Pilih Lokasi'
|
||||||
|
options={[]}
|
||||||
|
className={{ wrapper: 'col-span-12 sm:col-span-6' }}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* <TextInput
|
||||||
required
|
required
|
||||||
label='Nama'
|
label='Nama'
|
||||||
name='name'
|
name='name'
|
||||||
@@ -173,6 +188,25 @@ const ExpenseForm = ({ type = 'add', initialValues }: ExpenseFormProps) => {
|
|||||||
isError={formik.touched.name && Boolean(formik.errors.name)}
|
isError={formik.touched.name && Boolean(formik.errors.name)}
|
||||||
errorMessage={formik.errors.name}
|
errorMessage={formik.errors.name}
|
||||||
readOnly={type === 'detail'}
|
readOnly={type === 'detail'}
|
||||||
|
className={{
|
||||||
|
wrapper: 'col-span-12 sm:col-span-6',
|
||||||
|
}}
|
||||||
|
/> */}
|
||||||
|
|
||||||
|
<DateInput
|
||||||
|
name='transaction_date'
|
||||||
|
label='Tanggal Transaksi'
|
||||||
|
className={{
|
||||||
|
wrapper: 'col-span-12 sm:col-span-6',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ExpenseKandangsTable
|
||||||
|
type={type}
|
||||||
|
locationId={2}
|
||||||
|
className={{
|
||||||
|
wrapper: 'w-full col-span-12',
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -300,4 +334,4 @@ const ExpenseForm = ({ type = 'add', initialValues }: ExpenseFormProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ExpenseForm;
|
export default ExpenseRequestForm;
|
||||||
Reference in New Issue
Block a user