-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
241 additions
and
74 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
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
client/pages/Admin/MissingSubmissions/MissingSubmissions.module.scss
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
client/pages/Admin/MissingSubmissions/MissingSubmissions.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
.list { | ||
margin: 0; | ||
|
||
.actions { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: row; | ||
gap: 10px; | ||
} | ||
} |
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 @@ | ||
export * from './List' |
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
client/pages/Admin/WeekStatus/LockWeekButton/LockWeekButton.module.scss
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,3 @@ | ||
.lockWeekButton { | ||
margin: 15px 0; | ||
} |
22 changes: 22 additions & 0 deletions
22
client/pages/Admin/WeekStatus/LockWeekButton/LockWeekButton.tsx
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,22 @@ | ||
import { Button } from '@fluentui/react-components' | ||
import React from 'react' | ||
import { StyledComponent } from 'types' | ||
import styles from './LockWeekButton.module.scss' | ||
import { ILockWeekButtonProps } from './types' | ||
import { useLockWeekButton } from './useLockWeekButton' | ||
|
||
export const LockWeekButton: StyledComponent<ILockWeekButtonProps> = ( | ||
props | ||
) => { | ||
const { text, icon, onClick } = useLockWeekButton(props) | ||
return ( | ||
<div className={LockWeekButton.className}> | ||
<Button appearance='subtle' icon={icon} onClick={onClick}> | ||
{text} | ||
</Button> | ||
</div> | ||
) | ||
} | ||
|
||
LockWeekButton.displayName = 'LockWeekButton' | ||
LockWeekButton.className = styles.lockWeekButton |
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 @@ | ||
export * from './LockWeekButton' |
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,5 @@ | ||
mutation LockPeriod ($periodId: String!, $unlock: Boolean) { | ||
result: lockPeriod(periodId: $periodId, unlock: $unlock) { | ||
success | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
client/pages/Admin/WeekStatus/LockWeekButton/locked-periods.gql
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,5 @@ | ||
query LockedPeriods { | ||
subscription { | ||
lockedPeriods | ||
} | ||
} |
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,6 @@ | ||
import { IButtonProps } from '@fluentui/react' | ||
import { IMissingSubmissionPeriod } from '../types' | ||
|
||
export interface ILockWeekButtonProps extends IButtonProps { | ||
period: IMissingSubmissionPeriod | ||
} |
52 changes: 52 additions & 0 deletions
52
client/pages/Admin/WeekStatus/LockWeekButton/useLockWeekButton.ts
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,52 @@ | ||
import { useTranslation } from 'react-i18next' | ||
import { useBoolean } from 'usehooks-ts' | ||
import { getFluentIcon } from 'utils/getFluentIcon' | ||
import { ILockWeekButtonProps } from './types' | ||
import $lockedPeriods from './locked-periods.gql' | ||
import $lockPeriod from './lock-period.gql' | ||
import { useMutation, useQuery } from '@apollo/client' | ||
import { Subscription } from 'types' | ||
import { useEffect } from 'react' | ||
|
||
/** | ||
* Component logic hook for the `LockWeekButton` component. Handles | ||
* fetching of locked periods and locking/unlocking of periods. | ||
* Returns the text, icon and click handler for the button. | ||
* | ||
* @param props Props for the `LockWeekButton` component. | ||
*/ | ||
export function useLockWeekButton(props: ILockWeekButtonProps) { | ||
const { t } = useTranslation() | ||
const { data } = useQuery<{ subscription: Subscription }>($lockedPeriods, { | ||
fetchPolicy: 'network-only' | ||
}) | ||
const [lockPeriod] = useMutation($lockPeriod) | ||
const isLocked = useBoolean(false) | ||
|
||
useEffect(() => { | ||
isLocked.setValue( | ||
data?.subscription?.lockedPeriods?.some( | ||
(periodId) => periodId === props.period?.id | ||
) | ||
) | ||
}, [data?.subscription?.lockedPeriods, props.period?.id]) | ||
|
||
const text = isLocked.value | ||
? t('admin.weekStatus.unlockWeekButtonText') | ||
: t('admin.weekStatus.lockWeekButtonText') | ||
const icon = getFluentIcon(isLocked.value ? 'LockOpen' : 'LockClosed') | ||
|
||
/** | ||
* Handles the click event for the button. | ||
*/ | ||
const onClick = () => { | ||
lockPeriod({ | ||
variables: { | ||
periodId: props.period?.id, | ||
unlock: isLocked.value | ||
} | ||
}) | ||
isLocked.toggle() | ||
} | ||
return { text, icon, onClick } | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
.weekStatus { | ||
margin: 0; | ||
} |
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,21 @@ | ||
import { TabComponent, Tabs } from 'components/Tabs' | ||
import React from 'react' | ||
import styles from './WeekStatus.module.scss' | ||
import { useWeekStatus } from './useWeekStatus' | ||
|
||
export const WeekStatus: TabComponent = () => { | ||
const { tabs, defaultSelectedTab } = useWeekStatus() | ||
return ( | ||
<div className={WeekStatus.className}> | ||
<Tabs | ||
items={tabs} | ||
vertical | ||
defaultSelectedValue={defaultSelectedTab} | ||
level={3} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
WeekStatus.displayName = 'WeekStatus' | ||
WeekStatus.className = styles.weekStatus |
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,2 @@ | ||
export * from './WeekStatus' | ||
export * from './types' |
File renamed without changes.
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
6 changes: 3 additions & 3 deletions
6
...Submissions/useMissingSubmissionsQuery.ts → ...es/Admin/WeekStatus/useWeekStatusQuery.ts
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
File renamed without changes.
Oops, something went wrong.