Use app.d.ts for login form JSDoc formResult

This commit is contained in:
Cristian Ditaputratama 2024-05-15 18:05:43 +07:00
parent 8f3f9392b7
commit e65e81d3c3
Signed by: ditatompel
GPG key ID: 31D3D06D77950979

View file

@ -3,14 +3,7 @@
import { apiUri } from '$lib/utils/common'; import { apiUri } from '$lib/utils/common';
import { ProgressBar, LightSwitch } from '@skeletonlabs/skeleton'; import { ProgressBar, LightSwitch } from '@skeletonlabs/skeleton';
/** /** @type {ApiResponse} */
* @typedef formResult
* @type {object}
* @property {string} status
* @property {string} message
* @property {null | object} data
*/
/** @type {formResult} */
export let formResult; export let formResult;
let isProcessing = false; let isProcessing = false;
@ -33,7 +26,6 @@
isProcessing = false; isProcessing = false;
if (formResult.status === 'ok') { if (formResult.status === 'ok') {
// rerun all `load` functions, following the successful update
await invalidateAll(); await invalidateAll();
goto('/app/prober/'); goto('/app/prober/');
} }
@ -52,48 +44,20 @@
<div <div
class="w-full rounded-lg shadow border md:mt-0 sm:max-w-md xl:p-0 bg-white border-gray-700 dark:bg-gray-800" class="w-full rounded-lg shadow border md:mt-0 sm:max-w-md xl:p-0 bg-white border-gray-700 dark:bg-gray-800"
> >
<!-- prettier-ignore -->
<div class="p-6 space-y-4 md:space-y-6 sm:p-8"> <div class="p-6 space-y-4 md:space-y-6 sm:p-8">
<h1 <h1 class="text-xl font-bold leading-tight tracking-tight tmd:text-2xl text-gray-900 dark:text-white">Sign in to your account</h1>
class="text-xl font-bold leading-tight tracking-tight tmd:text-2xl text-gray-900 dark:text-white" <form class="space-y-4 md:space-y-6" action={apiUri('/auth/login')} method="POST" on:submit|preventDefault={handleSubmit}
>
Sign in to your account
</h1>
<form
class="space-y-4 md:space-y-6"
action={apiUri('/auth/login')}
method="POST"
on:submit|preventDefault={handleSubmit}
> >
<div> <div>
<label <label for="username" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Username</label>
for="username" <input type="text" name="username" id="username" class="input" placeholder="username" required />
class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Username</label
>
<input
type="text"
name="username"
id="username"
class="input"
placeholder="username"
required
/>
</div> </div>
<div> <div>
<label <label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label>
for="password" <input type="password" name="password" id="password" placeholder="••••••••" class="input" required />
class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password</label
>
<input
type="password"
name="password"
id="password"
placeholder="••••••••"
class="input"
required
/>
</div> </div>
<button type="submit" class="btn variant-filled-primary w-full">Sign in</button> <button type="submit" class="btn variant-filled-primary w-full">Sign in</button>
<LightSwitch /> <LightSwitch />
</form> </form>
</div> </div>