RecipeSettingsSwitches use v-model instead of prop and turn into script setup

This commit is contained in:
Kuchenpirat 2025-06-19 10:20:12 +00:00
commit 4ce1f5c926

View file

@ -1,9 +1,9 @@
<template> <template>
<div> <div>
<v-switch <v-switch
v-for="(_, key) in modelValue" v-for="(_, key) in model"
:key="key" :key="key"
v-model="modelValue[key]" v-model="model[key]"
color="primary" color="primary"
xs xs
density="compact" density="compact"
@ -15,21 +15,15 @@
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineModel, defineProps } from "vue";
import type { RecipeSettings } from "~/lib/api/types/recipe"; import type { RecipeSettings } from "~/lib/api/types/recipe";
import { useI18n } from "#imports";
defineProps<{ isOwner?: boolean }>();
const model = defineModel<RecipeSettings>({ required: true });
export default defineNuxtComponent({
props: {
modelValue: {
type: Object as () => RecipeSettings,
required: true,
},
isOwner: {
type: Boolean,
required: false,
},
},
setup() {
const i18n = useI18n(); const i18n = useI18n();
const labels: Record<keyof RecipeSettings, string> = { const labels: Record<keyof RecipeSettings, string> = {
public: i18n.t("recipe.public-recipe"), public: i18n.t("recipe.public-recipe"),
@ -40,12 +34,6 @@ export default defineNuxtComponent({
disableAmount: i18n.t("recipe.disable-amount"), disableAmount: i18n.t("recipe.disable-amount"),
locked: i18n.t("recipe.locked"), locked: i18n.t("recipe.locked"),
}; };
return {
labels,
};
},
});
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>