feat: toasts
This commit is contained in:
@@ -6,6 +6,8 @@ import { updateTask } from "@/api/tasks";
|
||||
const CronInput = defineAsyncComponent(() => import("@/components/CronInput.vue"));
|
||||
import { taskCompleted, taskNextReset } from "@/lib/tasks";
|
||||
import { relativeTime } from "@/lib/dates";
|
||||
import { useAlertStore } from "@/stores/alerts";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const emit = defineEmits<(e: 'clone' | 'delete', task: Task) => void>();
|
||||
|
||||
@@ -20,15 +22,22 @@ const refreshKey = ref<number>(0);
|
||||
const checked = computed<boolean>(() => taskCompleted(task.value));
|
||||
const nextReset = computed<Date | null>(() => taskNextReset(task.value));
|
||||
|
||||
const i18n = useI18n();
|
||||
|
||||
const { alertSuccess, alertError } = useAlertStore();
|
||||
|
||||
function onClose() {
|
||||
editMode.value = false;
|
||||
}
|
||||
|
||||
function onSave() {
|
||||
void updateTask(task.value.id, { name: editName.value, reset_cron: editCron.value })
|
||||
updateTask(task.value.id, { name: editName.value, reset_cron: editCron.value })
|
||||
.then((newTask) => {
|
||||
task.value = newTask;
|
||||
});
|
||||
alertSuccess(i18n.t('alerts.task_updated'));
|
||||
}).catch(() => {
|
||||
alertError(i18n.t('alerts.task_update_error'))
|
||||
})
|
||||
task.value.name = editName.value;
|
||||
task.value.reset_cron = editCron.value;
|
||||
editMode.value = false;
|
||||
@@ -36,14 +45,18 @@ function onSave() {
|
||||
|
||||
function onCheck() {
|
||||
if (!checked.value) {
|
||||
void updateTask(task.value.id, { check_date: (new Date()).toISOString(), previous_check_date: task.value.check_date?.toISOString() })
|
||||
updateTask(task.value.id, { check_date: (new Date()).toISOString(), previous_check_date: task.value.check_date?.toISOString() })
|
||||
.then((newTask) => {
|
||||
task.value = newTask;
|
||||
}).catch(() => {
|
||||
alertError(i18n.t('alerts.task_update_error'))
|
||||
});
|
||||
} else {
|
||||
void updateTask(task.value.id, { check_date: null, previous_check_date: task.value.check_date?.toISOString() })
|
||||
updateTask(task.value.id, { check_date: null, previous_check_date: task.value.check_date?.toISOString() })
|
||||
.then((newTask) => {
|
||||
task.value = newTask;
|
||||
}).catch(() => {
|
||||
alertError(i18n.t('alerts.task_update_error'))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user