71 lines
2.2 KiB
Vue
71 lines
2.2 KiB
Vue
<template>
|
||||
|
|
<div>
|
|||
|
|
<h1>تنظیمات سایت</h1>
|
|||
|
|
<form v-if="form" class="card" @submit.prevent="save">
|
|||
|
|
<div class="grid-2">
|
|||
|
|
<div class="field">
|
|||
|
|
<label class="label">نام برند</label>
|
|||
|
|
<input v-model="form.brandName" class="input" />
|
|||
|
|
</div>
|
|||
|
|
<div class="field">
|
|||
|
|
<label class="label">تگلاین</label>
|
|||
|
|
<input v-model="form.tagline" class="input" />
|
|||
|
|
</div>
|
|||
|
|
<div class="field">
|
|||
|
|
<label class="label">ایمیل</label>
|
|||
|
|
<input v-model="form.email" class="input" dir="ltr" />
|
|||
|
|
</div>
|
|||
|
|
<div class="field">
|
|||
|
|
<label class="label">تلفن</label>
|
|||
|
|
<input v-model="form.phone" class="input" dir="ltr" />
|
|||
|
|
</div>
|
|||
|
|
<div class="field">
|
|||
|
|
<label class="label">آدرس</label>
|
|||
|
|
<input v-model="form.address" class="input" />
|
|||
|
|
</div>
|
|||
|
|
<div class="field">
|
|||
|
|
<label class="label">Timezone</label>
|
|||
|
|
<input v-model="form.timezone" class="input" dir="ltr" />
|
|||
|
|
</div>
|
|||
|
|
<div class="field">
|
|||
|
|
<label class="label">لوگو URL</label>
|
|||
|
|
<input v-model="form.logoUrl" class="input" dir="ltr" />
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="field">
|
|||
|
|
<label class="label">شبکههای اجتماعی (JSON)</label>
|
|||
|
|
<textarea v-model="socialsText" class="textarea" dir="ltr" />
|
|||
|
|
</div>
|
|||
|
|
<p v-if="msg" class="muted">{{ msg }}</p>
|
|||
|
|
<button class="btn">ذخیره</button>
|
|||
|
|
</form>
|
|||
|
|
</div>
|
|||
|
|
</template>
|
|||
|
|
|
|||
|
|
<script setup lang="ts">
|
|||
|
|
import { onMounted, ref } from "vue";
|
|||
|
|
import { api } from "../lib/api";
|
|||
|
|
|
|||
|
|
const form = ref<any>(null);
|
|||
|
|
const socialsText = ref("[]");
|
|||
|
|
const msg = ref("");
|
|||
|
|
|
|||
|
|
onMounted(async () => {
|
|||
|
|
const { data } = await api.get("/admin/settings");
|
|||
|
|
form.value = data;
|
|||
|
|
socialsText.value = JSON.stringify(data.socials ?? [], null, 2);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
async function save() {
|
|||
|
|
msg.value = "";
|
|||
|
|
try {
|
|||
|
|
form.value.socials = JSON.parse(socialsText.value);
|
|||
|
|
const { data } = await api.put("/admin/settings", form.value);
|
|||
|
|
form.value = data;
|
|||
|
|
msg.value = "ذخیره شد.";
|
|||
|
|
} catch {
|
|||
|
|
msg.value = "خطا در ذخیره یا JSON نامعتبر.";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
</script>
|