Skip to content

Commit 463ee0e

Browse files
๐Ÿ“ Add docstrings to #3067
Docstrings generation was requested by @KATO-Hiro. * #3069 (comment) The following files were modified: * `src/routes/(admin)/account_transfer/+page.server.ts` * `src/routes/workbooks/edit/[slug]/+page.server.ts`
1 parent 2c90e2b commit 463ee0e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

โ€Žsrc/routes/(admin)/account_transfer/+page.server.tsโ€Ž

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ import { Roles } from '$lib/types/user';
1616

1717
let accountTransferMessages: FloatingMessage[] = [];
1818

19+
/**
20+
* Prepare data for the account transfer page by validating the current session, enforcing admin access, and constructing the transfer form.
21+
*
22+
* @param locals - SvelteKit locals providing `auth` for session validation and services used to fetch user data.
23+
* @returns An object with `success: true`, `form`: the validated account transfer form with its `message` cleared, and `accountTransferMessages`: the module-level messages array related to account transfers.
24+
* @throws Redirects to the login page when the session is missing or the authenticated user is not an admin.
25+
*/
1926
export async function load({ locals }) {
2027
const session = await locals.auth.validate();
2128

@@ -79,4 +86,4 @@ export const actions: Actions = {
7986
};
8087
}
8188
},
82-
};
89+
};

โ€Žsrc/routes/workbooks/edit/[slug]/+page.server.tsโ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import { workBookSchema } from '$lib/zod/schema';
1414
import * as tasksCrud from '$lib/services/tasks';
1515
import * as workBooksCrud from '$lib/services/workbooks';
1616

17+
/**
18+
* Loads workbook and author data, initializes a validation form and task lookups, and enforces edit permissions for the current user.
19+
*
20+
* @returns An object containing the initialized `form` (prefilled with the workbook), `loggedInAsAdmin` flag, the workbook with author data, `tasks`, and `tasksMapByIds`. If a logged-in user exists but is not authorized to edit the workbook, the returned object includes `status: FORBIDDEN` and a `message` describing the access restriction. */
1721
export async function load({ locals, params }) {
1822
const loggedInUser = await getLoggedInUser(locals);
1923
const loggedInAsAdmin = isAdmin(loggedInUser?.role as Roles);
@@ -97,4 +101,4 @@ export const actions = {
97101

98102
redirect(TEMPORARY_REDIRECT, '/workbooks');
99103
},
100-
};
104+
};

0 commit comments

Comments
ย (0)