-
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.
- Configure creation of a new posts - Enhance api interceptor - Take basic user info to navbar - Enhance RichEditor to return his value - Correct roots - Make strong nullcheck in MenuButton Refs: CU-86973uu60 Signed-off-by: Patryk Kłosiński <[email protected]>
- Loading branch information
Showing
12 changed files
with
125 additions
and
40 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 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,57 @@ | ||
import {RichEditor} from "../../Components/RichEditor"; | ||
import {Button, Divider, Group, Modal} from "@mantine/core"; | ||
import {useDisclosure} from "@mantine/hooks"; | ||
import {IconPencil} from "@tabler/icons-react"; | ||
import {useState} from "react"; | ||
import api from "../../Services/api.ts"; | ||
import {useAlert} from "../../Providers/AlertProvider.tsx"; | ||
|
||
export const CreatePost = () => { | ||
const [opened, {open, close}] = useDisclosure(false); | ||
const [content, setContent] = useState(''); | ||
const alert = useAlert(); | ||
|
||
const handleContentChange = (html: string) => { | ||
setContent(html); | ||
} | ||
|
||
const handleCreatePost = () => { | ||
console.log('Create post: ', content) | ||
if (!content) { | ||
alert.showError('Post is empty!'); | ||
return; | ||
} | ||
|
||
api.post('/api/posts/create', null, {params: {content}}).then((response) => { | ||
if (response.status === 200) { | ||
close(); | ||
} | ||
}); | ||
} | ||
|
||
return ( | ||
<> | ||
<Modal opened={opened} onClose={close} title="Create post" size={"auto"} centered closeOnClickOutside={false}> | ||
<RichEditor onContentChange={handleContentChange}/> | ||
<Divider my={"md"}/> | ||
<Group justify={"space-between"}> | ||
<Button color="red" variant="light" onClick={close}>Cancel</Button> | ||
<Button color="blue" variant="light" onClick={handleCreatePost}>Create</Button> | ||
</Group> | ||
</Modal> | ||
|
||
<Button | ||
variant={"subtle"} | ||
size={"md"} | ||
leftSection={<IconPencil/>} | ||
autoContrast | ||
fullWidth | ||
justify={"flex-start"} | ||
color={"gray"} | ||
onClick={open} | ||
> | ||
Napisz post | ||
</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 './CreatePost.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
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
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