🚨(frontend) block button when creating doc
When the user clicks on the button to create a new doc, the button is disabled to prevent multiple clicks. Multiple clicks on the button could create multiple docs and create a error about duplicated paths.
This commit is contained in:
@@ -8,6 +8,10 @@ and this project adheres to
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
|
||||||
|
- 🚨(frontend) block button when creating doc #749
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
- 🐛(back) validate document content in serializer #822
|
- 🐛(back) validate document content in serializer #822
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
|
|||||||
useCmdK(openSearchModal);
|
useCmdK(openSearchModal);
|
||||||
const { togglePanel } = useLeftPanelStore();
|
const { togglePanel } = useLeftPanelStore();
|
||||||
|
|
||||||
const { mutate: createDoc } = useCreateDoc({
|
const { mutate: createDoc, isPending: isCreatingDoc } = useCreateDoc({
|
||||||
onSuccess: (doc) => {
|
onSuccess: (doc) => {
|
||||||
router.push(`/docs/${doc.id}`);
|
router.push(`/docs/${doc.id}`);
|
||||||
togglePanel();
|
togglePanel();
|
||||||
@@ -81,7 +81,9 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
{authenticated && (
|
{authenticated && (
|
||||||
<Button onClick={createNewDoc}>{t('New doc')}</Button>
|
<Button onClick={createNewDoc} disabled={isCreatingDoc}>
|
||||||
|
{t('New doc')}
|
||||||
|
</Button>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</SeparatedSection>
|
</SeparatedSection>
|
||||||
|
|||||||
Reference in New Issue
Block a user