Compare commits
No commits in common. "ai-dev" and "master" have entirely different histories.
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,8 +1,3 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
*/node_modules/
|
*/node_modules/
|
||||||
*/build/
|
*/build/
|
||||||
|
|
||||||
**/node_modules/
|
|
||||||
**/build/
|
|
||||||
.DS_Store
|
|
||||||
.env
|
|
||||||
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
@ -1,190 +1,103 @@
|
|||||||
import React, { useState } from 'react';
|
import {
|
||||||
|
mdiAccount,
|
||||||
|
mdiChartTimelineVariant,
|
||||||
|
mdiMail,
|
||||||
|
mdiUpload,
|
||||||
|
} from '@mdi/js';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import { Formik, Form, Field, FieldArray } from 'formik';
|
import React, { ReactElement } from 'react';
|
||||||
|
import CardBox from '../../components/CardBox';
|
||||||
|
import LayoutAuthenticated from '../../layouts/Authenticated';
|
||||||
import SectionMain from '../../components/SectionMain';
|
import SectionMain from '../../components/SectionMain';
|
||||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
|
||||||
import CardBox from '../../components/CardBox';
|
import { getPageTitle } from '../../config';
|
||||||
import BaseButton from '../../components/BaseButton';
|
|
||||||
import BaseButtons from '../../components/BaseButtons';
|
import { Field, Form, Formik } from 'formik';
|
||||||
import BaseDivider from '../../components/BaseDivider';
|
|
||||||
import FormField from '../../components/FormField';
|
import FormField from '../../components/FormField';
|
||||||
|
import BaseDivider from '../../components/BaseDivider';
|
||||||
|
import BaseButtons from '../../components/BaseButtons';
|
||||||
|
import BaseButton from '../../components/BaseButton';
|
||||||
|
import FormCheckRadio from '../../components/FormCheckRadio';
|
||||||
|
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup';
|
||||||
|
import FormFilePicker from '../../components/FormFilePicker';
|
||||||
|
import FormImagePicker from '../../components/FormImagePicker';
|
||||||
|
import { SwitchField } from '../../components/SwitchField';
|
||||||
|
|
||||||
import { SelectField } from '../../components/SelectField';
|
import { SelectField } from '../../components/SelectField';
|
||||||
import { SelectFieldMany } from '../../components/SelectFieldMany';
|
import { SelectFieldMany } from '../../components/SelectFieldMany';
|
||||||
import { mdiChartTimelineVariant } from '@mdi/js';
|
import { RichTextField } from '../../components/RichTextField';
|
||||||
|
|
||||||
|
import { create } from '../../stores/rfqs/rfqsSlice';
|
||||||
import { useAppDispatch } from '../../stores/hooks';
|
import { useAppDispatch } from '../../stores/hooks';
|
||||||
import { create as createRfqs } from '../../stores/rfqs/rfqsSlice';
|
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
client_name: '',
|
client_name: '',
|
||||||
|
|
||||||
system_type: '',
|
system_type: '',
|
||||||
|
|
||||||
custom_options: [],
|
custom_options: [],
|
||||||
rfqnumber: '',
|
|
||||||
client_address: '',
|
|
||||||
status: 'draft',
|
|
||||||
locations: [
|
|
||||||
{
|
|
||||||
safety_item_1: '',
|
|
||||||
safety_item_2: '',
|
|
||||||
safety_item_3: '',
|
|
||||||
safety_item_4: '',
|
|
||||||
safety_item_5: '',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const RfqsNew = () => {
|
const RfqsNew = () => {
|
||||||
const [step, setStep] = useState(0);
|
|
||||||
const dispatch = useAppDispatch();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const handleSubmit = async (values) => {
|
const handleSubmit = async (data) => {
|
||||||
await dispatch(createRfqs(values));
|
await dispatch(create(data));
|
||||||
router.push('/rfqs/rfqs-list');
|
await router.push('/rfqs/rfqs-list');
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>New RFQ</title>
|
<title>{getPageTitle('New Item')}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<SectionMain>
|
<SectionMain>
|
||||||
<SectionTitleLineWithButton
|
<SectionTitleLineWithButton
|
||||||
icon={mdiChartTimelineVariant}
|
icon={mdiChartTimelineVariant}
|
||||||
title={step === 0 ? 'RFQ Details' : 'RFQ Locations'}
|
title='New Item'
|
||||||
main
|
main
|
||||||
/>
|
>
|
||||||
|
{''}
|
||||||
|
</SectionTitleLineWithButton>
|
||||||
<CardBox>
|
<CardBox>
|
||||||
<Formik initialValues={initialValues} onSubmit={handleSubmit}>
|
<Formik
|
||||||
{({ values }) => (
|
initialValues={initialValues}
|
||||||
<Form>
|
onSubmit={(values) => handleSubmit(values)}
|
||||||
{step === 0 && (
|
>
|
||||||
<>
|
<Form>
|
||||||
<FormField label="Client Name">
|
<FormField label='ClientName'>
|
||||||
<Field name="client_name" placeholder="Client Name" />
|
<Field name='client_name' placeholder='ClientName' />
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<FormField label="Client Address">
|
<FormField label='SystemType'>
|
||||||
<Field name="client_address" placeholder="Client Address" />
|
<Field name='system_type' placeholder='SystemType' />
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<FormField label="System Type" labelFor="system_type">
|
<FormField label='CustomOptions' labelFor='custom_options'>
|
||||||
<Field
|
<Field
|
||||||
name="system_type"
|
name='custom_options'
|
||||||
id="system_type"
|
id='custom_options'
|
||||||
component={SelectField}
|
itemRef={'custom_options'}
|
||||||
options={[
|
options={[]}
|
||||||
{ value: 'Standard', label: 'Standard' },
|
component={SelectFieldMany}
|
||||||
{ value: 'Custom', label: 'Custom' },
|
></Field>
|
||||||
]}
|
</FormField>
|
||||||
/>
|
|
||||||
</FormField>
|
|
||||||
|
|
||||||
<FormField label="RFQ Number">
|
<BaseDivider />
|
||||||
<Field name="rfqnumber" type="number" placeholder="RFQ Number" />
|
<BaseButtons>
|
||||||
</FormField>
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
<BaseButton type='reset' color='info' outline label='Reset' />
|
||||||
<FormField label="Custom Options" labelFor="custom_options">
|
<BaseButton
|
||||||
<Field
|
type='reset'
|
||||||
name="custom_options"
|
color='danger'
|
||||||
id="custom_options"
|
outline
|
||||||
itemRef="custom_options"
|
label='Cancel'
|
||||||
component={SelectFieldMany}
|
onClick={() => router.push('/rfqs/rfqs-list')}
|
||||||
options={[]}
|
/>
|
||||||
/>
|
</BaseButtons>
|
||||||
</FormField>
|
</Form>
|
||||||
|
|
||||||
<BaseDivider />
|
|
||||||
<BaseButtons>
|
|
||||||
<BaseButton
|
|
||||||
type="button"
|
|
||||||
color="info"
|
|
||||||
label="Next"
|
|
||||||
onClick={() => setStep(1)}
|
|
||||||
/>
|
|
||||||
</BaseButtons>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{step === 1 && (
|
|
||||||
<>
|
|
||||||
<FieldArray name="locations">
|
|
||||||
{({ remove, push }) => (
|
|
||||||
<>
|
|
||||||
{values.locations.map((loc, index) => (
|
|
||||||
<div key={index} style={{ marginBottom: '1rem' }}>
|
|
||||||
<h4>Location #{index + 1}</h4>
|
|
||||||
<FormField label="Safety Item 1">
|
|
||||||
<Field
|
|
||||||
name={`locations[${index}].safety_item_1`}
|
|
||||||
placeholder="Safety Item 1"
|
|
||||||
/>
|
|
||||||
</FormField>
|
|
||||||
<FormField label="Safety Item 2">
|
|
||||||
<Field
|
|
||||||
name={`locations[${index}].safety_item_2`}
|
|
||||||
placeholder="Safety Item 2"
|
|
||||||
/>
|
|
||||||
</FormField>
|
|
||||||
<FormField label="Safety Item 3">
|
|
||||||
<Field
|
|
||||||
name={`locations[${index}].safety_item_3`}
|
|
||||||
placeholder="Safety Item 3"
|
|
||||||
/>
|
|
||||||
</FormField>
|
|
||||||
<FormField label="Safety Item 4">
|
|
||||||
<Field
|
|
||||||
name={`locations[${index}].safety_item_4`}
|
|
||||||
placeholder="Safety Item 4"
|
|
||||||
/>
|
|
||||||
</FormField>
|
|
||||||
<FormField label="Safety Item 5">
|
|
||||||
<Field
|
|
||||||
name={`locations[${index}].safety_item_5`}
|
|
||||||
placeholder="Safety Item 5"
|
|
||||||
/>
|
|
||||||
</FormField>
|
|
||||||
<BaseButton
|
|
||||||
type="button"
|
|
||||||
color="danger"
|
|
||||||
outline
|
|
||||||
label="Remove"
|
|
||||||
onClick={() => remove(index)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
<BaseButton
|
|
||||||
type="button"
|
|
||||||
color="success"
|
|
||||||
label="Add Location"
|
|
||||||
onClick={() =>
|
|
||||||
push({
|
|
||||||
safety_item_1: '',
|
|
||||||
safety_item_2: '',
|
|
||||||
safety_item_3: '',
|
|
||||||
safety_item_4: '',
|
|
||||||
safety_item_5: '',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</FieldArray>
|
|
||||||
|
|
||||||
<BaseDivider />
|
|
||||||
<BaseButtons>
|
|
||||||
<BaseButton
|
|
||||||
type="button"
|
|
||||||
color="info"
|
|
||||||
outline
|
|
||||||
label="Back"
|
|
||||||
onClick={() => setStep(0)}
|
|
||||||
/>
|
|
||||||
<BaseButton type="submit" color="success" label="Submit" />
|
|
||||||
</BaseButtons>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Form>
|
|
||||||
)}
|
|
||||||
</Formik>
|
</Formik>
|
||||||
</CardBox>
|
</CardBox>
|
||||||
</SectionMain>
|
</SectionMain>
|
||||||
@ -192,8 +105,10 @@ const RfqsNew = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
RfqsNew.getLayout = function getLayout(page) {
|
RfqsNew.getLayout = function getLayout(page: ReactElement) {
|
||||||
return page;
|
return (
|
||||||
|
<LayoutAuthenticated permission={'CREATE_RFQS'}>{page}</LayoutAuthenticated>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default RfqsNew;
|
export default RfqsNew;
|
||||||
Loading…
x
Reference in New Issue
Block a user