-
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 view to mark bookings completed when in PendingBookings status (#14)
Signed-off-by: Sean Sundberg <[email protected]>
- Loading branch information
Showing
11 changed files
with
220 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
import React, {MouseEventHandler, ReactNode} from 'react'; | ||
import { Button } from '@carbon/react'; | ||
|
||
export interface EnabledButtonProps { | ||
enabled: boolean | ||
type?: 'button' | 'submit' | 'reset' | ||
size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | ||
onClick?: MouseEventHandler<HTMLButtonElement> | ||
children: ReactNode | ReactNode[] | ||
} | ||
|
||
export const EnabledButton: React.FunctionComponent<EnabledButtonProps> = ({enabled, type, size, onClick, children}: EnabledButtonProps) => { | ||
if (!enabled) { | ||
return (<></>) | ||
} | ||
|
||
return (<Button type={type || 'submit'} size={size || 'sm'} onClick={onClick}>{children}</Button>) | ||
} |
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 './EnabledButton' |
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 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
47 changes: 47 additions & 0 deletions
47
src/views/CaseView/CaseDetailView/MarkBookingsComplete/MarkBookingsComplete.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,47 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
import React, {FormEvent} from 'react'; | ||
import {Form} from "@carbon/react"; | ||
import {useSetAtom} from "jotai"; | ||
|
||
import {familyAllowanceCaseAtom} from "../../../../atoms"; | ||
import {EnabledButton, Stack} from "../../../../components"; | ||
import {FamilyAllowanceStatus} from "../../../../models"; | ||
import {familyAllowanceCaseApi, FamilyAllowanceCaseApi} from "../../../../services"; | ||
|
||
export interface MarkBookingsCompleteProps { | ||
caseId: string; | ||
status: FamilyAllowanceStatus; | ||
} | ||
|
||
export const MarkBookingsComplete: React.FunctionComponent<MarkBookingsCompleteProps> = ({caseId, status}: MarkBookingsCompleteProps) => { | ||
const setFamilyAllowanceCase = useSetAtom(familyAllowanceCaseAtom) | ||
|
||
const enabled = FamilyAllowanceStatus[status] === FamilyAllowanceStatus.PendingBookings | ||
|
||
if (!enabled) { | ||
return (<></>) | ||
} | ||
|
||
const service: FamilyAllowanceCaseApi = familyAllowanceCaseApi() | ||
|
||
const updateCaseStatusToCompleted = (event: FormEvent<HTMLFormElement>) => { | ||
event.preventDefault() | ||
event.stopPropagation() | ||
|
||
service | ||
.markFamilyAllowanceCaseBookingsComplete(caseId) | ||
.then(setFamilyAllowanceCase) | ||
} | ||
|
||
return ( | ||
<div style={{padding: '20px 0'}}> | ||
<Form className="" onSubmit={updateCaseStatusToCompleted}> | ||
<Stack gap={3}> | ||
<EnabledButton enabled={enabled}>Bookings completed</EnabledButton> | ||
</Stack> | ||
</Form> | ||
</div> | ||
) | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
src/views/CaseView/CaseDetailView/MarkBookingsComplete/index.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 @@ | ||
export * from './MarkBookingsComplete' |
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