fix(orders,wallet): implement full-stack wallet deduction in PostgreSQL and sync charity donation total in user profile
This commit is contained in:
1 parent
51b2f811fa
commit
377ec7fb34
7 files changed
+76
-18
No files matched your search
@@ -41,6 +41,7 @@ export class OrderService {
|
||||
couponCode?: string;
|
||||
prescriptionUrl?: string;
|
||||
charityDonation?: number;
|
||||
paymentMethod?: string;
|
||||
isRefill?: boolean;
|
||||
refillIntervalDays?: number;
|
||||
shippingAddress?: string;
|
||||
|
||||
@@ -21,6 +21,8 @@ interface Order {
|
||||
items: CartItem[];
|
||||
total: number;
|
||||
charityDonation?: number;
|
||||
paymentMethod?: string;
|
||||
isRefill?: boolean;
|
||||
status: 'processing' | 'shipped' | 'delivered';
|
||||
petId?: string;
|
||||
shippingAddress?: string;
|
||||
@@ -39,7 +41,7 @@ interface CartStore {
|
||||
toggleSubscription: () => void;
|
||||
setCharityDonation: (amount: number) => void;
|
||||
applyCoupon: (code: string) => Promise<boolean>;
|
||||
addOrder: (order: Omit<Order, 'id' | 'date' | 'status' | 'trackingNumber'>) => Promise<string>;
|
||||
addOrder: (orderData: Omit<Order, 'id' | 'date' | 'status' | 'trackingNumber'>) => Promise<string>;
|
||||
clearCart: () => void;
|
||||
removeCoupon: () => void;
|
||||
setOrders: (orders: any[]) => void;
|
||||
@@ -104,6 +106,12 @@ export const useCartStore = create<CartStore>()(
|
||||
addOrder: async (orderData) => {
|
||||
const payload = {
|
||||
petId: orderData.petId,
|
||||
couponCode: get().coupon?.code,
|
||||
charityDonation: orderData.charityDonation,
|
||||
paymentMethod: orderData.paymentMethod,
|
||||
isRefill: orderData.isRefill || get().isSubscribed,
|
||||
refillIntervalDays: 60,
|
||||
shippingAddress: orderData.shippingAddress,
|
||||
items: orderData.items.map(i => ({
|
||||
productId: i.product.id,
|
||||
quantity: i.quantity
|
||||
|
||||
Reference in new issue
Block a user