forked from Code-4-Community/scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 0
[SSF-185] volunteer order management page #149
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
181 changes: 181 additions & 0 deletions
181
apps/frontend/src/components/forms/completeRequiredActionsModal.tsx
This file contains hidden or 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,181 @@ | ||
| import React, { useState } from 'react'; | ||
| import { | ||
| Box, | ||
| Button, | ||
| VStack, | ||
| CloseButton, | ||
| Text, | ||
| Flex, | ||
| Dialog, | ||
| } from '@chakra-ui/react'; | ||
| import { CircleCheck } from 'lucide-react'; | ||
| import ApiClient from '@api/apiClient'; | ||
| import { | ||
| VolunteerOrder, | ||
| VolunteerAction, | ||
| VolunteerActionCompletion, | ||
| } from '../../types/types'; | ||
| import { FloatingAlert } from '@components/floatingAlert'; | ||
| import { useAlert } from '../../hooks/alert'; | ||
|
|
||
| interface CompleteRequiredActionsModalProps { | ||
| order: VolunteerOrder; | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| onActionCompleted: (orderId: number, action: VolunteerAction) => void; | ||
| } | ||
|
|
||
| const CompleteRequiredActionsModal: React.FC< | ||
| CompleteRequiredActionsModalProps | ||
| > = ({ order, isOpen, onClose, onActionCompleted }) => { | ||
| const [alertState, setAlertMessage] = useAlert(); | ||
| const [loadingAction, setLoadingAction] = useState<VolunteerAction | null>( | ||
| null, | ||
| ); | ||
|
|
||
| const completion: VolunteerActionCompletion = order.actionCompletion ?? { | ||
| confirmDonationReceipt: false, | ||
| notifyPantry: false, | ||
| }; | ||
|
|
||
| const handleComplete = async (action: VolunteerAction) => { | ||
| setLoadingAction(action); | ||
| try { | ||
| await ApiClient.completeOrderAction(order.orderId, action); | ||
| onActionCompleted(order.orderId, action); | ||
| } catch { | ||
| setAlertMessage('Error completing action. Please try again.'); | ||
| } finally { | ||
| setLoadingAction(null); | ||
| } | ||
| }; | ||
|
|
||
| const sectionTitleStyles = { | ||
| fontWeight: '600', | ||
| fontSize: '14px', | ||
| color: 'neutral.800', | ||
| }; | ||
|
|
||
| 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="lg" fontWeight={600}> | ||
| Complete Required Action | ||
| </Dialog.Title> | ||
| </Dialog.Header> | ||
| <Dialog.Body pb={6}> | ||
| <VStack align="stretch" gap={4}> | ||
| <Text fontSize="sm" color="gray.dark" mt={1}> | ||
| Please complete the following outstanding actions for this | ||
| order. | ||
| </Text> | ||
| <Box> | ||
| <Box | ||
| border="1px solid" | ||
| borderColor="neutral.100" | ||
| borderRadius="md" | ||
| p={4} | ||
| > | ||
| <Flex align="center" gap={2}> | ||
| {completion.confirmDonationReceipt && ( | ||
| <CircleCheck size={18} /> | ||
| )} | ||
| <Text {...sectionTitleStyles}> | ||
| Confirm Donation Receipt | ||
| </Text> | ||
| </Flex> | ||
| <Text textStyle="p2" color="gray.dark" mt={6}> | ||
| Please contact the food pantry to confirm their donation | ||
| receipt order. | ||
| </Text> | ||
| </Box> | ||
| {!completion.confirmDonationReceipt && ( | ||
| <Flex justify="flex-end" mt={4}> | ||
| <Button | ||
| size="sm" | ||
| bg="neutral.900" | ||
| color="white" | ||
| fontSize="12px" | ||
| px={2} | ||
| h="20px" | ||
| _hover={{ bg: 'neutral.700' }} | ||
| loading={ | ||
| loadingAction === | ||
| VolunteerAction.CONFIRM_DONATION_RECEIPT | ||
| } | ||
| onClick={() => | ||
| handleComplete(VolunteerAction.CONFIRM_DONATION_RECEIPT) | ||
| } | ||
| > | ||
| Mark as Complete | ||
| </Button> | ||
| </Flex> | ||
| )} | ||
| </Box> | ||
|
|
||
| <Box> | ||
| <Box | ||
| border="1px solid" | ||
| borderColor="neutral.100" | ||
| borderRadius="md" | ||
| p={4} | ||
| > | ||
| <Flex align="center" gap={2}> | ||
| {completion.notifyPantry && <CircleCheck size={18} />} | ||
| <Text {...sectionTitleStyles}>Notify Pantry</Text> | ||
| </Flex> | ||
| <Text textStyle="p2" color="gray.dark" mt={6}> | ||
| Subheading Content | ||
| </Text> | ||
| </Box> | ||
| {!completion.notifyPantry && ( | ||
| <Flex justify="flex-end" mt={4}> | ||
| <Button | ||
| size="sm" | ||
| bg="neutral.900" | ||
| color="white" | ||
| fontSize="12px" | ||
| px={2} | ||
| h="20px" | ||
| _hover={{ bg: 'neutral.700' }} | ||
| loading={loadingAction === VolunteerAction.NOTIFY_PANTRY} | ||
| onClick={() => | ||
| handleComplete(VolunteerAction.NOTIFY_PANTRY) | ||
| } | ||
| > | ||
| Mark as Complete | ||
| </Button> | ||
| </Flex> | ||
| )} | ||
| </Box> | ||
| </VStack> | ||
| </Dialog.Body> | ||
| </Dialog.Content> | ||
| </Dialog.Positioner> | ||
| </Dialog.Root> | ||
| ); | ||
| }; | ||
|
|
||
| export default CompleteRequiredActionsModal; | ||
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.