aboutsummaryrefslogtreecommitdiff
path: root/src/lib/server/services/routine-actions.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/server/services/routine-actions.ts')
-rw-r--r--src/lib/server/services/routine-actions.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/server/services/routine-actions.ts b/src/lib/server/services/routine-actions.ts
index 1d7f8b5..ea4e91e 100644
--- a/src/lib/server/services/routine-actions.ts
+++ b/src/lib/server/services/routine-actions.ts
@@ -1,5 +1,5 @@
import { fail, type ActionFailure } from '@sveltejs/kit';
-import { archive, complete, edit, loadCurrent } from './routines';
+import { routinesService } from '$lib/server/services';
import { parseFormString } from './validation';
import { instantFromDay } from '$lib/shared/temporal';
import { Frequency } from '$lib/shared/frequency';
@@ -14,7 +14,7 @@ export async function editRoutineAction(
routineId: number,
extra?: { type: 'edit' },
): Promise<EditRoutineResult> {
- const current = await loadCurrent(routineId);
+ const current = await routinesService.loadCurrent(routineId);
if (!current) {
return fail(400, { error: 'Routine introuvable' });
}
@@ -47,7 +47,7 @@ export async function editRoutineAction(
}
try {
- await edit(routineId, fields);
+ await routinesService.edit(routineId, fields);
} catch {
return fail(400, { error: 'Routine introuvable' });
}
@@ -55,7 +55,7 @@ export async function editRoutineAction(
}
export async function completeRoutineAction(data: FormData, routineId: number) {
- const current = await loadCurrent(routineId);
+ const current = await routinesService.loadCurrent(routineId);
if (!current) {
return fail(400, { error: 'Routine introuvable' });
}
@@ -73,7 +73,11 @@ export async function completeRoutineAction(data: FormData, routineId: number) {
}
try {
- await complete(routineId, parseFormString(data.get('note')), doneAt);
+ await routinesService.complete(
+ routineId,
+ parseFormString(data.get('note')),
+ doneAt,
+ );
} catch {
return fail(400, { error: 'Routine introuvable' });
}
@@ -82,7 +86,7 @@ export async function completeRoutineAction(data: FormData, routineId: number) {
export async function archiveRoutineAction(routineId: number) {
try {
- await archive(routineId);
+ await routinesService.archive(routineId);
} catch {
return fail(400, { error: 'Routine introuvable' });
}