-
Notifications
You must be signed in to change notification settings - Fork 0
[SSF-226] Pantry Deleting & Editing Food Requests Frontend #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1a7e2ed
45119d9
16cd7c4
a738bf4
b96d71b
96f34a0
faa3232
e5462a2
f63abd0
e36c4ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { HStack } from '@chakra-ui/react'; | ||
| import { Pencil, Trash2 } from 'lucide-react'; | ||
|
|
||
| interface EditDeleteButtonProps { | ||
| onClick: () => void; | ||
| } | ||
|
|
||
| export const EditButton: React.FC<EditDeleteButtonProps> = ({ onClick }) => { | ||
| return ( | ||
| <HStack | ||
| height={6} | ||
| minWidth={6} | ||
| padding={0.5} | ||
| justify="center" | ||
| align="center" | ||
| gap={1} | ||
| borderRadius="sm" | ||
| color={'neutral.800'} | ||
| background="neutral.50" | ||
| cursor="pointer" | ||
| _hover={{ background: 'neutral.200' }} | ||
| onClick={onClick} | ||
| > | ||
| <Pencil size={14} /> | ||
| </HStack> | ||
| ); | ||
| }; | ||
|
|
||
| export const DeleteButton: React.FC<EditDeleteButtonProps> = ({ onClick }) => { | ||
| return ( | ||
| <HStack | ||
| width={6} | ||
| height={6} | ||
| minWidth={6} | ||
| padding={0.5} | ||
| justify="center" | ||
| align="center" | ||
| gap={1} | ||
| flexShrink={0} | ||
| borderRadius="sm" | ||
| color="red.hover" | ||
| background="red.200" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is supposed to be #FEE2E2. Can we make this red.subtle? |
||
| cursor="pointer" | ||
| _hover={{ background: 'red.300' }} | ||
| onClick={onClick} | ||
| > | ||
| <Trash2 size={14} /> | ||
| </HStack> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| import React from 'react'; | ||
| import { | ||
| Box, | ||
| Button, | ||
| VStack, | ||
| CloseButton, | ||
| Text, | ||
| Flex, | ||
| Dialog, | ||
| } from '@chakra-ui/react'; | ||
| import { FoodRequestSummaryDto } from 'types/types'; | ||
| import { formatDate } from '@utils/utils'; | ||
| import apiClient from '@api/apiClient'; | ||
| import { useAlert } from '../../hooks/alert'; | ||
| import { FloatingAlert } from '@components/floatingAlert'; | ||
| import { useModalBodyCleanup } from '../../hooks/modalBodyCleanup'; | ||
|
|
||
| interface DeleteRequestActionModalProps { | ||
| request: FoodRequestSummaryDto; | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| onSuccess: () => void; | ||
| } | ||
|
|
||
| const PantryDeleteRequestActionModal: React.FC< | ||
| DeleteRequestActionModalProps | ||
| > = ({ request, isOpen, onClose, onSuccess }) => { | ||
| useModalBodyCleanup(); | ||
| const [alertState, setAlertMessage] = useAlert(); | ||
|
|
||
| const onCloseRequest = async () => { | ||
| try { | ||
| await apiClient.deleteFoodRequest(request.requestId); | ||
| onClose(); | ||
| onSuccess(); | ||
| } catch { | ||
| setAlertMessage('Food request could not be deleted.'); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <Dialog.Root | ||
| open={isOpen} | ||
| size="md" | ||
| onOpenChange={(e: { open: boolean }) => { | ||
| if (!e.open) onClose(); | ||
| }} | ||
| closeOnInteractOutside | ||
| > | ||
| {alertState && ( | ||
| <FloatingAlert | ||
| key={alertState.id} | ||
| message={alertState.message} | ||
| status="error" | ||
| timeout={6000} | ||
| /> | ||
| )} | ||
| <Dialog.Backdrop /> | ||
| <Dialog.Positioner> | ||
| <Dialog.Content> | ||
| <Dialog.CloseTrigger asChild> | ||
| <CloseButton size="lg" /> | ||
| </Dialog.CloseTrigger> | ||
|
|
||
| <Dialog.Header pb={0}> | ||
| <Dialog.Title fontSize="18px" fontFamily="inter" fontWeight={600}> | ||
| Confirm Action | ||
| </Dialog.Title> | ||
| </Dialog.Header> | ||
| <Dialog.Body pb={6}> | ||
| <VStack align="stretch" gap={4}> | ||
| <Text textStyle="p2" color="gray.dark"> | ||
| Are you sure you want to delete this food request? This action | ||
| cannot be undone. | ||
| </Text> | ||
| <Box | ||
| borderWidth={1} | ||
| p={6} | ||
| borderColor={'gray.200'} | ||
| borderRadius={6} | ||
| > | ||
| <Text textStyle="p2" color="gray.dark"> | ||
| Request #{request.requestId} | ||
| </Text> | ||
| <Text color="neutral.600" textStyle="p2" fontSize={'12'}> | ||
| Submitted {formatDate(request.requestedAt)} | ||
| </Text> | ||
| </Box> | ||
| <Flex justifyContent="flex-end" gap={2.5}> | ||
| <Button | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we get a little more horizontal padding, it kinda looks squished compared to the figma. Same with the Delete button |
||
| textStyle="p2" | ||
| fontWeight={600} | ||
| color="neutral.800" | ||
| variant="outline" | ||
| width={16} | ||
| flexShrink={0} | ||
| textAlign="center" | ||
| lineHeight="28px" | ||
| onClick={onClose} | ||
| > | ||
| Cancel | ||
| </Button> | ||
| <Button | ||
| textStyle="p2" | ||
| fontWeight={600} | ||
| bg={'red.hover'} | ||
| color={'white'} | ||
| width="92px" | ||
| flexShrink={0} | ||
| textAlign="center" | ||
| lineHeight="28px" | ||
| onClick={onCloseRequest} | ||
| > | ||
| Delete | ||
| </Button> | ||
| </Flex> | ||
| </VStack> | ||
| </Dialog.Body> | ||
| </Dialog.Content> | ||
| </Dialog.Positioner> | ||
| </Dialog.Root> | ||
| ); | ||
| }; | ||
|
|
||
| export default PantryDeleteRequestActionModal; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is supposed to be F4F4F5, can we turn this into grey.subtle as well?