forked from github/plane
style: module modal consistent design (#625)
This commit is contained in:
parent
66ed6a1dc8
commit
64c936b9b5
@ -9,8 +9,7 @@ import cyclesService from "services/cycles.service";
|
|||||||
// hooks
|
// hooks
|
||||||
import useToast from "hooks/use-toast";
|
import useToast from "hooks/use-toast";
|
||||||
// ui
|
// ui
|
||||||
import { Input, PrimaryButton, SecondaryButton, TextArea } from "components/ui";
|
import { DateSelect, Input, PrimaryButton, SecondaryButton, TextArea } from "components/ui";
|
||||||
import { DateSelect } from "components/cycles";
|
|
||||||
// helpers
|
// helpers
|
||||||
import { getDateRangeStatus, isDateRangeValid } from "helpers/date-time.helper";
|
import { getDateRangeStatus, isDateRangeValid } from "helpers/date-time.helper";
|
||||||
// types
|
// types
|
||||||
|
@ -8,4 +8,3 @@ export * from "./sidebar";
|
|||||||
export * from "./single-cycle-card";
|
export * from "./single-cycle-card";
|
||||||
export * from "./empty-cycle";
|
export * from "./empty-cycle";
|
||||||
export * from "./transfer-issues-modal";
|
export * from "./transfer-issues-modal";
|
||||||
export * from "./date";
|
|
@ -7,7 +7,13 @@ import useToast from "hooks/use-toast";
|
|||||||
// components
|
// components
|
||||||
import { ModuleLeadSelect, ModuleMembersSelect, ModuleStatusSelect } from "components/modules";
|
import { ModuleLeadSelect, ModuleMembersSelect, ModuleStatusSelect } from "components/modules";
|
||||||
// ui
|
// ui
|
||||||
import { CustomDatePicker, Input, PrimaryButton, SecondaryButton, TextArea } from "components/ui";
|
import {
|
||||||
|
DateSelect,
|
||||||
|
Input,
|
||||||
|
PrimaryButton,
|
||||||
|
SecondaryButton,
|
||||||
|
TextArea,
|
||||||
|
} from "components/ui";
|
||||||
// helper
|
// helper
|
||||||
import { isDateRangeValid } from "helpers/date-time.helper";
|
import { isDateRangeValid } from "helpers/date-time.helper";
|
||||||
// types
|
// types
|
||||||
@ -67,18 +73,19 @@ export const ModuleForm: React.FC<Props> = ({ handleFormSubmit, handleClose, sta
|
|||||||
<div>
|
<div>
|
||||||
<Input
|
<Input
|
||||||
id="name"
|
id="name"
|
||||||
label="Name"
|
|
||||||
name="name"
|
name="name"
|
||||||
type="name"
|
type="name"
|
||||||
placeholder="Enter name"
|
placeholder="Title"
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
|
mode="transparent"
|
||||||
|
className="resize-none text-xl"
|
||||||
error={errors.name}
|
error={errors.name}
|
||||||
register={register}
|
register={register}
|
||||||
validations={{
|
validations={{
|
||||||
required: "Name is required",
|
required: "Title is required",
|
||||||
maxLength: {
|
maxLength: {
|
||||||
value: 255,
|
value: 255,
|
||||||
message: "Name should be less than 255 characters",
|
message: "Title should be less than 255 characters",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@ -87,75 +94,64 @@ export const ModuleForm: React.FC<Props> = ({ handleFormSubmit, handleClose, sta
|
|||||||
<TextArea
|
<TextArea
|
||||||
id="description"
|
id="description"
|
||||||
name="description"
|
name="description"
|
||||||
label="Description"
|
placeholder="Description"
|
||||||
placeholder="Enter description"
|
className="h-32 resize-none text-sm"
|
||||||
|
mode="transparent"
|
||||||
error={errors.description}
|
error={errors.description}
|
||||||
register={register}
|
register={register}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-x-2">
|
|
||||||
<div className="w-full">
|
|
||||||
<h6 className="text-gray-500">Start Date</h6>
|
|
||||||
<div className="w-full">
|
|
||||||
<Controller
|
|
||||||
control={control}
|
|
||||||
name="start_date"
|
|
||||||
render={({ field: { value, onChange } }) => (
|
|
||||||
<CustomDatePicker
|
|
||||||
renderAs="input"
|
|
||||||
value={value}
|
|
||||||
onChange={(val) => {
|
|
||||||
onChange(val);
|
|
||||||
if (val && watch("target_date")) {
|
|
||||||
if (isDateRangeValid(val, `${watch("target_date")}`)) {
|
|
||||||
setIsDateValid(true);
|
|
||||||
} else {
|
|
||||||
setIsDateValid(false);
|
|
||||||
setToastAlert({
|
|
||||||
type: "error",
|
|
||||||
title: "Error!",
|
|
||||||
message: "You have enter invalid date.",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="w-full">
|
|
||||||
<h6 className="text-gray-500">Target Date</h6>
|
|
||||||
<div className="w-full">
|
|
||||||
<Controller
|
|
||||||
control={control}
|
|
||||||
name="target_date"
|
|
||||||
render={({ field: { value, onChange } }) => (
|
|
||||||
<CustomDatePicker
|
|
||||||
renderAs="input"
|
|
||||||
value={value}
|
|
||||||
onChange={(val) => {
|
|
||||||
onChange(val);
|
|
||||||
if (watch("start_date") && val) {
|
|
||||||
if (isDateRangeValid(`${watch("start_date")}`, val)) {
|
|
||||||
setIsDateValid(true);
|
|
||||||
} else {
|
|
||||||
setIsDateValid(false);
|
|
||||||
setToastAlert({
|
|
||||||
type: "error",
|
|
||||||
title: "Error!",
|
|
||||||
message: "You have enter invalid date.",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="start_date"
|
||||||
|
render={({ field: { value, onChange } }) => (
|
||||||
|
<DateSelect
|
||||||
|
label="Start date"
|
||||||
|
value={value}
|
||||||
|
onChange={(val) => {
|
||||||
|
onChange(val);
|
||||||
|
if (val && watch("target_date")) {
|
||||||
|
if (isDateRangeValid(val, `${watch("target_date")}`)) {
|
||||||
|
setIsDateValid(true);
|
||||||
|
} else {
|
||||||
|
setIsDateValid(false);
|
||||||
|
setToastAlert({
|
||||||
|
type: "error",
|
||||||
|
title: "Error!",
|
||||||
|
message: "You have enter invalid date.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="target_date"
|
||||||
|
render={({ field: { value, onChange } }) => (
|
||||||
|
<DateSelect
|
||||||
|
label="Target date"
|
||||||
|
value={value}
|
||||||
|
onChange={(val) => {
|
||||||
|
onChange(val);
|
||||||
|
if (watch("start_date") && val) {
|
||||||
|
if (isDateRangeValid(`${watch("start_date")}`, val)) {
|
||||||
|
setIsDateValid(true);
|
||||||
|
} else {
|
||||||
|
setIsDateValid(false);
|
||||||
|
setToastAlert({
|
||||||
|
type: "error",
|
||||||
|
title: "Error!",
|
||||||
|
message: "You have enter invalid date.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<ModuleStatusSelect control={control} error={errors.status} />
|
<ModuleStatusSelect control={control} error={errors.status} />
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
@ -174,7 +170,7 @@ export const ModuleForm: React.FC<Props> = ({ handleFormSubmit, handleClose, sta
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-5 flex justify-end gap-2">
|
<div className="-mx-5 mt-5 flex justify-end gap-2 border-t px-5 pt-5">
|
||||||
<SecondaryButton onClick={handleClose}>Cancel</SecondaryButton>
|
<SecondaryButton onClick={handleClose}>Cancel</SecondaryButton>
|
||||||
<PrimaryButton type="submit" loading={isSubmitting || isDateValid ? false : true}>
|
<PrimaryButton type="submit" loading={isSubmitting || isDateValid ? false : true}>
|
||||||
{status
|
{status
|
||||||
|
@ -6,6 +6,7 @@ export * from "./context-menu";
|
|||||||
export * from "./custom-menu";
|
export * from "./custom-menu";
|
||||||
export * from "./custom-search-select";
|
export * from "./custom-search-select";
|
||||||
export * from "./custom-select";
|
export * from "./custom-select";
|
||||||
|
export * from "./date";
|
||||||
export * from "./datepicker";
|
export * from "./datepicker";
|
||||||
export * from "./empty-space";
|
export * from "./empty-space";
|
||||||
export * from "./loader";
|
export * from "./loader";
|
||||||
|
Loading…
Reference in New Issue
Block a user