2024-08-22 10:14:32 -05:00
|
|
|
<template>
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-container v-if="household"
|
|
|
|
class="narrow-container"
|
|
|
|
>
|
2024-08-22 10:14:32 -05:00
|
|
|
<BasePageTitle class="mb-5">
|
|
|
|
<template #header>
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-img
|
|
|
|
width="100%"
|
|
|
|
max-height="100"
|
|
|
|
max-width="100"
|
|
|
|
:src="require('~/static/svgs/manage-group-settings.svg')"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<template #title>
|
|
|
|
{{ $t("profile.household-settings") }}
|
2024-08-22 10:14:32 -05:00
|
|
|
</template>
|
|
|
|
{{ $t("profile.household-description") }}
|
|
|
|
</BasePageTitle>
|
2024-09-17 10:48:14 -05:00
|
|
|
<v-form ref="refHouseholdEditForm" @submit.prevent="handleSubmit">
|
2025-06-20 00:09:12 +07:00
|
|
|
<v-card variant="outlined" style="border-color: lightgray;">
|
2024-09-17 10:48:14 -05:00
|
|
|
<v-card-text>
|
|
|
|
<HouseholdPreferencesEditor v-if="household.preferences" v-model="household.preferences" />
|
|
|
|
</v-card-text>
|
|
|
|
</v-card>
|
|
|
|
<div class="d-flex pa-2">
|
2025-06-20 00:09:12 +07:00
|
|
|
<BaseButton type="submit" edit class="ml-auto">
|
|
|
|
{{ $t("general.update") }}
|
|
|
|
</BaseButton>
|
2024-08-22 10:14:32 -05:00
|
|
|
</div>
|
2024-09-17 10:48:14 -05:00
|
|
|
</v-form>
|
2024-08-22 10:14:32 -05:00
|
|
|
</v-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2024-09-17 10:48:14 -05:00
|
|
|
import HouseholdPreferencesEditor from "~/components/Domain/Household/HouseholdPreferencesEditor.vue";
|
2024-08-22 10:14:32 -05:00
|
|
|
import { useHouseholdSelf } from "~/composables/use-households";
|
2025-06-20 00:09:12 +07:00
|
|
|
import type { ReadHouseholdPreferences } from "~/lib/api/types/household";
|
2024-09-17 10:48:14 -05:00
|
|
|
import { alert } from "~/composables/use-toast";
|
2025-06-20 00:09:12 +07:00
|
|
|
import type { VForm } from "~/types/auto-forms";
|
2024-08-22 10:14:32 -05:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
export default defineNuxtComponent({
|
2024-09-17 10:48:14 -05:00
|
|
|
components: {
|
|
|
|
HouseholdPreferencesEditor,
|
|
|
|
},
|
2025-06-20 00:09:12 +07:00
|
|
|
middleware: ["sidebase-auth", "can-manage-household-only"],
|
2024-08-22 10:14:32 -05:00
|
|
|
setup() {
|
|
|
|
const { household, actions: householdActions } = useHouseholdSelf();
|
2025-06-20 00:09:12 +07:00
|
|
|
const i18n = useI18n();
|
|
|
|
|
|
|
|
useSeoMeta({
|
|
|
|
title: i18n.t("household.household"),
|
|
|
|
});
|
2024-08-22 10:14:32 -05:00
|
|
|
|
2024-09-17 10:48:14 -05:00
|
|
|
const refHouseholdEditForm = ref<VForm | null>(null);
|
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
type Preference = {
|
|
|
|
key: keyof ReadHouseholdPreferences;
|
|
|
|
value: boolean;
|
|
|
|
label: string;
|
|
|
|
description: string;
|
|
|
|
};
|
2024-08-22 10:14:32 -05:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
const preferencesEditor = computed<Preference[]>(() => {
|
|
|
|
if (!household.value || !household.value.preferences) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
key: "recipePublic",
|
|
|
|
value: household.value.preferences.recipePublic || false,
|
|
|
|
label: i18n.t("household.allow-users-outside-of-your-household-to-see-your-recipes"),
|
|
|
|
description: i18n.t("household.allow-users-outside-of-your-household-to-see-your-recipes-description"),
|
|
|
|
} as Preference,
|
|
|
|
{
|
|
|
|
key: "recipeShowNutrition",
|
|
|
|
value: household.value.preferences.recipeShowNutrition || false,
|
|
|
|
label: i18n.t("group.show-nutrition-information"),
|
|
|
|
description: i18n.t("group.show-nutrition-information-description"),
|
|
|
|
} as Preference,
|
|
|
|
{
|
|
|
|
key: "recipeShowAssets",
|
|
|
|
value: household.value.preferences.recipeShowAssets || false,
|
|
|
|
label: i18n.t("group.show-recipe-assets"),
|
|
|
|
description: i18n.t("group.show-recipe-assets-description"),
|
|
|
|
} as Preference,
|
|
|
|
{
|
|
|
|
key: "recipeLandscapeView",
|
|
|
|
value: household.value.preferences.recipeLandscapeView || false,
|
|
|
|
label: i18n.t("group.default-to-landscape-view"),
|
|
|
|
description: i18n.t("group.default-to-landscape-view-description"),
|
|
|
|
} as Preference,
|
|
|
|
{
|
|
|
|
key: "recipeDisableComments",
|
|
|
|
value: household.value.preferences.recipeDisableComments || false,
|
|
|
|
label: i18n.t("group.disable-users-from-commenting-on-recipes"),
|
|
|
|
description: i18n.t("group.disable-users-from-commenting-on-recipes-description"),
|
|
|
|
} as Preference,
|
|
|
|
{
|
|
|
|
key: "recipeDisableAmount",
|
|
|
|
value: household.value.preferences.recipeDisableAmount || false,
|
|
|
|
label: i18n.t("group.disable-organizing-recipe-ingredients-by-units-and-food"),
|
|
|
|
description: i18n.t("group.disable-organizing-recipe-ingredients-by-units-and-food-description"),
|
|
|
|
} as Preference,
|
|
|
|
];
|
|
|
|
});
|
2024-08-22 10:14:32 -05:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
const allDays = [
|
|
|
|
{
|
|
|
|
name: i18n.t("general.sunday"),
|
|
|
|
value: 0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: i18n.t("general.monday"),
|
|
|
|
value: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: i18n.t("general.tuesday"),
|
|
|
|
value: 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: i18n.t("general.wednesday"),
|
|
|
|
value: 3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: i18n.t("general.thursday"),
|
|
|
|
value: 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: i18n.t("general.friday"),
|
|
|
|
value: 5,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: i18n.t("general.saturday"),
|
|
|
|
value: 6,
|
|
|
|
},
|
|
|
|
];
|
2024-08-22 10:14:32 -05:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
async function handleSubmit() {
|
|
|
|
if (!refHouseholdEditForm.value?.validate() || !household.value?.preferences) {
|
|
|
|
console.log(refHouseholdEditForm.value?.validate());
|
|
|
|
return;
|
|
|
|
}
|
2024-09-17 10:48:14 -05:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
const data = await householdActions.updatePreferences();
|
|
|
|
if (data) {
|
|
|
|
alert.success(i18n.t("settings.settings-updated"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
alert.error(i18n.t("settings.settings-update-failed"));
|
|
|
|
}
|
|
|
|
}
|
2024-09-17 10:48:14 -05:00
|
|
|
|
2025-06-20 00:09:12 +07:00
|
|
|
return {
|
|
|
|
household,
|
|
|
|
householdActions,
|
|
|
|
allDays,
|
|
|
|
preferencesEditor,
|
|
|
|
refHouseholdEditForm,
|
|
|
|
handleSubmit,
|
|
|
|
};
|
2024-08-22 10:14:32 -05:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="css">
|
|
|
|
.preference-container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
gap: 0.5rem;
|
|
|
|
max-width: 600px;
|
|
|
|
}
|
|
|
|
</style>
|