fix: store

This commit is contained in:
2026-04-03 11:32:04 +02:00
parent 68f31952da
commit b7c4b6e3fd
27 changed files with 22 additions and 22 deletions

View File

@@ -0,0 +1,46 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import type { Address } from './user/address'
export interface CustomerData {
companyName: string
companyEmail: string
companyAddress: string
regon: string
nip: string
vat: string
billingAddressId: number | null
companyAddressId: number | null
}
export const useCustomerStore = defineStore('customer', () => {
const customer = ref<CustomerData | null>(null)
const loading = ref(false)
const error = ref<string | null>(null)
const hasAccount = computed(() => customer.value !== null)
function setCustomer(data: CustomerData) {
customer.value = data
}
function clearCustomer() {
customer.value = null
}
function updateCustomer(data: Partial<CustomerData>) {
if (customer.value) {
customer.value = { ...customer.value, ...data }
}
}
return {
customer,
loading,
error,
hasAccount,
setCustomer,
clearCustomer,
updateCustomer
}
})