Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue on create project form #122

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export default function CreateprojectLayout() {
const isTerrainFollow = useTypedSelector(
state => state.createproject.isTerrainFollow,
);
const isNoflyzonePresent = useTypedSelector(
state => state.createproject.isNoflyzonePresent,
);

const initialState: FieldValues = {
name: '',
Expand Down Expand Up @@ -155,6 +158,25 @@ export default function CreateprojectLayout() {
};

const onSubmit = (data: any) => {
if (activeStep === 2) {
if (
!data?.outline_geojson ||
(Array.isArray(data?.outline_geojson) &&
data?.outline_geojson?.length === 0)
) {
toast.error('Please upload or draw and save project area');
return;
}
if (
isNoflyzonePresent === 'yes' &&
(!data?.outline_no_fly_zones ||
data?.outline_no_fly_zones?.length === 0)
) {
toast.error('Please upload or draw and save No Fly zone area');
return;
}
}

if (activeStep === 4 && !splitGeojson) return;
if (activeStep !== 5) {
dispatch(setCreateProjectState({ activeStep: activeStep + 1 }));
Expand All @@ -164,6 +186,9 @@ export default function CreateprojectLayout() {
...data,
is_terrain_follow: isTerrainFollow === 'hilly',
};
// remove key
if (isNoflyzonePresent === 'no') delete payload?.outline_no_fly_zones;

createProject(payload);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function BasicInformation({
placeholder="Enter Name of the Project"
{...register('name', {
required: 'Name of the project is required',
setValueAs: (value: string) => value.trim(),
})}
/>
<ErrorMessage message={errors?.name?.message as string} />
Expand All @@ -28,6 +29,7 @@ export default function BasicInformation({
placeholder="Description of the Project"
{...register('description', {
required: 'Description is Required',
setValueAs: (value: string) => value.trim(),
})}
/>
<ErrorMessage message={errors?.description?.message as string} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function Conditions({
placeholder="Enter Instructions for Drone Operators"
{...register('per_task_instructions', {
required: 'Instructions are required',
setValueAs: (value: string) => value.trim(),
})}
/>
<ErrorMessage
Expand Down
Loading