chore: install prettier

This commit is contained in:
Viet An
2026-05-04 15:22:27 +07:00
parent 93d29ca7d8
commit bd58e2b847
267 changed files with 22950 additions and 13581 deletions

View File

@@ -3,7 +3,7 @@
<p class="">
Bạn chắc chắn muốn chuyển sản phẩm này sang trạng thái<br />
<strong :class="newStatus === 2 ? 'has-text-success' : 'has-text-danger'">
{{ newStatus === 2 ? 'ĐANG BÁN' : 'KHÓA' }}
{{ newStatus === 2 ? "ĐANG BÁN" : "KHÓA" }}
</strong>
không?
</p>
@@ -12,15 +12,23 @@
<div class="field is-grouped is-grouped-centered">
<div class="control">
<button class="button " :class="newStatus === 2 ? 'is-success' : 'is-danger'" :disabled="isSaving"
@click="confirmChange">
<button
class="button"
:class="newStatus === 2 ? 'is-success' : 'is-danger'"
:disabled="isSaving"
@click="confirmChange"
>
<span v-if="isSaving">Đang xử lý...</span>
<span v-else>Đồng ý</span>
</button>
</div>
<div class="control">
<button class="button is-dark " :disabled="isSaving" @click="close">
<button
class="button is-dark"
:disabled="isSaving"
@click="close"
>
Hủy bỏ
</button>
</div>
@@ -29,70 +37,70 @@
</template>
<script setup>
import { ref, computed } from 'vue'
import { useNuxtApp } from '#app'
import { ref, computed } from "vue";
import { useNuxtApp } from "#app";
const emit = defineEmits(['close', 'modalevent'])
const emit = defineEmits(["close", "modalevent"]);
const props = defineProps({
product: {
type: Object,
required: true
}
})
required: true,
},
});
const { $patchapi, $snackbar } = useNuxtApp()
const { $patchapi, $snackbar } = useNuxtApp();
const isSaving = ref(false)
const isSaving = ref(false);
const currentStatus = computed(() => Number(props.product?.status) || null)
const newStatus = computed(() => (currentStatus.value === 15 ? 2 : 15))
const currentStatus = computed(() => Number(props.product?.status) || null);
const newStatus = computed(() => (currentStatus.value === 15 ? 2 : 15));
async function confirmChange() {
if (!props.product?.id || newStatus.value === currentStatus.value) {
close()
return
close();
return;
}
isSaving.value = true
isSaving.value = true;
try {
const result = await $patchapi(
'product',
"product",
{
id: props.product.id,
status: newStatus.value
status: newStatus.value,
},
{},
false
)
false,
);
if (result === 'error' || !result) {
$snackbar('Cập nhật thất bại', 'Lỗi', 'Error')
return
if (result === "error" || !result) {
$snackbar("Cập nhật thất bại", "Lỗi", "Error");
return;
}
$snackbar('Cập nhật trạng thái thành công', 'Thành công', 'Success')
$snackbar("Cập nhật trạng thái thành công", "Thành công", "Success");
// Phát sự kiện để component cha (hoặc bảng) cập nhật lại dữ liệu
emit('modalevent', {
name: 'update',
emit("modalevent", {
name: "update",
data: {
id: props.product.id,
status: newStatus.value
}
})
status: newStatus.value,
},
});
close()
close();
} catch (error) {
console.error('Lỗi đổi trạng thái:', error)
$snackbar('Có lỗi xảy ra', 'Lỗi', 'Error')
console.error("Lỗi đổi trạng thái:", error);
$snackbar("Có lỗi xảy ra", "Lỗi", "Error");
} finally {
isSaving.value = false
isSaving.value = false;
}
}
function close() {
emit('close')
emit("close");
}
</script>
</script>