fix(i18n): use current language for delayed trash and undo feedback
This commit is contained in:
@@ -149,6 +149,8 @@ export default function JobTable({ refreshToken, pageSize, onPageSizeChange, col
|
||||
const isMobile = useMediaQuery("(max-width:767.95px)");
|
||||
const { toast } = useToast();
|
||||
const { t, language } = useI18n();
|
||||
const currentTranslation = useRef(t);
|
||||
currentTranslation.current = t;
|
||||
const { confirmAction } = useDialogActions();
|
||||
const location = useLocation();
|
||||
const boardView = mode === "jobs" && new URLSearchParams(location.search).get("view") === "board";
|
||||
@@ -414,20 +416,20 @@ export default function JobTable({ refreshToken, pageSize, onPageSizeChange, col
|
||||
if (!(await confirmDelete([job]))) return;
|
||||
try {
|
||||
await api.delete(`/jobapplications/${job.id}`);
|
||||
toast(t("jobTableMovedToTrash"), "success", { label: t("jobTableUndo"), onClick: () => { void restore(job.id); } });
|
||||
toast(currentTranslation.current("jobTableMovedToTrash"), "success", { label: currentTranslation.current("jobTableUndo"), onClick: () => { void restore(job.id); } });
|
||||
setReloadToken((token) => token + 1);
|
||||
} catch {
|
||||
toast(t("jobTableDeleteFailed"), "error");
|
||||
toast(currentTranslation.current("jobTableDeleteFailed"), "error");
|
||||
}
|
||||
};
|
||||
|
||||
const restore = async (id: number) => {
|
||||
try {
|
||||
await api.post(`/jobapplications/${id}/restore`);
|
||||
toast(t("jobTableRestored"), "success");
|
||||
toast(currentTranslation.current("jobTableRestored"), "success");
|
||||
setReloadToken((token) => token + 1);
|
||||
} catch {
|
||||
toast(t("jobTableRestoreFailed"), "error");
|
||||
toast(currentTranslation.current("jobTableRestoreFailed"), "error");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user