Skip to content

Commit daa3695

Browse files
authored
responsive drawer and modals (#616)
* responsive drawer and modals responsive drawer and modals * lint fix
1 parent 13d6ab7 commit daa3695

File tree

19 files changed

+528
-341
lines changed

19 files changed

+528
-341
lines changed

compliance-web/src/components/App/CaseFiles/Profile/CaseFileCreateComplaint.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ComplaintDrawer from "@/components/App/Complaints/ComplaintDrawer";
2+
import useResponsiveDrawerWidth from "@/hooks/useResponsiveDrawerWidth";
23
import { CaseFile } from "@/models/CaseFile";
34
import { useDrawer } from "@/store/drawerStore";
45
import { notify } from "@/store/snackbarStore";
@@ -37,6 +38,11 @@ const CaseFileCreateComplaint = ({
3738
[caseFileData, queryClient, setClose]
3839
);
3940

41+
const drawerWidth = useResponsiveDrawerWidth(
42+
DRAWER_WIDTHS.COMPLAINT_DRAWER,
43+
{ mdToLgMax: "750px" }
44+
);
45+
4046
const handleOpenComplaintDrawer = useCallback(() => {
4147
setOpen({
4248
content: (
@@ -45,9 +51,9 @@ const CaseFileCreateComplaint = ({
4551
caseFile={caseFileData as CaseFile}
4652
/>
4753
),
48-
width: DRAWER_WIDTHS.COMPLAINT_DRAWER,
54+
width: drawerWidth,
4955
});
50-
}, [setOpen, handleOnSubmit, caseFileData]);
56+
}, [setOpen, handleOnSubmit, caseFileData, drawerWidth]);
5157

5258
return hidden ? null : (
5359
<Button

compliance-web/src/components/App/CaseFiles/Profile/CaseFileCreateInspection.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import InspectionDrawer from "@/components/App/Inspections/InspectionDrawer";
2+
import useResponsiveDrawerWidth from "@/hooks/useResponsiveDrawerWidth";
23
import { CaseFile } from "@/models/CaseFile";
34
import { useDrawer } from "@/store/drawerStore";
45
import { notify } from "@/store/snackbarStore";
@@ -37,6 +38,11 @@ const CaseFileCreateInspection = ({
3738
[queryClient, setClose, caseFileData]
3839
);
3940

41+
const drawerWidth = useResponsiveDrawerWidth(
42+
DRAWER_WIDTHS.INSPECTION_DRAWER,
43+
{ mdToLgMax: "715px" }
44+
);
45+
4046
const handleOpenInspectionDrawer = useCallback(() => {
4147
setOpen({
4248
content: (
@@ -45,9 +51,9 @@ const CaseFileCreateInspection = ({
4551
caseFile={caseFileData as CaseFile}
4652
/>
4753
),
48-
width: DRAWER_WIDTHS.INSPECTION_DRAWER,
54+
width: drawerWidth,
4955
});
50-
}, [setOpen, handleOnSubmit, caseFileData]);
56+
}, [setOpen, handleOnSubmit, caseFileData, drawerWidth]);
5157

5258
return hidden ? null : (
5359
<Button

compliance-web/src/components/App/Complaints/ComplaintDrawer.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { yupResolver } from "@hookform/resolvers/yup";
2-
import { Box, Stack } from "@mui/material";
2+
import { Box } from "@mui/material";
33
import { FormProvider, useForm } from "react-hook-form";
44
import ComplaintFormLeft from "./ComplaintFormLeft";
55
import DrawerTitleBar from "@/components/Shared/Drawer/DrawerTitleBar";
@@ -31,6 +31,7 @@ import DrawerActionBarTop from "@/components/Shared/Drawer/DrawerActionBarTop";
3131
import DrawerActionBarBottom from "@/components/Shared/Drawer/DrawerActionBarBottom";
3232
import { CaseFile } from "@/models/CaseFile";
3333
import { useCurrentLoggedInUser } from "@/hooks/useAuthorization";
34+
import { MQ } from "@/styles/responsive";
3435

3536
type ComplaintDrawerProps = {
3637
onSubmit: (submitMsg: string) => void;
@@ -179,9 +180,16 @@ const ComplaintDrawer: React.FC<ComplaintDrawerProps> = ({
179180
isShowActionBar={!complaint}
180181
isLoading={isCreateComplaintPending}
181182
/>
182-
<Stack
183+
<Box
183184
height={`calc(100vh - ${appHeaderHeight + 129}px)`} // 64px (DrawerTitleBar height) + 65px (DrawerActionBar height)
184-
direction="row"
185+
sx={{
186+
display: "flex",
187+
flexDirection: "row",
188+
[MQ.mdToLg]: {
189+
flexDirection: "column",
190+
overflow: "auto",
191+
}
192+
}}
185193
>
186194
<ComplaintFormLeft
187195
staffUsersList={staffUserList ?? []}
@@ -195,6 +203,11 @@ const ComplaintDrawer: React.FC<ComplaintDrawerProps> = ({
195203
width: "399px",
196204
boxSizing: "border-box",
197205
overflow: "auto",
206+
[MQ.mdToLg]: {
207+
width: "auto",
208+
overflow: "unset",
209+
ml: 2
210+
}
198211
}}
199212
>
200213
<ComplaintSourceForm
@@ -203,7 +216,7 @@ const ComplaintDrawer: React.FC<ComplaintDrawerProps> = ({
203216
firstNationsList={firstNationsList ?? []}
204217
/>
205218
</Box>
206-
</Stack>
219+
</Box>
207220
<DrawerActionBarBottom
208221
isShowActionBar={!!complaint}
209222
isLoading={isUpdateComplaintPending}

compliance-web/src/components/App/Complaints/ComplaintFormLeft.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import RequirementSourceForm from "./RequirementSourceForm";
1010
import { RequirementSource } from "@/models/RequirementSource";
1111

1212
import { Complaint } from "@/models/Complaint";
13+
import { MQ } from "@/styles/responsive";
1314

1415
type ComplaintFormLeftProps = {
1516
staffUsersList: StaffUser[];
@@ -35,6 +36,11 @@ const ComplaintFormLeft: FC<ComplaintFormLeftProps> = ({
3536
width: "718px",
3637
overflow: "auto",
3738
boxSizing: "border-box",
39+
[MQ.mdToLg]: {
40+
width: "auto",
41+
overflow: "unset",
42+
pr: 4,
43+
}
3844
}}
3945
>
4046
<ControlledTextField

compliance-web/src/components/App/Inspections/InspectionDrawer.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { Inspection, InspectionFormData } from "@/models/Inspection";
1818
import { StaffUser } from "@/models/Staff";
1919
import { useMenuStore } from "@/store/menuStore";
2020
import { yupResolver } from "@hookform/resolvers/yup";
21-
import { Stack } from "@mui/material";
21+
import { Box } from "@mui/material";
2222
import dayjs from "dayjs";
2323
import { useCallback, useMemo } from "react";
2424
import { FormProvider, useForm } from "react-hook-form";
@@ -32,6 +32,7 @@ import {
3232
} from "./InspectionFormUtils";
3333
import { Agency } from "@/models/Agency";
3434
import { FirstNation } from "@/models/FirstNation";
35+
import { MQ } from "@/styles/responsive";
3536

3637
type InspectionDrawerProps = {
3738
onSubmit: (submitMsg: string) => void;
@@ -213,9 +214,16 @@ const InspectionDrawer: React.FC<InspectionDrawerProps> = ({
213214
isShowActionBar={!inspection}
214215
isLoading={isCreateInspectionPending}
215216
/>
216-
<Stack
217+
<Box
217218
height={`calc(100vh - ${appHeaderHeight + 129}px)`} // 64px (DrawerTitleBar height) + 65px (DrawerActionBar height)
218-
direction={"row"}
219+
sx={{
220+
display: "flex",
221+
flexDirection: "row",
222+
[MQ.mdToLg]: {
223+
flexDirection: "column",
224+
overflow: "auto",
225+
}
226+
}}
219227
>
220228
<InspectionFormLeft
221229
initiationList={initiationList ?? []}
@@ -229,7 +237,7 @@ const InspectionDrawer: React.FC<InspectionDrawerProps> = ({
229237
firstNationsList={firstNationsList ?? []}
230238
staffList={inattendanceOfficersList ?? []}
231239
/>
232-
</Stack>
240+
</Box>
233241
<DrawerActionBarBottom
234242
isShowActionBar={!!inspection}
235243
isLoading={isUpdateInspectionPending}

compliance-web/src/components/App/Inspections/InspectionFormLeft.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Initiation } from "@/models/Initiation";
66
import { IRType } from "@/models/IRType";
77
import { ProjectStatus } from "@/models/ProjectStatus";
88
import { StaffUser } from "@/models/Staff";
9+
import { MQ } from "@/styles/responsive";
910
import { Box, Stack } from "@mui/material";
1011
import { BCDesignTokens } from "epic.theme";
1112
import { FC } from "react";
@@ -37,6 +38,11 @@ const InspectionFormLeft: FC<InspectionFormLeftProps> = ({
3738
width: "718px",
3839
overflow: "auto",
3940
boxSizing: "border-box",
41+
[MQ.mdToLg]: {
42+
width: "auto",
43+
overflow: "unset",
44+
pr: 4,
45+
}
4046
}}
4147
>
4248
<ControlledSwitch

compliance-web/src/components/App/Inspections/InspectionFormRight.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { FC, useEffect } from "react";
1616
import { useFormContext, useWatch } from "react-hook-form";
1717
import { AttendanceEnum } from "@/utils/constants";
1818
import ControlledCheckbox from "@/components/Shared/Controlled/ControlledCheckbox";
19+
import { MQ } from "@/styles/responsive";
1920

2021
type InspectionFormRightProps = {
2122
attendanceList: Attendance[];
@@ -141,6 +142,11 @@ const InspectionFormRight: FC<InspectionFormRightProps> = ({
141142
width: "399px",
142143
boxSizing: "border-box",
143144
overflow: "auto",
145+
[MQ.mdToLg]: {
146+
width: "auto",
147+
overflow: "unset",
148+
ml: 2
149+
}
144150
}}
145151
>
146152
<Stack>

compliance-web/src/components/App/Inspections/Profile/InspectionRequirements.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { DRAWER_WIDTHS } from "@/utils/constants";
2626
import { useRequirementStore } from "./Requirements/requirementStore";
2727
import RequirementLoading from "./Requirements/RequirementLoading";
2828
import DynamicHeightBox from "@/components/Shared/DynamicHeightBox";
29+
import useResponsiveDrawerWidth from "@/hooks/useResponsiveDrawerWidth";
2930

3031
interface InspectionRequirementsProps {
3132
inspectionData: Inspection;
@@ -138,6 +139,11 @@ const InspectionRequirements: React.FC<InspectionRequirementsProps> = ({
138139
[queryClient, inspectionData, setClose]
139140
);
140141

142+
const drawerWidth = useResponsiveDrawerWidth(
143+
DRAWER_WIDTHS.REQUIREMENT_DRAWER,
144+
{ mdToLgMax: "750px" }
145+
);
146+
141147
const handleOpenAddRequirementModal = useCallback(() => {
142148
setOpen({
143149
content: (
@@ -146,9 +152,9 @@ const InspectionRequirements: React.FC<InspectionRequirementsProps> = ({
146152
inspectionData={inspectionData}
147153
/>
148154
),
149-
width: DRAWER_WIDTHS.REQUIREMENT_DRAWER,
155+
width: drawerWidth,
150156
});
151-
}, [setOpen, handleOnSubmit, inspectionData]);
157+
}, [setOpen, handleOnSubmit, inspectionData, drawerWidth]);
152158

153159
const handleOpenAddRegulatoryConsiderationModal = useCallback(() => {
154160
setOpen({
@@ -159,9 +165,9 @@ const InspectionRequirements: React.FC<InspectionRequirementsProps> = ({
159165
isRegulatoryConsideration={true}
160166
/>
161167
),
162-
width: DRAWER_WIDTHS.REQUIREMENT_DRAWER,
168+
width: drawerWidth,
163169
});
164-
}, [setOpen, handleOnSubmit, inspectionData]);
170+
}, [setOpen, handleOnSubmit, inspectionData, drawerWidth]);
165171

166172
const handleOpenEditRequirementDrawer = useCallback(
167173
(
@@ -180,10 +186,10 @@ const InspectionRequirements: React.FC<InspectionRequirementsProps> = ({
180186
isRegulatoryConsideration={isRegulatoryConsideration}
181187
/>
182188
),
183-
width: DRAWER_WIDTHS.REQUIREMENT_DRAWER,
189+
width: drawerWidth,
184190
});
185191
},
186-
[setOpen, handleOnSubmit, inspectionData]
192+
[setOpen, handleOnSubmit, inspectionData, drawerWidth]
187193
);
188194

189195
// Add a ref to store the timeout ID : to prevent multiple API calls during reordering

compliance-web/src/components/App/Inspections/Profile/Reports/ReportTabContents/IROverview/Overview.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { notify } from "@/store/snackbarStore";
1616
import { useQueryClient } from "@tanstack/react-query";
1717
import { formatInAttendance } from "@/components/App/Inspections/InspectionFormUtils";
1818
import { renderStaffNameWithPosition } from "@/utils/appUtils";
19+
import useResponsiveDrawerWidth from "@/hooks/useResponsiveDrawerWidth";
1920

2021
const Overview = () => {
2122
const { inspectionData, caseFileData, isReportsReadOnly } = useReportStore();
@@ -62,6 +63,11 @@ const Overview = () => {
6263
[queryClient, inspectionData, setClose]
6364
);
6465

66+
const drawerWidth = useResponsiveDrawerWidth(
67+
DRAWER_WIDTHS.INSPECTION_DRAWER,
68+
{ mdToLgMax: "715px" }
69+
);
70+
6571
const handleOpenEditModal = useCallback(() => {
6672
setOpen({
6773
content: (
@@ -71,9 +77,9 @@ const Overview = () => {
7177
caseFile={caseFileData as CaseFile}
7278
/>
7379
),
74-
width: DRAWER_WIDTHS.INSPECTION_DRAWER,
80+
width: drawerWidth,
7581
});
76-
}, [setOpen, handleOnSubmit, inspectionData, caseFileData]);
82+
}, [setOpen, handleOnSubmit, inspectionData, caseFileData, drawerWidth]);
7783

7884
return (
7985
<>

compliance-web/src/components/App/Inspections/Profile/Reports/ReportTabContents/IRRegulatoryConsideration.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { InspectionRequirement } from "@/models/InspectionRequirement";
1313
import { REGULATORY_CONSIDERATION_TYPE_ID } from "@/components/App/Inspections/Profile/Requirements/RequirementUtils";
1414
import { RequirementImage } from "@/models/Image";
1515
import IRImageSection from "./IRImageSection";
16+
import useResponsiveDrawerWidth from "@/hooks/useResponsiveDrawerWidth";
1617

1718
const IRRegulatoryConsideration = () => {
1819
const { inspectionData, isReportsReadOnly } = useReportStore();
@@ -60,6 +61,11 @@ const IRRegulatoryConsideration = () => {
6061
[setClose, inspectionData, queryClient]
6162
);
6263

64+
const drawerWidth = useResponsiveDrawerWidth(
65+
DRAWER_WIDTHS.REQUIREMENT_DRAWER,
66+
{ mdToLgMax: "750px" }
67+
);
68+
6369
const handleOpenEditRequirementModal = useCallback(() => {
6470
setOpen({
6571
content: (
@@ -70,13 +76,14 @@ const IRRegulatoryConsideration = () => {
7076
isRegulatoryConsideration={true}
7177
/>
7278
),
73-
width: DRAWER_WIDTHS.REQUIREMENT_DRAWER,
79+
width: drawerWidth,
7480
});
7581
}, [
7682
setOpen,
7783
handleOnSubmit,
7884
inspectionData,
7985
inspectionRegulatoryConsideration,
86+
drawerWidth,
8087
]);
8188

8289
return (

0 commit comments

Comments
 (0)