feat: handle restore memo when is in archived memo detail page (#3165)

pull/3166/head
The Anh Nguyen 11 months ago committed by GitHub
parent c8baeb86ec
commit 2fe6d606ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -57,24 +57,35 @@ const MemoActionMenu = (props: Props) => {
}); });
}; };
const handleArchiveMemoClick = async () => { const handleToggleMemoStatusClick = async () => {
try { try {
await memoStore.updateMemo( if (memo.rowStatus === RowStatus.ARCHIVED) {
{ await memoStore.updateMemo(
name: memo.name, {
rowStatus: RowStatus.ARCHIVED, name: memo.name,
}, rowStatus: RowStatus.ACTIVE,
["row_status"], },
); ["row_status"],
);
toast(t("message.restored-successfully"));
} else {
await memoStore.updateMemo(
{
name: memo.name,
rowStatus: RowStatus.ARCHIVED,
},
["row_status"],
);
toast.success(t("message.archived-successfully"));
}
} catch (error: any) { } catch (error: any) {
console.error(error); console.error(error);
toast.error(error.response.data.message); toast.error(error.response.data.message);
return; return;
} }
toast.success("Archived successfully");
if (isInMemoDetailPage) { if (isInMemoDetailPage) {
navigateTo("/archived"); memo.rowStatus === RowStatus.ARCHIVED ? navigateTo("/") : navigateTo("/archived");
} }
}; };
@ -120,9 +131,9 @@ const MemoActionMenu = (props: Props) => {
{t("common.share")} {t("common.share")}
</MenuItem> </MenuItem>
)} )}
<MenuItem color="warning" onClick={handleArchiveMemoClick}> <MenuItem color="warning" onClick={handleToggleMemoStatusClick}>
<Icon.Archive className="w-4 h-auto" /> {memo.rowStatus === RowStatus.ARCHIVED ? <Icon.ArchiveRestore className="w-4 h-auto" /> : <Icon.Archive className="w-4 h-auto" />}
{t("common.archive")} {memo.rowStatus === RowStatus.ARCHIVED ? t("common.restore") : t("common.archive")}
</MenuItem> </MenuItem>
<MenuItem color="danger" onClick={handleDeleteMemoClick}> <MenuItem color="danger" onClick={handleDeleteMemoClick}>
<Icon.Trash className="w-4 h-auto" /> <Icon.Trash className="w-4 h-auto" />

@ -312,6 +312,7 @@
"no-data": "No data found.", "no-data": "No data found.",
"memos-ready": "all memos are ready", "memos-ready": "all memos are ready",
"resource-ready": "all resource are ready", "resource-ready": "all resource are ready",
"archived-successfully": "Archived successfully",
"restored-successfully": "Restored successfully", "restored-successfully": "Restored successfully",
"memo-updated-datetime": "Memo created datetime changed.", "memo-updated-datetime": "Memo created datetime changed.",
"invalid-created-datetime": "Invalid created datetime.", "invalid-created-datetime": "Invalid created datetime.",

@ -126,6 +126,7 @@
"private-only": "Bản ghi chú này là riêng tư", "private-only": "Bản ghi chú này là riêng tư",
"resource-filename-updated": "Tên tệp tài nguyên đã được cập nhật.", "resource-filename-updated": "Tên tệp tài nguyên đã được cập nhật.",
"resource-ready": "tất cả tài nguyên đã sẵn sàng", "resource-ready": "tất cả tài nguyên đã sẵn sàng",
"archived-successfully": "Lưu trữ thành công",
"restored-successfully": "Khôi phục thành công", "restored-successfully": "Khôi phục thành công",
"signup-failed": "Đăng ký thất bại", "signup-failed": "Đăng ký thất bại",
"succeed-copy-code": "Mã đã được sao chép thành công.", "succeed-copy-code": "Mã đã được sao chép thành công.",

Loading…
Cancel
Save