Skip to content

Commit

Permalink
add confirm before delete (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek authored Feb 3, 2025
1 parent b0b0abd commit 103e03e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/components/AboutModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ export function AboutModal({
const navigate = useNavigate();

const handleDeleteDocument = async () => {
await deleteDocument(documentId, modificationSecret);
deleteLocalDocument(documentId);
void navigate('/');
const confirmed = confirm(t('modals.about.confirmDelete'));
if (confirmed) {
await deleteDocument(documentId, modificationSecret);
deleteLocalDocument(documentId);
void navigate('/');
}
};
return (
<Modal
Expand Down
3 changes: 2 additions & 1 deletion src/locales/de/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
"linkLegal": "Impressum",
"buttons": {
"delete": "Text löschen"
}
},
"confirmDelete": "Wirklich löschen?"
}
},
"page": {
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
"content": "GroupWriter is a collaboration tool for teams to write and edit documents together.",
"buttons": {
"delete": "Delete text"
}
},
"confirmDelete": "Are you sure you want to delete this text?"
}
},
"page": {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/editorSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const createServerUrl = (targetSubdomain: string, postFix?: string): string => {

return `${protocol}${subdomain}.${hostArray
.slice(1, hostArray.length)
.join('.')}${postFix ? postFix : ''}`;
.join('.')}${postFix ?? ''}`;
};

export const serverUrl = (): string => {
Expand Down

0 comments on commit 103e03e

Please sign in to comment.