Skip to content

Commit

Permalink
Merge pull request #92 from uwblueprint/julia-cindy/tasks-modal
Browse files Browse the repository at this point in the history
Create Tasks Modal Component
  • Loading branch information
ya5er authored Jul 8, 2024
2 parents 9347eb3 + b257b5b commit 8796d6c
Show file tree
Hide file tree
Showing 7 changed files with 358 additions and 60 deletions.
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"react-bootstrap": "^1.5.2",
"react-dom": "^18.2.0",
"react-google-login": "^5.2.2",
"react-icons": "^5.2.1",
"react-json-schema": "^1.2.2",
"react-jsonschema-form": "^1.8.1",
"react-router-dom": "^6.4.3",
Expand Down
86 changes: 86 additions & 0 deletions frontend/src/components/common/FormField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import React from "react";
import {
Button,
Input,
Select,

Check warning on line 5 in frontend/src/components/common/FormField.tsx

View workflow job for this annotation

GitHub Actions / run-lint

'Select' is defined but never used
Flex,
FormControl,
FormLabel,
InputRightElement,
InputGroup,
InputLeftElement,
Checkbox,

Check warning on line 12 in frontend/src/components/common/FormField.tsx

View workflow job for this annotation

GitHub Actions / run-lint

'Checkbox' is defined but never used
Container,

Check warning on line 13 in frontend/src/components/common/FormField.tsx

View workflow job for this annotation

GitHub Actions / run-lint

'Container' is defined but never used
} from "@chakra-ui/react";

import VisibilityIcon from "@mui/icons-material/Visibility";
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";

const FormField = ({
label,
value,
type = "text",
onChange,
onBlur,
submitPressed,
required = false,
isPassword = false,
showPassword,
setShowPassword,
leftElement

Check warning on line 30 in frontend/src/components/common/FormField.tsx

View workflow job for this annotation

GitHub Actions / run-lint

Insert `,`
}: {
label: string;
value: string;
type?: string;
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
onBlur?: () => void;
submitPressed: boolean;
required?: boolean;
isPassword?: boolean;
showPassword?: boolean;
setShowPassword?: React.Dispatch<React.SetStateAction<boolean>>;
leftElement?: string;
}) => (
<Flex flexDir="column" flex="1">
<FormControl isRequired={required}>
<FormLabel mb="5px" color="gray.main" fontWeight="700">
{label}
</FormLabel>
<InputGroup>
{leftElement && <InputLeftElement height='34px' pointerEvents='none' color='black'>

Check warning on line 50 in frontend/src/components/common/FormField.tsx

View workflow job for this annotation

GitHub Actions / run-lint

Replace `<InputLeftElement·height='34px'·pointerEvents='none'·color='black'` with `(⏎··········<InputLeftElement·height="34px"·pointerEvents="none"·color="black"`
<Flex>{leftElement}</Flex>

Check warning on line 51 in frontend/src/components/common/FormField.tsx

View workflow job for this annotation

GitHub Actions / run-lint

Insert `··`
</InputLeftElement>}

Check warning on line 52 in frontend/src/components/common/FormField.tsx

View workflow job for this annotation

GitHub Actions / run-lint

Replace `</InputLeftElement>` with `··</InputLeftElement>⏎········)`

<Input
variant="primary"
placeholder='Enter amount'

Check warning on line 56 in frontend/src/components/common/FormField.tsx

View workflow job for this annotation

GitHub Actions / run-lint

Replace `'Enter·amount'` with `"Enter·amount"`
borderColor={submitPressed && !value ? "red.error" : "gray.300"}
boxShadow={submitPressed && !value ? "0 0 2px red.error" : "none"}
type={
isPassword && setShowPassword && !showPassword ? "password" : type
}
value={value}
onChange={onChange}
onBlur={onBlur}
/>
{isPassword && setShowPassword && (
<InputRightElement h="34px">
<Button
onClick={() => setShowPassword(!showPassword)}
bg="transparent"
_hover={{ bg: "transparent" }}
>
{!showPassword ? (
<VisibilityIcon fontSize="small" />
) : (
<VisibilityOffIcon fontSize="small" />
)}
</Button>
</InputRightElement>
)}
</InputGroup>
</FormControl>
</Flex>
);

export default FormField;
58 changes: 1 addition & 57 deletions frontend/src/components/pages/residents/ResidentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,69 +13,13 @@ import VisibilityIcon from "@mui/icons-material/Visibility";
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";

import ModalContainer from "../../common/ModalContainer";
import FormField from "../../common/FormField";

type Props = {
isOpen: boolean;
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
};

const FormField = ({
label,
value,
type = "text",
onChange,
submitPressed,
required = false,
isPassword = false,
showPassword,
setShowPassword,
}: {
label: string;
value: string;
type?: string;
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
submitPressed: boolean;
required?: boolean;
isPassword?: boolean;
showPassword?: boolean;
setShowPassword?: React.Dispatch<React.SetStateAction<boolean>>;
}) => (
<Flex flexDir="column" flex="1">
<FormControl isRequired={required}>
<FormLabel mb="5px" color="gray.main" fontWeight="700">
{label}
</FormLabel>
<InputGroup>
<Input
variant="primary"
borderColor={submitPressed && !value ? "red.error" : "gray.300"}
boxShadow={submitPressed && !value ? "0 0 2px red.error" : "none"}
type={
isPassword && setShowPassword && !showPassword ? "password" : type
}
value={value}
onChange={onChange}
/>
{isPassword && setShowPassword && (
<InputRightElement h="34px">
<Button
onClick={() => setShowPassword(!showPassword)}
bg="transparent"
_hover={{ bg: "transparent" }}
>
{!showPassword ? (
<VisibilityIcon fontSize="small" />
) : (
<VisibilityOffIcon fontSize="small" />
)}
</Button>
</InputRightElement>
)}
</InputGroup>
</FormControl>
</Flex>
);

const ResidentModal = ({ isOpen, setIsOpen }: Props): React.ReactElement => {
const [firstName, setFirstName] = useState("");
const [lastName, setLastName] = useState("");
Expand Down
Loading

0 comments on commit 8796d6c

Please sign in to comment.