fix(ui): refactor percentage and suffix/prefix inputs to standard Input component with guaranteed padding isolation
This commit is contained in:
1 parent
c4e4a336d8
commit
a62bfb77b3
15 files changed
+11604
-11407
No files matched your search
@@ -8,6 +8,7 @@ import ConfirmModal from '../components/ui/ConfirmModal';
|
||||
import PriceInput from '../components/ui/PriceInput';
|
||||
import Button from '../components/ui/Button';
|
||||
import Modal from '../components/ui/Modal';
|
||||
import Input from '../components/ui/Input';
|
||||
|
||||
|
||||
export interface CouponTarget {
|
||||
@@ -423,20 +424,18 @@ function CouponModal({ formData, setFormData, onSave, onClose, isEditing }: Coup
|
||||
className="px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 text-xs"
|
||||
/>
|
||||
) : (
|
||||
<div className="relative">
|
||||
<input
|
||||
required
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
value={formData.value}
|
||||
onChange={(e) => setFormData({ ...formData, value: e.target.value })}
|
||||
dir="ltr"
|
||||
placeholder="مثال: ۲۰"
|
||||
className="w-full px-3 py-2.5 rounded-xl border border-gray-200 focus:border-purple-500 font-bold"
|
||||
/>
|
||||
<span className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 font-bold">%</span>
|
||||
</div>
|
||||
<Input
|
||||
required
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
value={formData.value}
|
||||
onChange={(e) => setFormData({ ...formData, value: e.target.value })}
|
||||
dir="ltr"
|
||||
placeholder="مثال: ۲۰"
|
||||
leftIcon={<span className="text-gray-400 font-bold text-xs">%</span>}
|
||||
className="font-bold"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,7 @@ import api from '../services/api';
|
||||
import Spinner from '../components/ui/Spinner';
|
||||
import PriceInput from '../components/ui/PriceInput';
|
||||
import Button from '../components/ui/Button';
|
||||
import Input from '../components/ui/Input';
|
||||
import type { FinancialSettings, PricingSettings } from '../types/admin';
|
||||
import { calculateSellingPrice } from '../utils/pricing';
|
||||
|
||||
@@ -153,19 +154,17 @@ export default function FinancialSettingsPage() {
|
||||
<Percent className="w-4 h-4 text-emerald-600" />
|
||||
<span>درصد مالیات بر ارزش افزوده (VAT) *</span>
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
required
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
value={financial.taxPercentage}
|
||||
onChange={(e) => setFinancial({ ...financial, taxPercentage: Number(e.target.value) })}
|
||||
className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-emerald-500 outline-none font-bold text-sm"
|
||||
dir="ltr"
|
||||
/>
|
||||
<span className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 font-bold">%</span>
|
||||
</div>
|
||||
<Input
|
||||
required
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
value={financial.taxPercentage}
|
||||
onChange={(e) => setFinancial({ ...financial, taxPercentage: Number(e.target.value) })}
|
||||
leftIcon={<span className="text-gray-400 font-bold text-xs">%</span>}
|
||||
dir="ltr"
|
||||
className="font-bold text-sm"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">درصد قانونی محاسبه مالیات بر ارزش افزوده در فاکتور نهایی سفارشات.</p>
|
||||
</div>
|
||||
|
||||
@@ -255,18 +254,17 @@ export default function FinancialSettingsPage() {
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1.5">
|
||||
درصد پاداش رزرو تمدید (Cashback Reward Percent)
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
value={refillPercent}
|
||||
onChange={(e) => setRefillPercent(e.target.value)}
|
||||
className="w-full px-4 py-2.5 rounded-xl border border-gray-200 focus:border-indigo-500 outline-none font-bold text-xs"
|
||||
dir="ltr"
|
||||
/>
|
||||
<span className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 font-bold text-xs">%</span>
|
||||
</div>
|
||||
<Input
|
||||
type="number"
|
||||
min="1"
|
||||
max="100"
|
||||
value={refillPercent}
|
||||
onChange={(e) => setRefillPercent(e.target.value)}
|
||||
leftIcon={<span className="text-gray-400 font-bold text-xs">%</span>}
|
||||
dir="ltr"
|
||||
inputSize="sm"
|
||||
className="font-bold"
|
||||
/>
|
||||
<p className="text-[11px] text-gray-400 mt-1">پیشفرض: ۵ درصد</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -374,19 +372,17 @@ export default function FinancialSettingsPage() {
|
||||
<label className="block text-xs font-bold text-gray-800 mb-1.5">
|
||||
درصد سود پیشفرض تکفروشی (Retail Margin %)
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
max="500"
|
||||
step="0.5"
|
||||
value={pricing.defaultRetailMarginPercent}
|
||||
onChange={(e) => setPricing({ ...pricing, defaultRetailMarginPercent: Number(e.target.value) || 0 })}
|
||||
className="w-full px-4 py-2.5 bg-white rounded-xl border border-indigo-200 focus:border-indigo-600 outline-none font-bold text-sm"
|
||||
dir="ltr"
|
||||
/>
|
||||
<span className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 font-bold text-xs">%</span>
|
||||
</div>
|
||||
<Input
|
||||
type="number"
|
||||
min="0"
|
||||
max="500"
|
||||
step="0.5"
|
||||
value={pricing.defaultRetailMarginPercent}
|
||||
onChange={(e) => setPricing({ ...pricing, defaultRetailMarginPercent: Number(e.target.value) || 0 })}
|
||||
leftIcon={<span className="text-gray-400 font-bold text-xs">%</span>}
|
||||
dir="ltr"
|
||||
className="font-bold text-sm"
|
||||
/>
|
||||
<p className="text-[11px] text-gray-500 mt-1">فرمول: قیمت خرید × (۱ + سود٪)</p>
|
||||
</div>
|
||||
|
||||
@@ -395,19 +391,17 @@ export default function FinancialSettingsPage() {
|
||||
<label className="block text-xs font-bold text-gray-800 mb-1.5">
|
||||
درصد سود پیشفرض عمدهفروشی (Wholesale Margin %)
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
max="500"
|
||||
step="0.5"
|
||||
value={pricing.defaultWholesaleMarginPercent}
|
||||
onChange={(e) => setPricing({ ...pricing, defaultWholesaleMarginPercent: Number(e.target.value) || 0 })}
|
||||
className="w-full px-4 py-2.5 bg-white rounded-xl border border-indigo-200 focus:border-indigo-600 outline-none font-bold text-sm"
|
||||
dir="ltr"
|
||||
/>
|
||||
<span className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 font-bold text-xs">%</span>
|
||||
</div>
|
||||
<Input
|
||||
type="number"
|
||||
min="0"
|
||||
max="500"
|
||||
step="0.5"
|
||||
value={pricing.defaultWholesaleMarginPercent}
|
||||
onChange={(e) => setPricing({ ...pricing, defaultWholesaleMarginPercent: Number(e.target.value) || 0 })}
|
||||
leftIcon={<span className="text-gray-400 font-bold text-xs">%</span>}
|
||||
dir="ltr"
|
||||
className="font-bold text-sm"
|
||||
/>
|
||||
<p className="text-[11px] text-gray-500 mt-1">برای مشتریان همکار و داروخانههای دامپزشکی B2B</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -37,6 +37,7 @@ import MediaSelector from '../components/ui/MediaSelector';
|
||||
import ConfirmModal from '../components/ui/ConfirmModal';
|
||||
import PriceInput from '../components/ui/PriceInput';
|
||||
import Button from '../components/ui/Button';
|
||||
import Input from '../components/ui/Input';
|
||||
import RichTextEditor from '../components/ui/RichTextEditor';
|
||||
import type { PricingSettings } from '../types/admin';
|
||||
import {
|
||||
@@ -1348,8 +1349,8 @@ export default function Products() {
|
||||
className="px-3 py-3 rounded-xl border border-gray-200 focus:border-purple-500 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-2 relative">
|
||||
<input
|
||||
<div className="col-span-2">
|
||||
<Input
|
||||
type="number"
|
||||
placeholder="٪ سود"
|
||||
value={formData.priceValueMarginPercent}
|
||||
@@ -1374,10 +1375,10 @@ export default function Products() {
|
||||
priceDisplay: `${Number(pPrice || 0).toLocaleString('fa-IR')} تومان`,
|
||||
});
|
||||
}}
|
||||
className="w-full px-2 py-3 rounded-xl border border-purple-200 focus:border-purple-500 text-center font-bold text-xs bg-purple-50/30 outline-none"
|
||||
leftIcon={<span className="text-gray-400 font-bold text-xs">%</span>}
|
||||
dir="ltr"
|
||||
className="font-bold text-xs bg-purple-50/30 border-purple-200"
|
||||
/>
|
||||
<span className="absolute left-2 top-1/2 -translate-y-1/2 text-gray-400 text-xs pointer-events-none">٪</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1406,8 +1407,8 @@ export default function Products() {
|
||||
className="px-3 py-3 rounded-xl border border-purple-200 focus:border-purple-600 bg-purple-50/20 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-2 relative">
|
||||
<input
|
||||
<div className="col-span-2">
|
||||
<Input
|
||||
type="number"
|
||||
placeholder="٪ سود"
|
||||
value={formData.wholesaleMarginPercent}
|
||||
@@ -1431,10 +1432,10 @@ export default function Products() {
|
||||
wholesalePrice: wPrice,
|
||||
});
|
||||
}}
|
||||
className="w-full px-2 py-3 rounded-xl border border-purple-200 focus:border-purple-500 text-center font-bold text-xs bg-purple-50/30 outline-none"
|
||||
leftIcon={<span className="text-gray-400 font-bold text-xs">%</span>}
|
||||
dir="ltr"
|
||||
className="font-bold text-xs bg-purple-50/30 border-purple-200"
|
||||
/>
|
||||
<span className="absolute left-2 top-1/2 -translate-y-1/2 text-gray-400 text-xs pointer-events-none">٪</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2833,19 +2834,17 @@ export default function Products() {
|
||||
مقدار تغییر {bulkAdjustForm.adjustmentType === 'PERCENT' ? '(درصد)' : '(تومان)'}:
|
||||
</label>
|
||||
{bulkAdjustForm.adjustmentType === 'PERCENT' ? (
|
||||
<div className="relative">
|
||||
<input
|
||||
type="number"
|
||||
min="0.1"
|
||||
max="200"
|
||||
step="0.5"
|
||||
value={bulkAdjustForm.value}
|
||||
onChange={(e) => setBulkAdjustForm({ ...bulkAdjustForm, value: Number(e.target.value) || 0 })}
|
||||
className="w-full px-4 py-2.5 bg-white rounded-xl border border-gray-200 focus:border-purple-500 outline-none text-sm font-bold"
|
||||
dir="ltr"
|
||||
/>
|
||||
<span className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 font-bold text-xs">%</span>
|
||||
</div>
|
||||
<Input
|
||||
type="number"
|
||||
min="0.1"
|
||||
max="200"
|
||||
step="0.5"
|
||||
value={bulkAdjustForm.value}
|
||||
onChange={(e) => setBulkAdjustForm({ ...bulkAdjustForm, value: Number(e.target.value) || 0 })}
|
||||
leftIcon={<span className="text-gray-400 font-bold text-xs">%</span>}
|
||||
dir="ltr"
|
||||
className="text-sm font-bold"
|
||||
/>
|
||||
) : (
|
||||
<PriceInput
|
||||
value={String(bulkAdjustForm.value)}
|
||||
@@ -2993,19 +2992,17 @@ export default function Products() {
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1.5">
|
||||
درصد سود تکفروشی جدید:
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
max="500"
|
||||
step="0.5"
|
||||
value={globalMarginForm.retailMarginPercent}
|
||||
onChange={(e) => setGlobalMarginForm({ ...globalMarginForm, retailMarginPercent: Number(e.target.value) || 0 })}
|
||||
className="w-full px-4 py-2.5 bg-white rounded-xl border border-gray-200 focus:border-purple-500 outline-none text-sm font-bold"
|
||||
dir="ltr"
|
||||
/>
|
||||
<span className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 font-bold text-xs">%</span>
|
||||
</div>
|
||||
<Input
|
||||
type="number"
|
||||
min="0"
|
||||
max="500"
|
||||
step="0.5"
|
||||
value={globalMarginForm.retailMarginPercent}
|
||||
onChange={(e) => setGlobalMarginForm({ ...globalMarginForm, retailMarginPercent: Number(e.target.value) || 0 })}
|
||||
leftIcon={<span className="text-gray-400 font-bold text-xs">%</span>}
|
||||
dir="ltr"
|
||||
className="text-sm font-bold"
|
||||
/>
|
||||
<p className="text-[11px] text-gray-400 mt-1">پیشفرض سیستم: {pricingSettings.defaultRetailMarginPercent}٪</p>
|
||||
</div>
|
||||
|
||||
@@ -3014,19 +3011,17 @@ export default function Products() {
|
||||
<label className="block text-xs font-bold text-gray-700 mb-1.5">
|
||||
درصد سود عمدهفروشی (B2B) جدید:
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
max="500"
|
||||
step="0.5"
|
||||
value={globalMarginForm.wholesaleMarginPercent}
|
||||
onChange={(e) => setGlobalMarginForm({ ...globalMarginForm, wholesaleMarginPercent: Number(e.target.value) || 0 })}
|
||||
className="w-full px-4 py-2.5 bg-white rounded-xl border border-gray-200 focus:border-purple-500 outline-none text-sm font-bold"
|
||||
dir="ltr"
|
||||
/>
|
||||
<span className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 font-bold text-xs">%</span>
|
||||
</div>
|
||||
<Input
|
||||
type="number"
|
||||
min="0"
|
||||
max="500"
|
||||
step="0.5"
|
||||
value={globalMarginForm.wholesaleMarginPercent}
|
||||
onChange={(e) => setGlobalMarginForm({ ...globalMarginForm, wholesaleMarginPercent: Number(e.target.value) || 0 })}
|
||||
leftIcon={<span className="text-gray-400 font-bold text-xs">%</span>}
|
||||
dir="ltr"
|
||||
className="text-sm font-bold"
|
||||
/>
|
||||
<p className="text-[11px] text-gray-400 mt-1">پیشفرض سیستم: {pricingSettings.defaultWholesaleMarginPercent}٪</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user