diff --git a/docker-compose.yml b/docker-compose.yml index a20318cd..1d6e257a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,9 +5,12 @@ services: volumes: - ${STATIC_FILES_PATH:-./static}:/app/static - ${DATABASE_PATH:-./db}:/app/db + - ${PRIVATE_FILES_PATH:-./private}:/app/private environment: - SECRET=${SECRET:-} + - DATA_FILES_PATH=/app/data - STATIC_FILES_PATH=/app/static + - PRIVATE_FILES_PATH=/app/private - DATABASE_PATH=/app/db - ENABLE_CORS=${ENABLE_CORS:-false} - HOST=${HOST:-backend} diff --git a/frontend/src/lib/admin.svelte.ts b/frontend/src/lib/admin.svelte.ts index 254beea6..69c78485 100644 --- a/frontend/src/lib/admin.svelte.ts +++ b/frontend/src/lib/admin.svelte.ts @@ -1,17 +1,19 @@ import { authCookieLogin, + getChildQuestionsAdmin, getMilestoneGroupsAdmin, getUserQuestionsAdmin, usersCurrentUser, } from "$lib/client/services.gen"; import type { Body_auth_cookie_login_auth_login_post, - GetLanguagesResponse, - MilestoneGroupAdmin, - UserQuestionAdmin, UserRead, } from "$lib/client/types.gen"; -import { milestoneGroups, userQuestions } from "$lib/stores/adminStore"; +import { + childQuestions, + milestoneGroups, + userQuestions, +} from "$lib/stores/adminStore"; function AdminUser() { let user = $state(null as UserRead | null); @@ -70,3 +72,14 @@ export async function refreshUserQuestions() { userQuestions.set(data); } } + +export async function refreshChildQuestions() { + console.log("refreshQuestions..."); + const { data, error } = await getChildQuestionsAdmin(); + if (error || data === undefined) { + console.log("Failed to get child questions"); + childQuestions.set([]); + } else { + childQuestions.set(data); + } +} diff --git a/frontend/src/lib/client/services.gen.ts b/frontend/src/lib/client/services.gen.ts index d4b7bdc0..4fac64ce 100644 --- a/frontend/src/lib/client/services.gen.ts +++ b/frontend/src/lib/client/services.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import { createClient, createConfig, type Options, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/client-fetch'; -import type { GetLanguagesError, GetLanguagesResponse, GetMilestonesError, GetMilestonesResponse, GetMilestoneData, GetMilestoneError, GetMilestoneResponse, GetMilestoneGroupsData, GetMilestoneGroupsError, GetMilestoneGroupsResponse, GetUserQuestionsError, GetUserQuestionsResponse, GetChildQuestionsError, GetChildQuestionsResponse, CreateLanguageData, CreateLanguageError, CreateLanguageResponse, DeleteLanguageData, DeleteLanguageError, DeleteLanguageResponse, UpdateI18NData, UpdateI18NError, UpdateI18NResponse, GetMilestoneGroupsAdminError, GetMilestoneGroupsAdminResponse, CreateMilestoneGroupAdminError, CreateMilestoneGroupAdminResponse, UpdateMilestoneGroupAdminData, UpdateMilestoneGroupAdminError, UpdateMilestoneGroupAdminResponse, DeleteMilestoneGroupAdminData, DeleteMilestoneGroupAdminError, DeleteMilestoneGroupAdminResponse, UploadMilestoneGroupImageData, UploadMilestoneGroupImageError, UploadMilestoneGroupImageResponse, CreateMilestoneData, CreateMilestoneError, CreateMilestoneResponse, UpdateMilestoneData, UpdateMilestoneError, UpdateMilestoneResponse, DeleteMilestoneData, DeleteMilestoneError, DeleteMilestoneResponse, UploadMilestoneImageData, UploadMilestoneImageError, UploadMilestoneImageResponse, GetUserQuestionsAdminError, GetUserQuestionsAdminResponse, UpdateUserQuestionData, UpdateUserQuestionError, UpdateUserQuestionResponse, CreateUserQuestionError, CreateUserQuestionResponse, DeleteUserQuestionData, DeleteUserQuestionError, DeleteUserQuestionResponse, GetChildQuestionsAdminError, GetChildQuestionsAdminResponse, UpdateChildQuestionData, UpdateChildQuestionError, UpdateChildQuestionResponse, CreateChildQuestionError, CreateChildQuestionResponse, DeleteChildQuestionData, DeleteChildQuestionError, DeleteChildQuestionResponse, UsersCurrentUserError, UsersCurrentUserResponse, UsersPatchCurrentUserData, UsersPatchCurrentUserError, UsersPatchCurrentUserResponse, UsersUserData, UsersUserError, UsersUserResponse, UsersPatchUserData, UsersPatchUserError, UsersPatchUserResponse, UsersDeleteUserData, UsersDeleteUserError, UsersDeleteUserResponse, GetChildrenError, GetChildrenResponse, UpdateChildData, UpdateChildError, UpdateChildResponse, CreateChildData, CreateChildError, CreateChildResponse, GetChildData, GetChildError, GetChildResponse, DeleteChildData, DeleteChildError, DeleteChildResponse, GetChildImageData, GetChildImageError, GetChildImageResponse, UploadChildImageData, UploadChildImageError, UploadChildImageResponse, GetCurrentMilestoneAnswerSessionData, GetCurrentMilestoneAnswerSessionError, GetCurrentMilestoneAnswerSessionResponse, UpdateMilestoneAnswerData, UpdateMilestoneAnswerError, UpdateMilestoneAnswerResponse, GetCurrentUserAnswersError, GetCurrentUserAnswersResponse, UpdateCurrentUserAnswersData, UpdateCurrentUserAnswersError, UpdateCurrentUserAnswersResponse, GetCurrentChildAnswersData, GetCurrentChildAnswersError, GetCurrentChildAnswersResponse, UpdateCurrentChildAnswersData, UpdateCurrentChildAnswersError, UpdateCurrentChildAnswersResponse, AuthCookieLoginData, AuthCookieLoginError, AuthCookieLoginResponse, AuthCookieLogoutError, AuthCookieLogoutResponse, RegisterRegisterData, RegisterRegisterError, RegisterRegisterResponse, ResetForgotPasswordData, ResetForgotPasswordError, ResetForgotPasswordResponse, ResetResetPasswordData, ResetResetPasswordError, ResetResetPasswordResponse, VerifyRequestTokenData, VerifyRequestTokenError, VerifyRequestTokenResponse, VerifyVerifyData, VerifyVerifyError, VerifyVerifyResponse, AuthError, AuthResponse } from './types.gen'; +import type { GetLanguagesError, GetLanguagesResponse, GetMilestonesError, GetMilestonesResponse, GetMilestoneData, GetMilestoneError, GetMilestoneResponse, GetMilestoneGroupsData, GetMilestoneGroupsError, GetMilestoneGroupsResponse, GetUserQuestionsError, GetUserQuestionsResponse, GetChildQuestionsError, GetChildQuestionsResponse, CreateLanguageData, CreateLanguageError, CreateLanguageResponse, DeleteLanguageData, DeleteLanguageError, DeleteLanguageResponse, UpdateI18NData, UpdateI18NError, UpdateI18NResponse, GetMilestoneGroupsAdminError, GetMilestoneGroupsAdminResponse, CreateMilestoneGroupAdminError, CreateMilestoneGroupAdminResponse, UpdateMilestoneGroupAdminData, UpdateMilestoneGroupAdminError, UpdateMilestoneGroupAdminResponse, DeleteMilestoneGroupAdminData, DeleteMilestoneGroupAdminError, DeleteMilestoneGroupAdminResponse, UploadMilestoneGroupImageData, UploadMilestoneGroupImageError, UploadMilestoneGroupImageResponse, CreateMilestoneData, CreateMilestoneError, CreateMilestoneResponse, UpdateMilestoneData, UpdateMilestoneError, UpdateMilestoneResponse, DeleteMilestoneData, DeleteMilestoneError, DeleteMilestoneResponse, UploadMilestoneImageData, UploadMilestoneImageError, UploadMilestoneImageResponse, GetUserQuestionsAdminError, GetUserQuestionsAdminResponse, UpdateUserQuestionData, UpdateUserQuestionError, UpdateUserQuestionResponse, CreateUserQuestionError, CreateUserQuestionResponse, DeleteUserQuestionData, DeleteUserQuestionError, DeleteUserQuestionResponse, GetChildQuestionsAdminError, GetChildQuestionsAdminResponse, UpdateChildQuestionData, UpdateChildQuestionError, UpdateChildQuestionResponse, CreateChildQuestionError, CreateChildQuestionResponse, DeleteChildQuestionData, DeleteChildQuestionError, DeleteChildQuestionResponse, UsersCurrentUserError, UsersCurrentUserResponse, UsersPatchCurrentUserData, UsersPatchCurrentUserError, UsersPatchCurrentUserResponse, UsersUserData, UsersUserError, UsersUserResponse, UsersPatchUserData, UsersPatchUserError, UsersPatchUserResponse, UsersDeleteUserData, UsersDeleteUserError, UsersDeleteUserResponse, GetChildrenError, GetChildrenResponse, UpdateChildData, UpdateChildError, UpdateChildResponse, CreateChildData, CreateChildError, CreateChildResponse, GetChildData, GetChildError, GetChildResponse, DeleteChildData, DeleteChildError, DeleteChildResponse, GetChildImageData, GetChildImageError, GetChildImageResponse, UploadChildImageData, UploadChildImageError, UploadChildImageResponse, DeleteChildImageData, DeleteChildImageError, DeleteChildImageResponse, GetCurrentMilestoneAnswerSessionData, GetCurrentMilestoneAnswerSessionError, GetCurrentMilestoneAnswerSessionResponse, UpdateMilestoneAnswerData, UpdateMilestoneAnswerError, UpdateMilestoneAnswerResponse, GetCurrentUserAnswersError, GetCurrentUserAnswersResponse, UpdateCurrentUserAnswersData, UpdateCurrentUserAnswersError, UpdateCurrentUserAnswersResponse, GetCurrentChildAnswersData, GetCurrentChildAnswersError, GetCurrentChildAnswersResponse, UpdateCurrentChildAnswersData, UpdateCurrentChildAnswersError, UpdateCurrentChildAnswersResponse, AuthCookieLoginData, AuthCookieLoginError, AuthCookieLoginResponse, AuthCookieLogoutError, AuthCookieLogoutResponse, RegisterRegisterData, RegisterRegisterError, RegisterRegisterResponse, ResetForgotPasswordData, ResetForgotPasswordError, ResetForgotPasswordResponse, ResetResetPasswordData, ResetResetPasswordError, ResetResetPasswordResponse, VerifyRequestTokenData, VerifyRequestTokenError, VerifyRequestTokenResponse, VerifyVerifyData, VerifyVerifyError, VerifyVerifyResponse, AuthError, AuthResponse } from './types.gen'; export const client = createClient(createConfig()); @@ -324,6 +324,14 @@ export const uploadChildImage = (options: url: '/users/children-images/{child_id}' }); }; +/** + * Delete Child Image + */ +export const deleteChildImage = (options: Options) => { return (options?.client ?? client).delete({ + ...options, + url: '/users/children-images/{child_id}' +}); }; + /** * Get Current Milestone Answer Session */ diff --git a/frontend/src/lib/client/types.gen.ts b/frontend/src/lib/client/types.gen.ts index fc861434..a51c7657 100644 --- a/frontend/src/lib/client/types.gen.ts +++ b/frontend/src/lib/client/types.gen.ts @@ -569,6 +569,16 @@ export type UploadChildImageResponse = (unknown); export type UploadChildImageError = (HTTPValidationError); +export type DeleteChildImageData = { + path: { + child_id: number; + }; +}; + +export type DeleteChildImageResponse = (unknown); + +export type DeleteChildImageError = (HTTPValidationError); + export type GetCurrentMilestoneAnswerSessionData = { path: { child_id: number; @@ -608,12 +618,16 @@ export type GetCurrentChildAnswersData = { }; }; -export type GetCurrentChildAnswersResponse = (Array); +export type GetCurrentChildAnswersResponse = ({ + [key: string]: ChildAnswerPublic; +}); export type GetCurrentChildAnswersError = (HTTPValidationError); export type UpdateCurrentChildAnswersData = { - body: Array; + body: { + [key: string]: ChildAnswerPublic; + }; path: { child_id: number; }; diff --git a/frontend/src/lib/components/Admin/EditUserQuestionModal.svelte b/frontend/src/lib/components/Admin/EditQuestionModal.svelte similarity index 66% rename from frontend/src/lib/components/Admin/EditUserQuestionModal.svelte rename to frontend/src/lib/components/Admin/EditQuestionModal.svelte index 23ef65f4..6f33a168 100644 --- a/frontend/src/lib/components/Admin/EditUserQuestionModal.svelte +++ b/frontend/src/lib/components/Admin/EditQuestionModal.svelte @@ -1,9 +1,15 @@ - {#if userQuestion} + {#if question}
- - {#each Object.values(userQuestion.text) as text} + + {#each Object.values(question.text) as text}
{text.lang_id} { - userQuestion = userQuestion; - }} - placeholder={$_('admin.placeholder')} + placeholder={$_("admin.placeholder")} />
@@ -91,25 +117,24 @@ async function saveChanges() {