From 98003b863121b2931c552a61993dd170ef37cc23 Mon Sep 17 00:00:00 2001 From: Areos Chen Date: Tue, 26 Mar 2024 16:10:17 +1030 Subject: [PATCH] adjust: modal size on small screen --- src/components/CheckBox.tsx | 5 ++- src/components/modal/modalFrame.tsx | 4 +- .../modals/mJobAssign/AssignedStaff.tsx | 2 +- .../modals/mJobAssign/DateSchedule.tsx | 40 ++++++++++++++++--- .../modals/mJobAssign/SelectStaff.tsx | 2 +- .../modals/mJobAssign/mJobAssign.tsx | 3 +- src/pageComponents/modals/mOrderForm.tsx | 39 +++++++++--------- src/pageComponents/modals/mOrderPay.tsx | 2 +- .../modals/mTimeTracker/TimeBtns.tsx | 2 +- 9 files changed, 65 insertions(+), 34 deletions(-) diff --git a/src/components/CheckBox.tsx b/src/components/CheckBox.tsx index 9ebd9eb..355e8dc 100644 --- a/src/components/CheckBox.tsx +++ b/src/components/CheckBox.tsx @@ -6,10 +6,11 @@ type Tprops = ComponentPropsWithoutRef<"input"> & { }; const CheckBox: FC = (props) => { - const { onChange, checked, onClick, name, uid, ...restProps } = props; + const { onChange, checked, onClick, name, uid, className, ...restProps } = + props; return (
= ({ )} ${className}`} > {/* right top close button */} -
+
{ e.preventDefault(); @@ -99,7 +99,7 @@ const ModalFrame: FC = ({ {/* title */} { return (
{scheduledWork.length > 0 ? ( scheduledWork.map((item) => { diff --git a/src/pageComponents/modals/mJobAssign/DateSchedule.tsx b/src/pageComponents/modals/mJobAssign/DateSchedule.tsx index ecab5ad..c6de093 100644 --- a/src/pageComponents/modals/mJobAssign/DateSchedule.tsx +++ b/src/pageComponents/modals/mJobAssign/DateSchedule.tsx @@ -1,4 +1,5 @@ import type { FC } from "react"; +import { useEffect, useState } from "react"; import { DateBtn } from "@/components/btns"; import Card from "@/components/card"; import Fieldset from "@/components/form/fieldset"; @@ -11,9 +12,25 @@ import { dateFormatAU, sortWorkLogs } from "@/utils/utils"; const DateSchedule: FC = () => { const { t } = useTranslation(); const selectedDate = useJobAssignStore((state) => state.selectedDate); - const currentWorkLogs = useJobAssignStore((state) => state.currentWorkLogs); const setDate = useJobAssignStore((state) => state.setDate); + const currentWorkLogs = useJobAssignStore((state) => state.currentWorkLogs); const setWorkLogs = useJobAssignStore((state) => state.setWorkLogs); + const [isTooSmallScreen, setIsTooSmallScreen] = useState(false); + + const checkScreenWidth = () => { + setIsTooSmallScreen(window.innerWidth < 420); + }; + + useEffect(() => { + checkScreenWidth(); + // Add event listener for window resize + window.addEventListener("resize", checkScreenWidth); + + // Remove event listener on component unmount + return () => { + window.removeEventListener("resize", checkScreenWidth); + }; + }); // remove work log from the current work log list const handleDelete = (indexToRemove: number) => { @@ -22,6 +39,17 @@ const DateSchedule: FC = () => { ); }; + const InputDatePicker = () => { + return ( + setDate(new Date(e.target.value))} + value={selectedDate?.toDateString()} + placeholder="DD/MM/YYYY" // Placeholder text + /> + ); + }; + return (
{ sLegend={`text-lg`} > {/* date picker area */} -
+
{selectedDate != undefined ? ( <> @@ -53,17 +81,17 @@ const DateSchedule: FC = () => { t("modal.tips.noDateSelected") )}
- - + + {isTooSmallScreen ? : }
{/* assigned dates area */} -
+
{t("modal.tips.scheduledWork")}
- + {sortWorkLogs("dsc", currentWorkLogs).map((item, index) => { return (
diff --git a/src/pageComponents/modals/mJobAssign/SelectStaff.tsx b/src/pageComponents/modals/mJobAssign/SelectStaff.tsx index 74ae408..f07db90 100644 --- a/src/pageComponents/modals/mJobAssign/SelectStaff.tsx +++ b/src/pageComponents/modals/mJobAssign/SelectStaff.tsx @@ -62,7 +62,7 @@ const SelectStaff: FC = () => { return (
{allStaff.length ? ( allStaff.map((staff) => { diff --git a/src/pageComponents/modals/mJobAssign/mJobAssign.tsx b/src/pageComponents/modals/mJobAssign/mJobAssign.tsx index e3bb46d..3b9b33b 100644 --- a/src/pageComponents/modals/mJobAssign/mJobAssign.tsx +++ b/src/pageComponents/modals/mJobAssign/mJobAssign.tsx @@ -64,7 +64,7 @@ const MJobAssign = () => { const mainContent = (
-
+
{/* left area */}
{/* client fieldset */} @@ -106,6 +106,7 @@ const MJobAssign = () => { title={t("modal.title.jobAssign")} mode="full" mQuit={true} + className={"overflow-y-auto"} > {mainContent} diff --git a/src/pageComponents/modals/mOrderForm.tsx b/src/pageComponents/modals/mOrderForm.tsx index d856bf9..3811db9 100644 --- a/src/pageComponents/modals/mOrderForm.tsx +++ b/src/pageComponents/modals/mOrderForm.tsx @@ -700,8 +700,8 @@ const MOrderForm: FC = memo(() => { ); const mainContent = ( - -
+ +
{/* client info */}
@@ -729,23 +729,24 @@ const MOrderForm: FC = memo(() => {
{/* order services list */} -
- - {t("label.serviceList")}: - - {descContent} - {/* append btn - adding a new service */} - {appendNewService} -
-
-
- {/* btns */} - trigger()} - onClose={onClose} - navState={navigation.state} - className="" - /> +
+
+ + {t("label.serviceList")}: + + {descContent} + {/* append btn - adding a new service */} + {appendNewService} +
+ {/* btns */} + trigger()} + onClose={onClose} + navState={navigation.state} + /> +
+
+
); diff --git a/src/pageComponents/modals/mOrderPay.tsx b/src/pageComponents/modals/mOrderPay.tsx index 506d460..dd00a43 100644 --- a/src/pageComponents/modals/mOrderPay.tsx +++ b/src/pageComponents/modals/mOrderPay.tsx @@ -268,7 +268,7 @@ const MOrderPay: FC = memo(() => { const mainContent = (
-
+
{/* client info */}
diff --git a/src/pageComponents/modals/mTimeTracker/TimeBtns.tsx b/src/pageComponents/modals/mTimeTracker/TimeBtns.tsx index c399f0c..e633d3f 100644 --- a/src/pageComponents/modals/mTimeTracker/TimeBtns.tsx +++ b/src/pageComponents/modals/mTimeTracker/TimeBtns.tsx @@ -48,7 +48,7 @@ const TimeBtnGroup: FC = ({ className, setOpenReset }) => { ) : ( <>