скрытие магазина

This commit is contained in:
2026-07-28 14:47:07 +04:00
parent 373649c3d2
commit 66251ede8e
15 changed files with 169 additions and 172 deletions
+38 -1
View File
@@ -1,5 +1,5 @@
<script setup>
import { Head, router } from '@inertiajs/vue3';
import { Head, router, useForm } from '@inertiajs/vue3';
import AdminLayout from '../../Layouts/AdminLayout.vue';
import CategoryForm from './Components/CategoryForm.vue';
import ProductForm from './Components/ProductForm.vue';
@@ -14,9 +14,15 @@ const props = defineProps({
products: { type: Array, default: () => [] },
categoryStoreUrl: { type: String, required: true },
productStoreUrl: { type: String, required: true },
shopEnabled: { type: Boolean, required: true },
availabilityUpdateUrl: { type: String, required: true },
productTypes: { type: Array, required: true },
});
const availabilityForm = useForm({
enabled: props.shopEnabled,
});
const stats = [
{ label: 'Категории', value: props.categories.length },
{ label: 'Позиции', value: props.products.length },
@@ -28,6 +34,17 @@ function destroy(url, message) {
router.delete(url, { preserveScroll: true });
}
}
function updateAvailability(event) {
const previousValue = !event.target.checked;
availabilityForm.patch(props.availabilityUpdateUrl, {
preserveScroll: true,
onError: () => {
availabilityForm.enabled = previousValue;
},
});
}
</script>
<template>
@@ -46,6 +63,26 @@ function destroy(url, message) {
<div class="admin-page wrap">
<section class="admin-section">
<StatCards :items="stats" />
<article class="portal-card admin-panel corners">
<span class="admin-kicker">Глобальная доступность</span>
<h2 class="h-serif">Магазин и пополнение</h2>
<p>
При выключении игровой магазин становится недоступен, а форма пополнения скрывается в личном кабинете.
</p>
<label class="admin-check">
<input
v-model="availabilityForm.enabled"
type="checkbox"
:disabled="availabilityForm.processing"
@change="updateAvailability"
/>
<span class="admin-check__box"></span>
<span>{{ availabilityForm.enabled ? 'Доступны' : 'Выключены' }}</span>
</label>
<small v-if="availabilityForm.errors.enabled" class="admin-field-error">
{{ availabilityForm.errors.enabled }}
</small>
</article>
<div class="admin-notice">
Изменения записываются прямо в базу <code>store</code>. После сохранения перезагрузи данные магазина командой модуля или перезапусти worldserver.
</div>