changes
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user