🚨(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:
Anthony LC
2025-03-17 17:17:18 +01:00
committed by Anthony LC
parent 910686293c
commit 3881930e82
2 changed files with 8 additions and 2 deletions

View File

@@ -8,6 +8,10 @@ and this project adheres to
## [Unreleased]
## Changed
- 🚨(frontend) block button when creating doc #749
## Fixed
- 🐛(back) validate document content in serializer #822

View File

@@ -33,7 +33,7 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
useCmdK(openSearchModal);
const { togglePanel } = useLeftPanelStore();
const { mutate: createDoc } = useCreateDoc({
const { mutate: createDoc, isPending: isCreatingDoc } = useCreateDoc({
onSuccess: (doc) => {
router.push(`/docs/${doc.id}`);
togglePanel();
@@ -81,7 +81,9 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => {
)}
</Box>
{authenticated && (
<Button onClick={createNewDoc}>{t('New doc')}</Button>
<Button onClick={createNewDoc} disabled={isCreatingDoc}>
{t('New doc')}
</Button>
)}
</Box>
</SeparatedSection>