Skip to content

Commit

Permalink
EmployeeWebClient - complete summary step
Browse files Browse the repository at this point in the history
  • Loading branch information
bartstc committed Dec 7, 2022
1 parent 0f16d44 commit df41152
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ const FormStepProgressBar = () => {
const getProgress = () => {
switch (step) {
case FacilityFormStep.Base_info:
return 33.33;
return 25;
case FacilityFormStep.Working_hours:
return 66.66;
return 50;
case FacilityFormStep.Contact:
return 75;
case FacilityFormStep.Summary:
return 100;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const NextStepButton = ({ formStep }: IProps) => {
variant='solid'
colorScheme='primary'
id={`go-to-${kebabCase(formStep)}`}
isDisabled={step === FacilityFormStep.Contact}
isDisabled={step === FacilityFormStep.Summary}
type='submit'
rightIcon={<ChevronRightIcon />}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { useIntl } from 'react-intl';

import { Button } from 'shared/Button';

import { ChevronRightIcon } from '@chakra-ui/icons';

const SubmitButton = () => {
const { formatMessage } = useIntl();

return (
<Button variant='solid' colorScheme='green' id={`submit-facility-form`} rightIcon={<ChevronRightIcon />}>
{formatMessage({ id: 'submit', defaultMessage: 'Submit' })}
</Button>
);
};

export { SubmitButton };
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
import React from 'react';
import { useIntl } from 'react-intl';
import { ButtonGroup } from '@chakra-ui/react';

import { ListItem } from 'shared/DescriptionListV2';
import { ListItem, Divider } from 'shared/DescriptionListV2';
import { List, IndentLabel } from 'shared/IndentiationList';

import { useFacilityFormStore } from '../createFacilityFormStore';
import { CreateFacilityFormDto } from '../../../application/types';
import { CreateFacilityMapper } from '../../../application';
import { FacilityBody } from '../../FacilityBody';
import { FormStepHeader } from '../FormStepHeader';
import { PreviousStepButton } from '../PreviousStepButton';
import { SubmitButton } from '../SubmitButton';

const SummaryStep = () => {
const { formatMessage } = useIntl();
const data = useFacilityFormStore(store => store.data);
const step = useFacilityFormStore(store => store.step);

return (
<FacilityBody facility={CreateFacilityMapper.formToModel(data as CreateFacilityFormDto)}>
<List>
<ListItem>
<FormStepHeader>
{formatMessage({
id: 'summary-facility-step-three',
defaultMessage: 'Step 4: Summary',
})}
</FormStepHeader>
<FacilityBody facility={CreateFacilityMapper.formToModel(data as CreateFacilityFormDto)}>
<ListItem>
<FormStepHeader>
{formatMessage({
id: 'summary-facility-step-three',
defaultMessage: 'Step 4: Summary',
})}
</FormStepHeader>
</ListItem>
</FacilityBody>
</ListItem>
</FacilityBody>
<Divider />
<IndentLabel>
<ButtonGroup>
<PreviousStepButton formStep={step} />
<SubmitButton />
</ButtonGroup>
</IndentLabel>
</List>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum FacilityFormStep {
Base_info = 'base info',
Working_hours = 'working hours',
Contact = 'contact',
Summary = 'summary',
}

type FacilityFormStore = {
Expand Down Expand Up @@ -35,7 +36,9 @@ export const useFacilityFormStore = create<FacilityFormStore>((set, get) => {
case FacilityFormStep.Working_hours:
return FacilityFormStep.Contact;
case FacilityFormStep.Contact:
return FacilityFormStep.Contact;
return FacilityFormStep.Summary;
case FacilityFormStep.Summary:
return FacilityFormStep.Summary;
}
};

Expand All @@ -44,19 +47,21 @@ export const useFacilityFormStore = create<FacilityFormStore>((set, get) => {
});
},
previous() {
const getNextStep = () => {
const getPrevStep = () => {
switch (get().step) {
case FacilityFormStep.Base_info:
return FacilityFormStep.Base_info;
case FacilityFormStep.Working_hours:
return FacilityFormStep.Base_info;
case FacilityFormStep.Contact:
return FacilityFormStep.Working_hours;
case FacilityFormStep.Summary:
return FacilityFormStep.Contact;
}
};

set({
step: getNextStep(),
step: getPrevStep(),
});
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface IProps extends GridItemProps {

const ListItem = ({ children, ...props }: IProps) => {
return (
<GridItem colSpan={3} {...props}>
<GridItem colStart={1} colEnd={-1} {...props}>
{children}
</GridItem>
);
Expand Down

0 comments on commit df41152

Please sign in to comment.