Newer
Older
bugtrail / packages / web / src / pages / SettingsPage.vue
<script setup lang="ts">
import { ref } from "vue";
import { useI18n } from "vue-i18n";
import { GnCard, GnSelect, GnAvatar } from "gnexus-ui-kit/vue";
import { SUPPORTED_LOCALES, setLocale, type Locale } from "../i18n";
import { useAuth } from "../stores/auth";
import AppShell from "../components/AppShell.vue";

const { t, locale } = useI18n();
const auth = useAuth();

const language = ref(locale.value as Locale);
const languageOptions = SUPPORTED_LOCALES.map((l) => ({
  value: l,
  label: l === "en" ? "English" : "Русский",
}));

function onLanguageChange(value: string) {
  language.value = value as Locale;
  setLocale(language.value);
}
</script>

<template>
  <AppShell>
    <h1 class="settings-title">{{ t("settings.title") }}</h1>

    <GnCard class="settings-card">
      <h2 class="settings-card-title">{{ t("settings.profile") }}</h2>
      <div v-if="auth.user.value" class="settings-profile">
        <GnAvatar :name="auth.user.value.nickname" />
        <div class="settings-profile-info">
          <span class="settings-profile-name">{{ auth.user.value.nickname }}</span>
          <span class="settings-profile-email">{{ auth.user.value.email }}</span>
        </div>
      </div>
    </GnCard>

    <GnCard class="settings-card">
      <h2 class="settings-card-title">{{ t("settings.language") }}</h2>
      <GnSelect
        :model-value="language"
        :options="languageOptions"
        icon="ph-globe"
        @update:model-value="onLanguageChange"
      />
      <p class="settings-hint">{{ t("settings.languageHint") }}</p>
    </GnCard>
  </AppShell>
</template>

<style scoped>
.settings-title {
  font-size: 20px;
  margin: 0 0 16px;
}
.settings-card {
  padding: 18px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 560px;
}
.settings-card-title {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.6;
}
.settings-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-profile-info {
  display: flex;
  flex-direction: column;
  margin-right: auto;
}
.settings-profile-name {
  font-weight: 600;
}
.settings-profile-email {
  font-size: 12px;
  opacity: 0.7;
}
.settings-hint {
  margin: 0;
  font-size: 12px;
  opacity: 0.5;
}
</style>