diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-12-09 03:57:12 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-12-09 03:57:12 +0100 |
| commit | 4dbef3fcd7a14437d55c555cf10d50de8e50d7d1 (patch) | |
| tree | 632589ecfcfb4dfddeafb71d0077257584b5e7ec /code/app/src/routes/(main)/(public) | |
| parent | 914c75e0ceeb3e11ddd55e94bb461c26b0db5b7a (diff) | |
| download | greatoffice-4dbef3fcd7a14437d55c555cf10d50de8e50d7d1.tar.xz greatoffice-4dbef3fcd7a14437d55c555cf10d50de8e50d7d1.zip | |
feat: Move everything out of $lib
Diffstat (limited to 'code/app/src/routes/(main)/(public)')
7 files changed, 115 insertions, 112 deletions
diff --git a/code/app/src/routes/(main)/(public)/+layout.svelte b/code/app/src/routes/(main)/(public)/+layout.svelte index cbda776..0d84f9a 100644 --- a/code/app/src/routes/(main)/(public)/+layout.svelte +++ b/code/app/src/routes/(main)/(public)/+layout.svelte @@ -1,10 +1,10 @@ <script> - import { LocaleSwitcher } from "$lib/components"; - import LL from "$lib/i18n/i18n-svelte"; + import {LocaleSwitcher} from "$components"; + import LL from "$i18n/i18n-svelte"; </script> -<LocaleSwitcher tabindex={-1} /> -<slot /> +<LocaleSwitcher tabindex={-1}/> +<slot/> <footer class="grid sm:gap-5 grid-flow-row sm:justify-center px-2 sm:grid-flow-col"> <a href="https://greatoffice.life/privacy" class="link"> {$LL.privacyPolicy()} diff --git a/code/app/src/routes/(main)/(public)/reset-password/+page.svelte b/code/app/src/routes/(main)/(public)/reset-password/+page.svelte index 2b34dfc..34dabae 100644 --- a/code/app/src/routes/(main)/(public)/reset-password/+page.svelte +++ b/code/app/src/routes/(main)/(public)/reset-password/+page.svelte @@ -1,8 +1,8 @@ <script lang="ts"> - import { Alert, Input, Button } from "$lib/components"; - import LL from "$lib/i18n/i18n-svelte"; - import { FormError } from "$lib/models/internal/FormError"; - import { PasswordResetService } from "$lib/services/password-reset-service"; + import {Alert, Input, Button} from "$components"; + import LL from "$i18n/i18n-svelte"; + import {FormError} from "$models/internal/FormError"; + import {PasswordResetService} from "$services/password-reset-service"; const formData = { email: { @@ -61,21 +61,21 @@ <div class="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10"> <form class="space-y-6" on:submit|preventDefault={submit_form_async}> {#if showErrorAlert} - <Alert title={formError.title} message={formError.subtitle} type="error" /> + <Alert title={formError.title} message={formError.subtitle} type="error"/> {:else if showSuccessAlert} - <Alert type="success" title={$LL.success()} message={$LL.resetPasswordPage.requestSentMessage()} /> + <Alert type="success" title={$LL.success()} message={$LL.resetPasswordPage.requestSentMessage()}/> {/if} <Input - id="email" - name="email" - type="email" - autocomplete="email" - errors={formData.email.errors} - bind:value={formData.email.value} - required - label={$LL.emailAddress()} + id="email" + name="email" + type="email" + autocomplete="email" + errors={formData.email.errors} + bind:value={formData.email.value} + required + label={$LL.emailAddress()} /> - <Button text={$LL.submit()} type="submit" {loading} fullWidth /> + <Button text={$LL.submit()} type="submit" {loading} fullWidth/> </form> </div> </div> diff --git a/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts b/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts index 389d04c..907b444 100644 --- a/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts +++ b/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts @@ -1,11 +1,11 @@ -import { is_guid } from '$lib/helpers'; -import { redirect } from '@sveltejs/kit'; -import type { PageServerLoad } from './$types'; +import {is_guid} from "$help"; +import {redirect} from "@sveltejs/kit"; +import type {PageServerLoad} from "./$types"; -export const load: PageServerLoad = async ({ params }) => { +export const load: PageServerLoad = async ({params}) => { const resetRequestId = params.id ?? ""; if (!is_guid(resetRequestId)) throw redirect(302, "/reset-password"); return { - resetRequestId + resetRequestId, }; };
\ No newline at end of file diff --git a/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.svelte b/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.svelte index ba59a8f..8f817bf 100644 --- a/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.svelte +++ b/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.svelte @@ -1,11 +1,11 @@ <script lang="ts"> - import { onMount } from "svelte"; - import LL from "$lib/i18n/i18n-svelte"; - import { Alert, Input, Button } from "$lib/components"; - import type { PageServerData } from "./$types"; - import { goto } from "$app/navigation"; - import { SignInPageMessage, signInPageMessageQueryKey } from "$routes/(main)/(public)/sign-in"; - import { PasswordResetService } from "$lib/services/password-reset-service"; + import {onMount} from "svelte"; + import LL from "$i18n/i18n-svelte"; + import {Alert, Input, Button} from "$components"; + import type {PageServerData} from "./$types"; + import {goto} from "$app/navigation"; + import {SignInPageMessage, signInPageMessageQueryKey} from "$routes/(main)/(public)/sign-in"; + import {PasswordResetService} from "$services/password-reset-service"; export let data: PageServerData; const passwordResets = new PasswordResetService(); @@ -57,18 +57,19 @@ <div class="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10"> <form class="space-y-6" on:submit|preventDefault={submitFormAsync}> {#if requestIsInvalid} - <Alert title={$LL.resetPasswordPage.invalidRequestTitle()} message={$LL.resetPasswordPage.invalidRequestMessage()} /> + <Alert title={$LL.resetPasswordPage.invalidRequestTitle()} + message={$LL.resetPasswordPage.invalidRequestMessage()}/> {/if} <Input - id="password" - name="password" - type="password" - autocomplete="new-password" - required - bind:value={formData.newPassword.value} - label={$LL.resetPasswordPage.newPassword()} + id="password" + name="password" + type="password" + autocomplete="new-password" + required + bind:value={formData.newPassword.value} + label={$LL.resetPasswordPage.newPassword()} /> - <Button text={$LL.submit()} type="submit" {loading} fullWidth /> + <Button text={$LL.submit()} type="submit" {loading} fullWidth/> </form> </div> </div> diff --git a/code/app/src/routes/(main)/(public)/sign-in/+page.svelte b/code/app/src/routes/(main)/(public)/sign-in/+page.svelte index 12801c5..e862050 100644 --- a/code/app/src/routes/(main)/(public)/sign-in/+page.svelte +++ b/code/app/src/routes/(main)/(public)/sign-in/+page.svelte @@ -1,13 +1,13 @@ <script lang="ts"> - import { goto } from "$app/navigation"; - import { Button, Checkbox, Input, Alert } from "$lib/components"; - import LL from "$lib/i18n/i18n-svelte"; + import {goto} from "$app/navigation"; + import {Button, Checkbox, Input, Alert} from "$components"; + import LL from "$i18n/i18n-svelte"; import pwKey from "$actions/pwKey"; - import { onMount } from "svelte"; - import { signInPageMessageQueryKey, signInPageTestKeys, type SignInPageMessage } from "."; - import { AccountService } from "$lib/services/account-service"; - import type { LoginPayload } from "$lib/services/abstractions/IAccountService"; - import { FormError } from "$lib/models/internal/FormError"; + import {onMount} from "svelte"; + import {signInPageMessageQueryKey, signInPageTestKeys, type SignInPageMessage} from "."; + import {AccountService} from "$services/account-service"; + import type {LoginPayload} from "$services/abstractions/IAccountService"; + import {FormError} from "$models/internal/FormError"; let loading = false; let showErrorAlert = false; @@ -71,24 +71,24 @@ <div class="sm:max-w-md sm:mx-auto sm:w-full"> {#if messageType === "after-password-reset"} <Alert - title={$LL.signInPage.yourNewPasswordIsApplied()} - _pwKey={signInPageTestKeys.afterPasswordResetAlert} - message={$LL.signInPage.signInBelow()} - closeable + title={$LL.signInPage.yourNewPasswordIsApplied()} + _pwKey={signInPageTestKeys.afterPasswordResetAlert} + message={$LL.signInPage.signInBelow()} + closeable /> {:else if messageType === "user-disabled"} <Alert - title={$LL.signInPage.yourAccountIsDisabled()} - _pwKey={signInPageTestKeys.userDisabledAlert} - message={$LL.signInPage.contactYourAdminIfDisabled()} - closeable + title={$LL.signInPage.yourAccountIsDisabled()} + _pwKey={signInPageTestKeys.userDisabledAlert} + message={$LL.signInPage.contactYourAdminIfDisabled()} + closeable /> {:else if messageType === "user-inactivity"} <Alert - title={$LL.signInPage.youHaveReachedInactivityLimit()} - _pwKey={signInPageTestKeys.userInactivityAlert} - message={$LL.signInPage.feelFreeToSignInAgain()} - closeable + title={$LL.signInPage.youHaveReachedInactivityLimit()} + _pwKey={signInPageTestKeys.userInactivityAlert} + message={$LL.signInPage.feelFreeToSignInAgain()} + closeable /> {/if} </div> @@ -107,37 +107,39 @@ <div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md"> <div class="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10"> {#if showErrorAlert} - <Alert title={formError.title} message={formError.subtitle} type="error" _pwKey={signInPageTestKeys.formErrorAlert} /> + <Alert title={formError.title} message={formError.subtitle} type="error" + _pwKey={signInPageTestKeys.formErrorAlert}/> {/if} - <form class="space-y-6 mt-2" use:pwKey={signInPageTestKeys.signInForm} on:submit|preventDefault={submit_form_async}> + <form class="space-y-6 mt-2" use:pwKey={signInPageTestKeys.signInForm} + on:submit|preventDefault={submit_form_async}> <Input - id="username" - _pwKey={signInPageTestKeys.usernameInput} - name="username" - type="email" - label={$LL.emailAddress()} - required - bind:value={formData.username.value} + id="username" + _pwKey={signInPageTestKeys.usernameInput} + name="username" + type="email" + label={$LL.emailAddress()} + required + bind:value={formData.username.value} /> <Input - id="password" - name="password" - type="password" - label={$LL.password()} - _pwKey={signInPageTestKeys.passwordInput} - autocomplete="current-password" - required - bind:value={formData.password.value} + id="password" + name="password" + type="password" + label={$LL.password()} + _pwKey={signInPageTestKeys.passwordInput} + autocomplete="current-password" + required + bind:value={formData.password.value} /> <div class="flex items-center justify-between"> <Checkbox - id="remember-me" - _pwKey={signInPageTestKeys.rememberMeCheckbox} - name="remember-me" - bind:checked={formData.persist.value} - label={$LL.signInPage.notMyComputer()} + id="remember-me" + _pwKey={signInPageTestKeys.rememberMeCheckbox} + name="remember-me" + bind:checked={formData.persist.value} + label={$LL.signInPage.notMyComputer()} /> <div class="text-sm"> <a href="/reset-password" class="link" use:pwKey={signInPageTestKeys.resetPasswordAnchor}> @@ -146,7 +148,7 @@ </div> </div> - <Button text={$LL.submit()} fullWidth type="submit" {loading} /> + <Button text={$LL.submit()} fullWidth type="submit" {loading}/> </form> </div> </div> diff --git a/code/app/src/routes/(main)/(public)/sign-in/tests/index.spec.ts b/code/app/src/routes/(main)/(public)/sign-in/tests/index.spec.ts index ea8c494..9a9f7a5 100644 --- a/code/app/src/routes/(main)/(public)/sign-in/tests/index.spec.ts +++ b/code/app/src/routes/(main)/(public)/sign-in/tests/index.spec.ts @@ -1,12 +1,12 @@ -import { test, expect } from "@playwright/test"; -import { signInPageTestKeys } from "../index"; -import { get_test_context } from "$lib/configuration"; -import { get_pw_key_selector } from "$lib/helpers"; +import {test, expect} from "@playwright/test"; +import {signInPageTestKeys} from "../index"; +import {get_test_context} from "$configuration"; +import {get_pw_key_selector} from "$help"; const context = get_test_context(); -test("form loads", async ({ page }) => { +test("form loads", async ({page}) => { page.goto("/sign-in"); const form = page.locator(get_pw_key_selector(signInPageTestKeys.signInForm)); expect(form.isVisible()).toBeTruthy(); -}) +}); diff --git a/code/app/src/routes/(main)/(public)/sign-up/+page.svelte b/code/app/src/routes/(main)/(public)/sign-up/+page.svelte index 9fa8dfa..58940ea 100644 --- a/code/app/src/routes/(main)/(public)/sign-up/+page.svelte +++ b/code/app/src/routes/(main)/(public)/sign-up/+page.svelte @@ -1,10 +1,10 @@ <script lang="ts"> - import { goto } from "$app/navigation"; - import type { CreateAccountPayload } from "$lib/api/account"; - import { Button, Input, Alert } from "$lib/components"; - import LL from "$lib/i18n/i18n-svelte"; - import { FormError } from "$lib/models/internal/FormError"; - import { AccountService } from "$lib/services/account-service"; + import {goto} from "$app/navigation"; + import type {CreateAccountPayload} from "$api/account"; + import {Button, Input, Alert} from "$components"; + import LL from "$i18n/i18n-svelte"; + import {FormError} from "$models/internal/FormError"; + import {AccountService} from "$services/account-service"; const formData = { username: { @@ -76,30 +76,30 @@ <div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md"> <div class="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10"> {#if showErrorAlert} - <Alert title={formError.title} message={formError.subtitle} type="error" class="mb-2" /> + <Alert title={formError.title} message={formError.subtitle} type="error" class="mb-2"/> {/if} <form class="space-y-6" on:submit|preventDefault={submit_form_async}> <Input - label={$LL.emailAddress()} - id="email" - name="email" - autocomplete="email" - required - type="email" - bind:value={formData.username.value} - errors={formData.username.errors} + label={$LL.emailAddress()} + id="email" + name="email" + autocomplete="email" + required + type="email" + bind:value={formData.username.value} + errors={formData.username.errors} /> <Input - label={$LL.password()} - id="password" - name="password" - required - type="password" - bind:value={formData.password.value} - errors={formData.password.errors} + label={$LL.password()} + id="password" + name="password" + required + type="password" + bind:value={formData.password.value} + errors={formData.password.errors} /> - <Button type="submit" text={$LL.submit()} {loading} fullWidth /> + <Button type="submit" text={$LL.submit()} {loading} fullWidth/> </form> </div> </div> |
