mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 16:51:38 +10:00
🚸 delete UX
This commit is contained in:
@ -33,11 +33,12 @@ export default function PDFEditor(props: any) {
|
|||||||
const fieldIndex = fields.map((item) => item.id).indexOf(id);
|
const fieldIndex = fields.map((item) => item.id).indexOf(id);
|
||||||
console.log(fieldIndex);
|
console.log(fieldIndex);
|
||||||
if (fieldIndex > -1) {
|
if (fieldIndex > -1) {
|
||||||
const newFields = [...fields];
|
const fieldWithoutRemoved = [...fields];
|
||||||
newFields.splice(fieldIndex, 1);
|
const removedField = fieldWithoutRemoved.splice(fieldIndex, 1);
|
||||||
|
setFields(fieldWithoutRemoved);
|
||||||
setFields(newFields);
|
deleteField(field).catch((err) => {
|
||||||
deleteField(field);
|
setFields(fieldWithoutRemoved.concat(removedField));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +136,7 @@ async function deleteField(field: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const deleted = await toast.promise(
|
const deleted = toast.promise(
|
||||||
fetch("/api/documents/" + 0 + "/fields/" + field.id, {
|
fetch("/api/documents/" + 0 + "/fields/" + field.id, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user