-
Notifications
You must be signed in to change notification settings - Fork 0
58 mock ups of view timesheet changes admin #59
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
Draft
izzyconner
wants to merge
8
commits into
main
Choose a base branch
from
58-mock-ups-of-view-timesheet-changes-admin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
30e6514
Beginning to setup components for the conflictable time entry cell
izzyconner 6f6bdfe
Adding in some beginnings to the popup and conflict time entry
izzyconner dd581a4
Starting to fix up the conflictable time entry, changing time entry c…
izzyconner d3d0a5d
Fixed the bug where the time picker wasn't getting updated
izzyconner 99f3521
starting to work on conflict modal
izzyconner 1363687
Adding in complete-ish modal and functional buttons to select associa…
izzyconner c9e335f
Adding in flexibility for user types
izzyconner 3b4fc8c
fixing up bug where no times would be shown initially
izzyconner 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
155 changes: 155 additions & 0 deletions
155
src/components/TimeCardPage/CellTypes/ConflictableTimeEntry.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,155 @@ | ||
| import React, { useEffect, useState } from "react"; | ||
| import { RowSchema, TimeRowEntry } from "../../../schemas/RowSchema"; | ||
| import { TimeEntry } from "./TimeEntry"; | ||
| import { | ||
| Button, | ||
| Modal, | ||
| ModalOverlay, | ||
| ModalContent, | ||
| ModalHeader, | ||
| ModalFooter, | ||
| ModalBody, | ||
| ModalCloseButton, | ||
| Editable, | ||
| EditablePreview, | ||
| EditableInput, | ||
| Input, | ||
| Box, | ||
| ButtonGroup, | ||
| Flex, | ||
| useDisclosure, | ||
| useEditableControls, | ||
| StackDivider, | ||
| HStack, | ||
| VStack, | ||
| Text, | ||
| IconButton | ||
| } from "@chakra-ui/react"; | ||
|
|
||
| import { | ||
| ChatIcon, | ||
| CheckIcon, | ||
| CloseIcon, | ||
| EditIcon, | ||
| AddIcon, | ||
| DeleteIcon, | ||
| WarningIcon | ||
| } from "@chakra-ui/icons"; | ||
|
|
||
|
|
||
|
|
||
| interface ConflicatableTimeEntryProps { | ||
| field: string; | ||
| row: RowSchema; | ||
| updateFields: Function; | ||
| } | ||
|
|
||
| /** | ||
| * This represents a time entry cell that accounts for multiple time entries (i.e. an associate's and a supervisor's entries) | ||
| * and allows for conflicts to be shown. | ||
| */ | ||
| export function ConflicatableTimeEntry(props: ConflicatableTimeEntryProps) { | ||
| const [selectedTime, setSelectedTime] = useState(null); | ||
|
|
||
| const handleTimeSelection = (time: number) => { | ||
| setSelectedTime(time); | ||
| }; | ||
|
|
||
| // determine if the associate and supervisor times are conflicting for this cell | ||
| const hasAssociateTime: boolean = props.row.Associate !== undefined; | ||
| const hasSupervisorTime: boolean = props.row.Supervisor !== undefined; | ||
| const hasAdminTime: boolean = props.row.Admin !== undefined; | ||
|
|
||
| // TODO : | ||
| // -- only show conflict button on conflict | ||
| // -- auto-populate with the following rules: | ||
| // ---- if associate and supervisor times are the same, auto-populate with that time | ||
| // ---- if associate and supervisor times are different, auto-populate with null | ||
| // -- make sure that time conflict entry cells only show up on admins | ||
|
|
||
| // Conflicts are defined as: | ||
| // 1. associate submitted a time, and supervisor did not | ||
| // 2. Supervisor submitted a time for this entry, and associate did not | ||
| // 3. Associate time and supervisor reported time differ | ||
| var hasConflict = hasAssociateTime !== hasSupervisorTime || | ||
|
Contributor
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. possible issue of associate has time and supervisor doesnt which shouldn't lead to a conflict |
||
| (hasAssociateTime && hasSupervisorTime && props.row.Associate[props.field] !== props.row.Supervisor[props.field]); | ||
|
|
||
| useEffect(() => { | ||
| if (!hasConflict && hasAssociateTime && !hasAdminTime) { | ||
| setSelectedTime(props.row.Associate[props.field]) | ||
| } else if (hasAdminTime) { | ||
| setSelectedTime(props.row.Admin[props.field]) | ||
| } | ||
| }, []); | ||
|
|
||
| // TODO: Toggle clicker to display popup with conflict only if hasConflict is true | ||
| return ( | ||
| <> | ||
| { hasConflict && (<TimeConflictPopup | ||
| field={props.field} | ||
| associateEntry={props.row.Associate} | ||
| supervisorEntry={props.row.Supervisor} | ||
| onSelectTime={handleTimeSelection} | ||
| /> ) } | ||
| <TimeEntry | ||
| field={props.field} | ||
| row={props.row} | ||
| updateFields={props.updateFields} | ||
| userType="Admin" | ||
| time={selectedTime} | ||
| /> | ||
| </> | ||
| ); | ||
|
|
||
| // TODO: make sure to update props field appropriately to trigger the correct autosaving | ||
| } | ||
|
|
||
| interface TimeConflictPopupProps { | ||
| field: string; | ||
| associateEntry: TimeRowEntry; | ||
| supervisorEntry: TimeRowEntry; | ||
| onSelectTime: Function; | ||
| } | ||
|
|
||
| export function TimeConflictPopup(props: TimeConflictPopupProps) { | ||
| const { isOpen, onOpen, onClose } = useDisclosure(); | ||
|
|
||
| const hasAssociateTime: boolean = props.associateEntry !== undefined && props.associateEntry !== null; | ||
|
Contributor
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. undefined instead? |
||
| const hasSupervisorTime: boolean = props.supervisorEntry !== undefined && props.supervisorEntry !== null; | ||
|
|
||
| const associateTime: number = hasAssociateTime ? props.associateEntry[props.field] : null; | ||
| const supervisorTime: number = hasSupervisorTime ? props.supervisorEntry[props.field] : null; | ||
|
|
||
| const convertMinutesToTime = (minutes) => { | ||
| const hours = Math.round(minutes / 60) | ||
| const mins = minutes % 60; | ||
| return hours + ":" + mins; | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <IconButton aria-label='Conflict' icon={<WarningIcon />} onClick={onOpen}></IconButton> | ||
| <Modal isOpen={isOpen} onClose={onClose}> | ||
| <ModalOverlay /> | ||
| <ModalContent> | ||
| <ModalHeader> | ||
| <HStack> | ||
| <Text>Time Conflict</Text> | ||
| </HStack> | ||
| </ModalHeader> | ||
| <ModalCloseButton /> | ||
| <ModalBody> | ||
| <Text>These are the entries submitted:</Text> | ||
| <HStack> | ||
| <Button onClick={() => { props.onSelectTime(associateTime); onClose(); }}>Use Associate Time</Button> | ||
| <Button onClick={() => { props.onSelectTime(supervisorTime); onClose();} }>Use Supervisor Time</Button> | ||
| </HStack> | ||
| <Text>Associate Time: {hasAssociateTime ? convertMinutesToTime(props.associateEntry[props.field]) : "none"}</Text> | ||
| <Text>Supervisor Time: {hasSupervisorTime ? convertMinutesToTime(props.supervisorEntry[props.field]) : "none"}</Text> | ||
| </ModalBody> | ||
| <ModalFooter> | ||
| </ModalFooter> | ||
| </ModalContent> | ||
| </Modal> | ||
| </>) | ||
| } | ||
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
Empty file.
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
Empty file.
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.
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.
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.
why not undefined?