source: src/sections/invoice/invoice-new-edit-status-date.tsx@ 87c9f1e

main
Last change on this file since 87c9f1e was 87c9f1e, checked in by Naum Shapkarovski <naumshapkarovski@…>, 5 weeks ago

update the seed script. update the prisma schema, use mapping

  • Property mode set to 100644
File size: 3.8 KB
Line 
1import { useFormContext, Controller } from 'react-hook-form';
2// @mui
3import { DatePicker } from '@mui/x-date-pickers/DatePicker';
4import Stack from '@mui/material/Stack';
5import MenuItem from '@mui/material/MenuItem';
6// components
7import { RHFSelect, RHFTextField } from 'src/components/hook-form';
8// api
9// import { useGetTenant } from 'src/api/settings';
10// utils
11import { incrementInvoiceNumber } from 'src/utils/increment-invoice-number';
12
13export const monthNames = [
14 'January',
15 'February',
16 'March',
17 'April',
18 'May',
19 'June',
20 'July',
21 'August',
22 'September',
23 'October',
24 'November',
25 'December',
26];
27
28// ----------------------------------------------------------------------
29
30export default function InvoiceNewEditStatusDate({ isCopy }: { isCopy?: boolean }) {
31 const { control, watch } = useFormContext();
32
33 const values = watch();
34
35 // const { settings } = useGetTenant();
36
37 return (
38 <Stack
39 spacing={2}
40 direction={{ xs: 'column', sm: 'row' }}
41 sx={{ p: 3, bgcolor: 'background.neutral' }}
42 >
43 {isCopy ? (
44 <RHFTextField
45 disabled
46 name="invoiceNumber"
47 label="Invoice number"
48 value={values.invoiceNumber}
49 />
50 ) : (
51 <RHFTextField name="invoiceNumber" label="Invoice number" value={values.invoiceNumber} />
52 )}
53
54 <RHFSelect
55 fullWidth
56 name="month"
57 label="Month"
58 InputLabelProps={{ shrink: true }}
59 PaperPropsSx={{ textTransform: 'uppercase' }}
60 >
61 {monthNames.map((option) => (
62 <MenuItem key={option} value={option}>
63 {option}
64 </MenuItem>
65 ))}
66 </RHFSelect>
67
68 <RHFSelect
69 fullWidth
70 name="status"
71 label="Status"
72 InputLabelProps={{ shrink: true }}
73 PaperPropsSx={{ textTransform: 'capitalize' }}
74 >
75 {['paid', 'pending', 'overdue', 'draft'].map((option) => (
76 <MenuItem key={option} value={option}>
77 {option}
78 </MenuItem>
79 ))}
80 </RHFSelect>
81
82 <RHFSelect
83 fullWidth
84 name="currency"
85 label="Currency"
86 InputLabelProps={{ shrink: true }}
87 PaperPropsSx={{ textTransform: 'uppercase' }}
88 >
89 {['EUR', 'USD'].map((option) => (
90 <MenuItem key={option} value={option}>
91 {option}
92 </MenuItem>
93 ))}
94 </RHFSelect>
95
96 <RHFSelect
97 fullWidth
98 name="quantityType"
99 label="Quantity Type"
100 InputLabelProps={{ shrink: true }}
101 PaperPropsSx={{ textTransform: 'uppercase' }}
102 >
103 {['Unit', 'Hour', 'Sprint', 'Month'].map((option) => (
104 <MenuItem key={option} value={option}>
105 {option}
106 </MenuItem>
107 ))}
108 </RHFSelect>
109
110 <Controller
111 name="issueDate"
112 control={control}
113 render={({ field, fieldState: { error } }) => (
114 <DatePicker
115 label="Date issued"
116 value={field.value}
117 onChange={(newValue) => {
118 field.onChange(newValue);
119 }}
120 slotProps={{
121 textField: {
122 fullWidth: true,
123 error: !!error,
124 helperText: error?.message,
125 },
126 }}
127 />
128 )}
129 />
130
131 <Controller
132 name="dueDate"
133 control={control}
134 render={({ field, fieldState: { error } }) => (
135 <DatePicker
136 label="Due date"
137 value={field.value}
138 onChange={(newValue) => {
139 field.onChange(newValue);
140 }}
141 slotProps={{
142 textField: {
143 fullWidth: true,
144 error: !!error,
145 helperText: error?.message,
146 },
147 }}
148 />
149 )}
150 />
151 </Stack>
152 );
153}
Note: See TracBrowser for help on using the repository browser.