fix: create Account Page
This commit is contained in:
@@ -86,10 +86,10 @@ export const useAddressStore = defineStore('address', () => {
|
||||
|
||||
function updateAddress(id: number, formData: AddressFormData): boolean {
|
||||
const index = addresses.value.findIndex(a => a.id === id)
|
||||
if (index === -1) return false
|
||||
if (index === -1) return false
|
||||
|
||||
const existing = addresses.value[index]
|
||||
if (!existing) return false
|
||||
if (!existing) return false
|
||||
|
||||
addresses.value[index] = {
|
||||
id: existing.id,
|
||||
|
||||
@@ -77,14 +77,42 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
password: string,
|
||||
confirm_password: string,
|
||||
lang?: string,
|
||||
company_name?: string,
|
||||
company_email?: string,
|
||||
company_address?: {
|
||||
street: string
|
||||
zipCode: string
|
||||
city: string
|
||||
country: string
|
||||
},
|
||||
regon?: string,
|
||||
nip?: string,
|
||||
vat?: string,
|
||||
billing_address?: {
|
||||
street: string
|
||||
zipCode: string
|
||||
city: string
|
||||
country: string
|
||||
},
|
||||
) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const body: any = { first_name, last_name, email, password, confirm_password, lang: lang || 'en' }
|
||||
|
||||
// Add company information if provided
|
||||
if (company_name) body.company_name = company_name
|
||||
if (company_email) body.company_email = company_email
|
||||
if (company_address) body.company_address = company_address
|
||||
if (regon) body.regon = regon
|
||||
if (nip) body.nip = nip
|
||||
if (vat) body.vat = vat
|
||||
if (billing_address) body.billing_address = billing_address
|
||||
|
||||
await useFetchJson('/api/v1/public/auth/register', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ first_name, last_name, email, password, confirm_password, lang: lang || 'en' }),
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
|
||||
return { success: true, requiresVerification: true }
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface CartItem {
|
||||
image: string
|
||||
price: number
|
||||
quantity: number
|
||||
product_number:string
|
||||
product_number: string
|
||||
}
|
||||
|
||||
export interface DeliveryMethod {
|
||||
@@ -24,7 +24,7 @@ export const useCartStore = defineStore('cart', () => {
|
||||
const selectedDeliveryMethodId = ref<number | null>(null)
|
||||
const shippingCost = ref(0)
|
||||
const vatRate = ref(0.23) // 23% VAT
|
||||
|
||||
const currentPage = ref(1)
|
||||
const deliveryMethods = ref<DeliveryMethod[]>([
|
||||
{ id: 1, name: 'Standard Delivery', price: 0, description: '5-7 business days' },
|
||||
{ id: 2, name: 'Express Delivery', price: 15, description: '2-3 business days' },
|
||||
@@ -66,7 +66,20 @@ export const useCartStore = defineStore('cart', () => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function deleteProduct(id: number): boolean {
|
||||
const index = items.value.findIndex(a => a.id === id)
|
||||
if (index === -1) return false
|
||||
|
||||
items.value.splice(index, 1)
|
||||
resetProductPagination()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
function resetProductPagination() {
|
||||
currentPage.value = 1
|
||||
}
|
||||
|
||||
function removeItem(itemId: number) {
|
||||
const index = items.value.findIndex(i => i.id === itemId)
|
||||
if (index !== -1) {
|
||||
@@ -106,6 +119,7 @@ export const useCartStore = defineStore('cart', () => {
|
||||
vatAmount,
|
||||
orderTotal,
|
||||
itemCount,
|
||||
deleteProduct,
|
||||
updateQuantity,
|
||||
removeItem,
|
||||
clearCart,
|
||||
|
||||
46
bo/src/stores/customer.ts
Normal file
46
bo/src/stores/customer.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import type { Address } from './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
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user