feat: add shipping address selection to checkout

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-09-26 12:53:39 +03:30
co-authored by Copilot
parent c0815a931a
commit c332b99130
70 changed files with 336 additions and 102 deletions
+7 -2
View File
@@ -119,7 +119,7 @@ export const useOrderStore = defineStore('order', () => {
* روش تسویه را انتخاب می‌کند.
* اقلام همه شرکت‌ها در یک فاکتور واحد ثبت می‌شوند.
*/
async function submitOrder(cart: Cart): Promise<Order> {
async function submitOrder(cart: Cart, shippingAddress?: string): Promise<Order> {
if (!cart.items.length) {
throw new Error('سبد خرید خالی است.')
}
@@ -134,12 +134,17 @@ export const useOrderStore = defineStore('order', () => {
throw new Error('شرکت سبد مشخص نیست. سبد را خالی کنید و دوباره اضافه کنید.')
}
const addressLine = shippingAddress?.trim()
? `آدرس ارسال: ${shippingAddress.trim()}`
: ''
const notes = [addressLine, cart.notes?.trim()].filter(Boolean).join('\n')
try {
const order = await apiRequest<Order>('/orders', {
method: 'POST',
body: {
companyId: companyIds[0],
notes: cart.notes,
notes: notes || undefined,
items: cart.items.map((item) => ({
productId: item.productId,
meterage: Number(item.meterage),