feat: B2B wholesale pricing per product & discount setting, dynamic payment gateways enable/disable & coming soon badges, B2B phone verification, trust seals menu link, dynamic contact info
Deploy Canina / deploy (push) Failing after 15s
Deploy Canina / deploy (push) Failing after 15s
This commit is contained in:
1 parent
f8e9ebfc44
commit
7bf6c47ee6
6 files changed
+292
-62
No files matched your search
@@ -3,6 +3,7 @@ import React, { useState, useEffect } from "react";
|
||||
import { Product } from "../lib/data/products";
|
||||
import { useCartStore } from "../lib/store/cartStore";
|
||||
import { useUserStore } from "../lib/store/userStore";
|
||||
import { useSettingsStore } from "../lib/store/settingsStore";
|
||||
import { productService } from "../lib/services/productService";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import {
|
||||
@@ -127,27 +128,29 @@ export default function B2BPortal({ onClose }: { onClose: () => void }) {
|
||||
</p>
|
||||
|
||||
{!isWholesaleVerified && (
|
||||
<div className="bg-white/10 p-4 rounded-2xl border border-white/20 mt-4">
|
||||
<h4 className="text-xs font-black mb-2 text-amber-300">درخواست تایید حساب همکار</h4>
|
||||
<p className="text-[11px] text-white/80 mb-3">جهت مشاهده و خرید با قیمت عمده، شماره پروانه نظام دامپزشکی خود را وارد کنید.</p>
|
||||
<div className="bg-white/10 p-4 rounded-2xl border border-white/20 mt-4 font-vazir">
|
||||
<h4 className="text-xs font-black mb-2 text-amber-300">درخواست مشاوره و عضویت همکار B2B</h4>
|
||||
<p className="text-[11px] text-white/80 mb-3 leading-relaxed">
|
||||
جهت دریافت شرایط همکاری و فعالسازی دسترسی خرید عمده، شماره تماس خود را وارد کنید تا کارشناسان فروش با شما تماس بگیرند.
|
||||
</p>
|
||||
<form onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
const form = e.target as HTMLFormElement;
|
||||
const bName = (form.elements.namedItem('bName') as HTMLInputElement).value;
|
||||
const lNum = (form.elements.namedItem('lNum') as HTMLInputElement).value;
|
||||
const phone = (form.elements.namedItem('phone') as HTMLInputElement).value;
|
||||
try {
|
||||
const api = (await import('../lib/services/api')).default;
|
||||
await api.post('/wholesale/apply', { businessName: bName, licenseNumber: lNum });
|
||||
alert('درخواست ثبتنام همکار با موفقیت ارسال شد و به زودی توسط ادمین تایید میشود.');
|
||||
await api.post('/wholesale/apply', { businessName: bName, licenseNumber: phone });
|
||||
alert('درخواست شما با موفقیت ثبت شد. کارشناسان پشتیبانی B2B کانینا به زودی جهت تایید تلفنی با شما تماس خواهند گرفت.');
|
||||
form.reset();
|
||||
} catch (err) {
|
||||
alert('لطفاً ابتدا وارد حساب کاربری خود شوید.');
|
||||
alert('خطا در ثبت درخواست. لطفاً دوباره تلاش کنید.');
|
||||
}
|
||||
}} className="space-y-2">
|
||||
<input name="bName" required placeholder="نام کلینیک / داروخانه" className="w-full bg-white/20 text-white text-xs px-3 py-2 rounded-xl outline-none placeholder:text-white/50" />
|
||||
<input name="lNum" required placeholder="شماره پروانه / نظام" className="w-full bg-white/20 text-white text-xs px-3 py-2 rounded-xl outline-none placeholder:text-white/50" />
|
||||
<button type="submit" className="w-full bg-amber-400 hover:bg-amber-500 text-gray-900 font-black text-xs py-2 rounded-xl transition-colors">
|
||||
ثبت درخواست همکار
|
||||
<input name="bName" required placeholder="نام مجموعه / کلینیک / داروخانه" className="w-full bg-white/20 text-white text-xs px-3 py-2.5 rounded-xl outline-none placeholder:text-white/50" />
|
||||
<input name="phone" required type="tel" placeholder="شماره تماس همراه" className="w-full bg-white/20 text-white text-xs px-3 py-2.5 rounded-xl outline-none placeholder:text-white/50 dir-ltr text-right" />
|
||||
<button type="submit" className="w-full bg-amber-400 hover:bg-amber-500 text-gray-900 font-black text-xs py-2.5 rounded-xl transition-colors">
|
||||
ثبت درخواست تماس و تایید B2B
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -209,7 +212,11 @@ export default function B2BPortal({ onClose }: { onClose: () => void }) {
|
||||
<tbody className="divide-y divide-medical-gray-100">
|
||||
{filteredProducts.map(product => {
|
||||
const basePrice = product.priceValue || 0;
|
||||
const wholesalePrice = basePrice * 0.7; // 30% discount
|
||||
// Priority 1: Specific product wholesalePrice, Priority 2: General settings percentage discount (default 30%)
|
||||
const wholesaleDiscountPercent = Number(useSettingsStore.getState().getText('B2B_DISCOUNT_PERCENT', '30')) || 30;
|
||||
const wholesalePrice = (product as any).wholesalePrice
|
||||
? Number((product as any).wholesalePrice)
|
||||
: Math.round(basePrice * (1 - wholesaleDiscountPercent / 100));
|
||||
return (
|
||||
<tr key={product.id} className="hover:bg-medical-gray-50/50 transition-colors">
|
||||
<td className="px-6 py-4">
|
||||
|
||||
Reference in new issue
Block a user