feat: update dashboard view

This commit is contained in:
2026-07-16 02:05:36 +05:00
parent 1d1f11c3f8
commit bda6c6b2e0
14 changed files with 338 additions and 136 deletions
+54
View File
@@ -0,0 +1,54 @@
import { errAsync, okAsync, ResultAsync } from "neverthrow";
import { applyRawTaskContent } from "@/dashboard/applyRawTaskContent";
import { appError, AppError, AppErrorVariant } from "@/error";
import { Task } from "@/model/task";
import { ITaskRepository } from "@/ports";
export type SaveTaskRawInput = {
folderPath?: string;
id?: string;
raw?: string;
};
export function saveTaskRaw(
repo: ITaskRepository,
input: SaveTaskRawInput,
): ResultAsync<Task, AppError> {
if (input.folderPath === undefined) {
return errAsync(appError(AppErrorVariant.NO_FOLDER));
}
if (input.id === undefined) {
return errAsync(appError(AppErrorVariant.NO_ID));
}
if (input.raw === undefined) {
return errAsync(appError(AppErrorVariant.NO_RAW));
}
const folderPath = input.folderPath;
const id = input.id;
const raw = input.raw;
return ResultAsync.fromSafePromise(repo.getById(folderPath, id)).andThen(
(existing) => {
if (!existing) {
return errAsync(appError(AppErrorVariant.NOT_FOUND, { id }));
}
const applied = applyRawTaskContent(raw, existing);
if (applied.isErr()) {
return errAsync(applied.error);
}
const next = applied.value;
return ResultAsync.fromSafePromise(repo.update(folderPath, next)).andThen(
() =>
ResultAsync.fromSafePromise(repo.getById(folderPath, id)).andThen(
(updated) =>
updated
? okAsync(updated)
: errAsync(appError(AppErrorVariant.NOT_FOUND, { id })),
),
);
},
);
}