-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(FE) Document Creation within Workspace Document Name (#81)
* Add create note button * Implement create modal * Implement create document
- Loading branch information
Showing
11 changed files
with
276 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Button, FormControl, Modal, ModalProps, Paper, Stack, Typography } from "@mui/material"; | ||
import { FormContainer, TextFieldElement } from "react-hook-form-mui"; | ||
|
||
interface CreateRequest { | ||
title: string; | ||
} | ||
|
||
interface CreateModalProps extends Omit<ModalProps, "children"> { | ||
title: string; | ||
onSuccess: (data: CreateRequest) => Promise<void>; | ||
} | ||
|
||
function CreateModal(props: CreateModalProps) { | ||
const { title, onSuccess, ...modalProps } = props; | ||
|
||
const handleCreate = async (data: CreateRequest) => { | ||
await onSuccess(data); | ||
modalProps?.onClose?.(new Event("Close Modal"), "escapeKeyDown"); | ||
}; | ||
|
||
return ( | ||
<Modal disableAutoFocus {...modalProps}> | ||
<Paper | ||
sx={{ | ||
position: "absolute", | ||
top: "50%", | ||
left: "50%", | ||
transform: "translate(-50%, -50%)", | ||
p: 4, | ||
width: 400, | ||
}} | ||
> | ||
<Stack gap={4}> | ||
<Typography variant="h5">Create New {title}</Typography> | ||
<FormControl> | ||
<FormContainer defaultValues={{ title: "" }} onSuccess={handleCreate}> | ||
<Stack gap={4} alignItems="flex-end"> | ||
<TextFieldElement | ||
variant="standard" | ||
name="title" | ||
label="Title of new note" | ||
required | ||
fullWidth | ||
inputProps={{ | ||
maxLength: 255, | ||
}} | ||
/> | ||
<Button type="submit" variant="contained" size="large"> | ||
OK | ||
</Button> | ||
</Stack> | ||
</FormContainer> | ||
</FormControl> | ||
</Stack> | ||
</Paper> | ||
</Modal> | ||
); | ||
} | ||
|
||
export default CreateModal; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Document } from "./document"; | ||
|
||
export class GetWorkspaceDocumentListResponse { | ||
cursor: string | null; | ||
documents: Array<Document>; | ||
} | ||
|
||
export class CreateDocumentRequest { | ||
title: string; | ||
} | ||
|
||
export class CreateDocumentResponse extends Document {} |
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
Oops, something went wrong.