moves bio to settings
This commit is contained in:
@@ -5,6 +5,7 @@ import type { Settings } from "../settings";
|
||||
const SettingsCreateSchema = z.object({
|
||||
unit: z.enum(["metric", "imperial"]).optional(),
|
||||
language: z.enum(["en", "de", "es", "fr", "hu", "it", "nl", "pl", "pt", "zh"]).optional(),
|
||||
bio: z.string().optional(),
|
||||
mapFocus: z.enum(["trails", "location"]).optional(),
|
||||
location: z.object({
|
||||
name: z.string(),
|
||||
|
||||
@@ -18,7 +18,6 @@ const UserUpdateSchema = (z.object({
|
||||
password: z.string().min(8, "must-be-at-least-n-characters-long").optional(),
|
||||
oldPassword: z.string().min(8, "must-be-at-least-n-characters-long").optional(),
|
||||
passwordConfirm: z.string().min(8, "must-be-at-least-n-characters-long").optional(),
|
||||
bio: z.string().optional()
|
||||
}) satisfies ZodType<Partial<User>>).refine((data) => data.password === data.passwordConfirm, {
|
||||
message: "passwords-must-match",
|
||||
path: ["passwordConfirm"],
|
||||
|
||||
@@ -4,6 +4,7 @@ class Settings {
|
||||
id?: string;
|
||||
unit?: "metric" | "imperial";
|
||||
language?: "en" | "de" | "es" | "fr" | "hu" | "it" | "nl" | "pl" | "pt" | "zh";
|
||||
bio?: string;
|
||||
mapFocus?: "trails" | "location";
|
||||
location?: { name: string, lat: number, lon: number };
|
||||
category?: string;
|
||||
|
||||
@@ -14,7 +14,6 @@ export type UserAnonymous = {
|
||||
id: string,
|
||||
username?: string,
|
||||
avatar?: string;
|
||||
bio?: string;
|
||||
created?: string;
|
||||
private: boolean;
|
||||
}
|
||||
@@ -46,14 +46,14 @@
|
||||
<h4 class="text-xl font-semibold">
|
||||
{$_("about")}
|
||||
{data.user.username}
|
||||
{#if data.isOwnProfile && data.user.bio?.length}
|
||||
{#if data.isOwnProfile && data.settings.bio?.length}
|
||||
<a class="ml-4" href="/settings/profile"
|
||||
><i class="fa fa-pen text-base"></i></a
|
||||
>
|
||||
{/if}
|
||||
</h4>
|
||||
{#if data.user.bio?.length}
|
||||
<p class="whitespace-pre-wrap text-sm">{data.user.bio}</p>
|
||||
{#if data.settings.bio?.length}
|
||||
<p class="whitespace-pre-wrap text-sm">{data.settings.bio}</p>
|
||||
{:else if data.isOwnProfile}
|
||||
<a class="btn-primary inline-block" href="/settings/profile"
|
||||
>+ {$_("add-bio")}</a
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
let selectedCategory =
|
||||
$page.data.settings?.category || data.categories[0].id;
|
||||
|
||||
let bio = $currentUser?.bio ?? "";
|
||||
let bio = data.settings?.bio ?? "";
|
||||
|
||||
const categoryItems: SelectItem[] = data.categories.map((c: Category) => ({
|
||||
text: $_(c.name),
|
||||
@@ -43,12 +43,12 @@
|
||||
}
|
||||
|
||||
async function handleBioSave() {
|
||||
if (!$currentUser) {
|
||||
if (!data.settings) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$currentUser.bio = bio;
|
||||
await users_update($currentUser);
|
||||
data.settings.bio = bio;
|
||||
await settings_update(data.settings);
|
||||
} catch (e) {
|
||||
show_toast({
|
||||
type: "error",
|
||||
@@ -111,7 +111,7 @@
|
||||
<Button
|
||||
on:click={() => handleBioSave()}
|
||||
primary
|
||||
disabled={$currentUser.bio === bio}>{$_("save")}</Button
|
||||
disabled={data.settings.bio === bio}>{$_("save")}</Button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user