-
Notifications
You must be signed in to change notification settings - Fork 113
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
1 parent
edc3d08
commit 143c4b8
Showing
2 changed files
with
56 additions
and
50 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,53 @@ | ||
import {Share} from "./api"; | ||
import {useEffect, useRef, useState} from "react"; | ||
import {Box, Button, Checkbox, FormControlLabel, Grid2, Modal, Typography} from "@mui/material"; | ||
import {modalStyle} from "./styling/theme.ts"; | ||
|
||
interface ReleaseShareProps { | ||
close: () => void; | ||
isOpen: boolean; | ||
detail: Share; | ||
action: () => void; | ||
} | ||
|
||
const ReleaseShareModal = ({ close, isOpen, detail, action }: ReleaseShareProps) => { | ||
const [token, setToken] = useState<String>(""); | ||
const [checked, setChecked] = useState<boolean>(false); | ||
const checkedRef = useRef<boolean>(); | ||
checkedRef.current = checked; | ||
|
||
const toggleChecked = () => { | ||
setChecked(!checkedRef.current); | ||
} | ||
|
||
useEffect(() => { | ||
setChecked(false); | ||
}, [isOpen]); | ||
|
||
useEffect(() => { | ||
if(detail && detail.token) { | ||
setToken(detail.token); | ||
} | ||
}, [detail]); | ||
|
||
return ( | ||
<Modal open={isOpen} onClose={close}> | ||
<Box sx={{ ...modalStyle }}> | ||
<Grid2 container sx={{ flexGrow: 1, p: 1 }} alignItems="center"> | ||
<Typography variant="h5"><strong>Release Share</strong></Typography> | ||
</Grid2> | ||
<Grid2 container sx={{ flexGrow: 1, p: 1 }} alignItems="center"> | ||
<Typography variant="body1">Would you like to release the share <code>{token}</code> ?</Typography> | ||
</Grid2> | ||
<Grid2 container sx={{ flexGrow: 1, p: 1 }} alignItems="center"> | ||
<FormControlLabel control={<Checkbox checked={checked} onChange={toggleChecked} />} label={<p>I confirm the release of <code>{token}</code></p>} sx={{ mt: 2 }} /> | ||
</Grid2> | ||
<Grid2 container sx={{ flexGrow: 1 }} alignItems="center"> | ||
<Button color="error" variant="contained" disabled={!checked} onClick={action}>Release</Button> | ||
</Grid2> | ||
</Box> | ||
</Modal> | ||
) | ||
} | ||
|
||
export default ReleaseShareModal; |
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