-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add kebab icon and menu * add delete confirmation component * fix id selection within map * add backend api * add success alert message * add frontend for edit component * fix api locations * add api connection to database * add default value to edit log fields * run linter * fix select dropdown states * fix some resident issues * remove extra api calls and fix reset states on close * fix table heading styles * swap menu option order * add page reload after submit * fix resident default value * fix attnTo to make it optional * fix flagged checkbox * run linters * add formatting changes and comments * change deleteLogRecord return type to boolean * add params type for editLogRecord * run linter * fix attnTo to make it optional * add date/time selection for create log * add date/time for edit log * fix note and residentId errors * refactor methods * remove extra API calls * fix handleNotesChange param type * fix async api calls --------- Co-authored-by: Connor Bechthold <[email protected]> Co-authored-by: Safewaan <[email protected]>
- Loading branch information
1 parent
c631c75
commit c9f873d
Showing
12 changed files
with
913 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React, { useState } from "react"; | ||
import { | ||
Box, | ||
Modal, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
ModalBody, | ||
ModalFooter, | ||
Button, | ||
Text, | ||
} from "@chakra-ui/react"; | ||
|
||
type Props = { | ||
itemName: string; | ||
itemId: number; | ||
isOpen: boolean; | ||
toggleClose: () => void; | ||
deleteAPI: (itemId: number) => void; | ||
}; | ||
|
||
const DeleteConfirmation = ({ | ||
itemName, | ||
itemId, | ||
isOpen, | ||
toggleClose, | ||
deleteAPI, | ||
}: Props): React.ReactElement => { | ||
const ITEM_NAME = itemName.toLowerCase(); | ||
|
||
const MESSAGE_HEADER = `Delete ${ | ||
ITEM_NAME.charAt(0).toUpperCase() + ITEM_NAME.slice(1) | ||
}`; | ||
|
||
const MESSAGE_TEXT = `Are you sure you want to delete this ${ITEM_NAME}? Deleting a \n\ | ||
${ITEM_NAME} will permanently remove it from your system.`; | ||
|
||
const handleSubmit = async () => { | ||
deleteAPI(itemId); | ||
toggleClose(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Box> | ||
<Modal isOpen={isOpen} onClose={toggleClose} size="xl"> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader>{MESSAGE_HEADER}</ModalHeader> | ||
<ModalBody> | ||
<Box marginBottom="12px"> | ||
<Text>{MESSAGE_TEXT}</Text> | ||
</Box> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button | ||
onClick={toggleClose} | ||
variant="tertiary" | ||
marginRight="8px" | ||
> | ||
Cancel | ||
</Button> | ||
<Button onClick={handleSubmit} variant="primary" type="submit"> | ||
Yes, delete | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
</Box> | ||
</> | ||
); | ||
}; | ||
|
||
export default DeleteConfirmation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.