Skip to content

Commit

Permalink
use and move specialfield lock component
Browse files Browse the repository at this point in the history
  • Loading branch information
jadmsaadaot committed Dec 21, 2023
1 parent 5f897e9 commit 7b897ad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { ETFormLabel } from "../../shared";
import { ETFormLabel } from "../..";
import { IconButton, Stack } from "@mui/material";
import icons from "../../icons";
import { IconProps } from "../../icons/type";
import { Palette } from "../../../styles/theme";
import icons from "../../../icons";
import { IconProps } from "../../../icons/type";
import { Palette } from "../../../../styles/theme";

interface SpecialFieldLockProps {
id: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ETCaption3 } from "../../shared";
import { Grid } from "@mui/material";
import { When } from "react-if";
import { Staff } from "../../../models/staff";
import { SpecialFieldLock } from "./SpecialFieldLock";
import { SpecialFieldLock } from "../../shared/specialField/components/SpecialFieldLock";

interface EPDSpecialFieldProps {
id: number;
Expand Down Expand Up @@ -40,7 +40,7 @@ export const EPDSpecialField = ({
id={id}
open={open}
onLockClick={onLockClick}
label={"Work Lead"}
label={"Responsible EPD"}
required
/>
{children}
Expand Down
39 changes: 10 additions & 29 deletions epictrack-web/src/components/work/WorkForm/WorkLeadSpecialField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import {
SPECIAL_FIELDS,
SpecialFieldEntityEnum,
} from "../../../constants/application-constant";
import { ETCaption3, ETFormLabel } from "../../shared";
import { Box, Grid, IconButton } from "@mui/material";
import icons from "../../icons";
import { IconProps } from "../../icons/type";
import { Palette } from "../../../styles/theme";
import { ETCaption3 } from "../../shared";
import { Grid } from "@mui/material";
import { When } from "react-if";
import { Staff } from "../../../models/staff";
import { SpecialFieldLock } from "../../shared/specialField/components/SpecialFieldLock";

interface WorkLeadSpecialFieldProps {
id: number;
Expand All @@ -28,9 +26,6 @@ export const WorkLeadSpecialField = ({
options,
children,
}: WorkLeadSpecialFieldProps) => {
const LockClosedIcon: React.FC<IconProps> = icons["LockClosedIcon"];
const LockOpenIcon: React.FC<IconProps> = icons["LockOpenIcon"];

const selectOptions = useMemo(() => {
return options.map((option) => ({
label: option.full_name,
Expand All @@ -41,27 +36,13 @@ export const WorkLeadSpecialField = ({
return (
<>
<Grid item xs={6}>
<Box
sx={{
display: "flex",
justifyContent: "space-between",
paddingTop: "3px",
}}
>
<ETFormLabel required>Work Lead</ETFormLabel>
<IconButton
onClick={onLockClick}
disableRipple
disabled={!id}
sx={{ padding: 0 }}
>
{open ? (
<LockOpenIcon fill={Palette.primary.accent.main} />
) : (
<LockClosedIcon fill={Palette.primary.accent.main} />
)}
</IconButton>
</Box>
<SpecialFieldLock
id={id}
open={open}
onLockClick={onLockClick}
label={"Work Lead"}
required
/>
{children}
</Grid>
<When condition={open}>
Expand Down

0 comments on commit 7b897ad

Please sign in to comment.