From 4d56adba43c52575d90c8e69920afc2f462e4c77 Mon Sep 17 00:00:00 2001 From: Saheb Giri <47132373+iamsahebgiri@users.noreply.github.com> Date: Thu, 30 Mar 2023 18:35:29 +0530 Subject: [PATCH] style: create cycle modal makeover (#617) --- apps/app/components/cycles/date.tsx | 71 ++++++++++++++ apps/app/components/cycles/form.tsx | 141 +++++++++++++--------------- apps/app/components/cycles/index.ts | 1 + 3 files changed, 137 insertions(+), 76 deletions(-) create mode 100644 apps/app/components/cycles/date.tsx diff --git a/apps/app/components/cycles/date.tsx b/apps/app/components/cycles/date.tsx new file mode 100644 index 0000000000..4325f5a42b --- /dev/null +++ b/apps/app/components/cycles/date.tsx @@ -0,0 +1,71 @@ +import React from "react"; + +import { Popover, Transition } from "@headlessui/react"; +import { CalendarDaysIcon, XMarkIcon } from "@heroicons/react/24/outline"; +// react-datepicker +import DatePicker from "react-datepicker"; +// import "react-datepicker/dist/react-datepicker.css"; +import { renderDateFormat } from "helpers/date-time.helper"; + +type Props = { + value: string | null; + onChange: (val: string | null) => void; + label: string; +}; + +export const DateSelect: React.FC = ({ value, onChange, label }) => ( + + {({ open }) => ( + <> + + `flex cursor-pointer items-center rounded-md border text-xs shadow-sm duration-200 + ${ + open + ? "border-theme bg-theme/5 outline-none ring-1 ring-theme " + : "hover:bg-theme/5 " + }` + } + > + + {value ? ( + <> + {value} + + + ) : ( + <> + + {label} + + )} + + + + + + { + if (!val) onChange(""); + else onChange(renderDateFormat(val)); + }} + dateFormat="dd-MM-yyyy" + inline + /> + + + + )} + +); diff --git a/apps/app/components/cycles/form.tsx b/apps/app/components/cycles/form.tsx index 9bff6f4398..fa244d3488 100644 --- a/apps/app/components/cycles/form.tsx +++ b/apps/app/components/cycles/form.tsx @@ -9,7 +9,8 @@ import cyclesService from "services/cycles.service"; // hooks import useToast from "hooks/use-toast"; // ui -import { CustomDatePicker, Input, PrimaryButton, SecondaryButton, TextArea } from "components/ui"; +import { Input, PrimaryButton, SecondaryButton, TextArea } from "components/ui"; +import { DateSelect } from "components/cycles"; // helpers import { getDateRangeStatus, isDateRangeValid } from "helpers/date-time.helper"; // types @@ -100,12 +101,13 @@ export const CycleForm: React.FC = ({ handleFormSubmit, handleClose, stat
= ({ handleFormSubmit, handleClose, stat