This commit is contained in:
Viet An
2026-07-02 16:20:37 +07:00
parent 6d9dce38cb
commit 5e6cb7a551
10 changed files with 463 additions and 419 deletions

View File

@@ -2,10 +2,11 @@
import { isEqual } from "es-toolkit";
const props = defineProps({
customerId: Number,
address: Object,
});
const emit = defineEmits(["modalevent"]);
const emit = defineEmits(["modalevent", "close"]);
const { $insertapi, $patchapi } = useNuxtApp();
const addressRef = ref({ ...props.address });
@@ -13,11 +14,16 @@ const isLoading = ref(false);
async function submitAddress() {
isLoading.value = true;
const payload = {
...addressRef.value,
customer: props.customerId,
};
const res = props.address
? await $patchapi("Customer_Address", addressRef.value)
: await $insertapi("Customer_Address", addressRef.value);
? await $patchapi("Customer_Address", payload)
: await $insertapi("Customer_Address", { data: payload });
isLoading.value = false;
emit("modalevent", { name: "submit" });
emit("close");
}
const isDirty = computed(() => {