fix(stock/editor/zibal): fix stock zero display in app, resolve admin rich text editor cursor jumping, optimize zibal queue parser
Deploy Canina / deploy (push) Successful in 1m38s

This commit is contained in:
parsa committed 2026-08-24 00:55:25 +03:30
1 parent d1e3daf992
commit 44e1f915f4
207 files changed
+254318 -117167

No files matched your search

@@ -42,6 +42,19 @@ export default function RichTextEditor({
}: RichTextEditorProps) {
const editorRef = useRef<HTMLDivElement>(null);
const isMountedRef = useRef(false);
useEffect(() => {
if (editorRef.current) {
if (!isMountedRef.current) {
editorRef.current.innerHTML = value || '';
isMountedRef.current = true;
} else if (editorRef.current.innerHTML !== (value || '')) {
editorRef.current.innerHTML = value || '';
}
}
}, [value]);
const exec = (command: string, val: string | undefined = undefined) => {
document.execCommand(command, false, val);
if (editorRef.current) {
@@ -229,7 +242,6 @@ export default function RichTextEditor({
ref={editorRef}
contentEditable
onInput={handleInput}
dangerouslySetInnerHTML={{ __html: value }}
data-placeholder={placeholder}
className="p-4 min-h-[140px] max-h-[350px] overflow-y-auto outline-none text-xs leading-relaxed text-gray-800 font-vazir empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400"
dir="rtl"
+41 -25
View File
@@ -155,25 +155,25 @@ export default function Products() {
const [formData, setFormData] = useState({
artNo: '',
buyPrice: '' as number | string,
priceValue: '' as number | string,
wholesalePrice: '' as number | string,
priceValueMarginPercent: '' as number | string,
wholesaleMarginPercent: '' as number | string,
priceDisplay: '',
unit: '',
packageSize: '' as number | string,
dosageLogic: '',
suitableFor: 'سگ و گربه',
imageUrl: '',
metaTitle: '',
metaDescription: '',
nameFa: '',
nameEn: '',
scientificTagline: '',
description: '',
shortDescription: '',
categoryId: '',
buyPrice: '' as number | string,
priceValue: 0,
wholesalePrice: '' as number | string,
priceValueMarginPercent: '' as number | string,
wholesaleMarginPercent: '' as number | string,
priceDisplay: '',
unit: '',
packageSize: 0,
dosageLogic: '',
suitableFor: 'سگ و گربه',
imageUrl: '',
metaTitle: '',
metaDescription: '',
keywords: '',
canonicalUrl: '',
slug: '',
@@ -195,17 +195,24 @@ export default function Products() {
preorderDeposit: '' as number | string
});
const openModal = (product: Product | null = null) => {
const openModal = (product?: Product) => {
setMediaImageError(false);
if (product) {
setEditingProduct(product);
updateUrlParams({ modal: 'edit', productId: product.id, tab: activeTab || 'general' });
const bPrice = product.buyPrice ? Number(product.buyPrice) : '';
const pPrice = Number(product.priceValue || 0);
const wPrice = product.wholesalePrice ? Number(product.wholesalePrice) : '';
const pMargin = bPrice && pPrice ? Math.round(((pPrice - Number(bPrice)) / Number(bPrice)) * 100) : '';
const wMargin = bPrice && wPrice ? Math.round(((wPrice - Number(bPrice)) / Number(bPrice)) * 100) : '';
const pPrice = product.priceValue !== undefined && product.priceValue !== null ? Number(product.priceValue) : '';
const wPrice = product.wholesalePrice !== undefined && product.wholesalePrice !== null ? Number(product.wholesalePrice) : '';
let pMargin: number | string = '';
let wMargin: number | string = '';
if (bPrice && pPrice !== '') {
pMargin = Math.round(((Number(pPrice) - Number(bPrice)) / Number(bPrice)) * 100);
}
if (bPrice && wPrice !== '') {
wMargin = Math.round(((Number(wPrice) - Number(bPrice)) / Number(bPrice)) * 100);
}
setFormData({
artNo: product.artNo || '',
@@ -214,7 +221,7 @@ export default function Products() {
scientificTagline: product.scientificTagline || '',
description: product.description || '',
shortDescription: product.shortDescription || '',
categoryId: product.categoryId || '',
categoryId: typeof product.category === 'object' && product.category !== null ? product.category.id : (product.categoryId || ''),
buyPrice: bPrice,
priceValue: pPrice,
wholesalePrice: wPrice,
@@ -222,7 +229,7 @@ export default function Products() {
wholesaleMarginPercent: wMargin,
priceDisplay: product.priceDisplay || '',
unit: product.unit || '',
packageSize: Number(product.packageSize) || 0,
packageSize: product.packageSize !== undefined && product.packageSize !== null ? Number(product.packageSize) : '',
dosageLogic: product.dosageLogic || '',
suitableFor: product.suitableFor || 'سگ و گربه',
imageUrl: product.imageUrl || '',
@@ -246,15 +253,15 @@ export default function Products() {
pdfCover: product.pdfCover || '',
symptoms: product.symptoms ? product.symptoms.map((s: { symptom: string } | string) => typeof s === 'string' ? s : s.symptom) : [],
isPreorder: Boolean(product.isPreorder),
preorderDeposit: product.preorderDeposit || ''
preorderDeposit: product.preorderDeposit !== undefined && product.preorderDeposit !== null ? product.preorderDeposit : ''
});
} else {
setEditingProduct(null);
updateUrlParams({ modal: 'create', productId: undefined, tab: activeTab || 'general' });
setFormData({
artNo: '', nameFa: '', nameEn: '', scientificTagline: '', description: '', shortDescription: '', categoryId: '',
buyPrice: '', priceValue: 0, wholesalePrice: '', priceValueMarginPercent: '', wholesaleMarginPercent: '',
priceDisplay: '', unit: '', packageSize: 0, dosageLogic: '', suitableFor: 'سگ و گربه',
buyPrice: '', priceValue: '', wholesalePrice: '', priceValueMarginPercent: '', wholesaleMarginPercent: '',
priceDisplay: '', unit: '', packageSize: '', dosageLogic: '', suitableFor: 'سگ و گربه',
imageUrl: '', metaTitle: '', metaDescription: '', keywords: '', canonicalUrl: '', slug: '',
images: [],
podcastUrl: '', podcastTitle: '', podcastDescription: '', podcastCover: '',
@@ -1111,7 +1118,16 @@ export default function Products() {
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 pt-2">
<div className="space-y-2">
<label className="text-sm font-bold text-gray-700">موجودی *</label>
<input required type="number" min="0" value={formData.packageSize} onChange={(e) => setFormData({ ...formData, packageSize: Number(e.target.value) })} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" dir="ltr" />
<input
required
type="number"
min="0"
placeholder="0"
value={formData.packageSize === '' ? '' : formData.packageSize}
onChange={(e) => setFormData({ ...formData, packageSize: e.target.value === '' ? '' : Number(e.target.value) })}
className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none text-left font-mono font-bold"
dir="ltr"
/>
</div>
<div className="space-y-2">
<label className="text-sm font-bold text-gray-700">واحد سنجش</label>
@@ -178,7 +178,18 @@ export default function ZibalPortalPage() {
try {
setLoadingQueue(true);
const res = await api.get('/payment/admin/checkout-queue');
const items = Array.isArray(res.data) ? res.data : (res.data?.data || []);
let items: any[] = [];
if (Array.isArray(res.data)) {
items = res.data;
} else if (res.data?.data && Array.isArray(res.data.data)) {
items = res.data.data;
} else if (res.data?.queue && Array.isArray(res.data.queue)) {
items = res.data.queue;
} else if (res.data?.checkouts && Array.isArray(res.data.checkouts)) {
items = res.data.checkouts;
} else if (res.data?.checkoutList && Array.isArray(res.data.checkoutList)) {
items = res.data.checkoutList;
}
setQueueItems(items);
} catch (e: any) {
toast.error('خطا در دریافت صف تسویه‌های در انتظار');