This commit is contained in:
shafi54 2026-07-31 23:20:04 +05:30
parent 1b62c6add4
commit 6193104e6f
2 changed files with 4 additions and 16 deletions

View file

@ -43,7 +43,7 @@ const SkuItemComponent: React.FC<SkuItemProps> = ({
const displayPrice = change.price !== undefined ? change.price : sku.price;
const displayMarketPrice = change.marketPrice !== undefined ? change.marketPrice : sku.marketPrice;
const displayFlashPrice = change.flashPrice !== undefined ? change.flashPrice : sku.flashPrice;
const displayProductQuantity = change.productQuantity !== undefined ? change.productQuantity : sku.productQuantity;
const displayUnit = (sku.features || []).map((f: any) => f.featureValue).join(' ') || '—';
return (
<View style={tw`bg-white p-4 mb-3 rounded-xl border border-gray-200 shadow-sm`}>
@ -130,7 +130,7 @@ const SkuItemComponent: React.FC<SkuItemProps> = ({
<View style={tw`items-center`}>
<MyText style={tw`text-xs text-gray-500 mb-1`}>Size</MyText>
<View style={tw`flex-row items-center`}>
<MyText style={tw`text-sm text-blue-600`}>{displayProductQuantity ? `${displayProductQuantity}${sku.unit?.shortNotation || ''}` : "N/A"}</MyText>
<MyText style={tw`text-sm text-blue-600`}>{displayUnit}</MyText>
<TouchableOpacity onPress={() => openEditDialog(sku, productName)} style={tw`ml-1`}>
<MaterialIcons name="edit" size={14} color="#6b7280" />
</TouchableOpacity>
@ -145,7 +145,6 @@ interface PendingChange {
price?: number;
marketPrice?: number | null;
flashPrice?: number | null;
productQuantity?: number | null;
isFlashAvailable?: boolean;
}
@ -156,7 +155,6 @@ interface EditDialogState {
tempPrice: string;
tempMarketPrice: string;
tempFlashPrice: string;
tempProductQuantity: string;
}
export default function PricesOverview() {
@ -170,7 +168,6 @@ export default function PricesOverview() {
tempPrice: "",
tempMarketPrice: "",
tempFlashPrice: "",
tempProductQuantity: "",
});
const [showMenu, setShowMenu] = useState(false);
@ -233,7 +230,6 @@ export default function PricesOverview() {
tempPrice: (change.price ?? sku.price)?.toString() || "",
tempMarketPrice: (change.marketPrice ?? sku.marketPrice)?.toString() || "",
tempFlashPrice: (change.flashPrice ?? sku.flashPrice)?.toString() || "",
tempProductQuantity: (change.productQuantity ?? sku.productQuantity)?.toString() || "",
});
};
@ -241,7 +237,6 @@ export default function PricesOverview() {
const price = parseFloat(editDialog.tempPrice);
const marketPrice = editDialog.tempMarketPrice ? parseFloat(editDialog.tempMarketPrice) : null;
const flashPrice = editDialog.tempFlashPrice ? parseFloat(editDialog.tempFlashPrice) : null;
const productQuantity = editDialog.tempProductQuantity ? parseFloat(editDialog.tempProductQuantity) : null;
if (isNaN(price) || price <= 0) {
Alert.alert("Error", "Please enter a valid price");
@ -258,7 +253,6 @@ export default function PricesOverview() {
return;
}
if (editDialog.tempProductQuantity && (isNaN(productQuantity!) || productQuantity! <= 0)) {
Alert.alert("Error", "Please enter a valid size");
return;
}
@ -269,21 +263,18 @@ export default function PricesOverview() {
price: price !== parseFloat(editDialog.sku.price) ? price : undefined,
marketPrice: marketPrice !== parseFloat(editDialog.sku.marketPrice || '0') ? marketPrice : undefined,
flashPrice: flashPrice !== parseFloat(editDialog.sku.flashPrice || '0') ? flashPrice : undefined,
productQuantity: productQuantity !== (editDialog.sku.productQuantity || 1) ? productQuantity : undefined,
},
}));
setEditDialog({ open: false, sku: null, productName: "", tempPrice: "", tempMarketPrice: "", tempFlashPrice: "", tempProductQuantity: "" });
};
const handleSave = () => {
const updates = Object.entries(pendingChanges).map(([skuId, change]) => {
const sku = allSkus.find(s => s.id === parseInt(skuId));
const update: any = { productId: sku?.productId };
const update: any = { productId: sku?.id };
if (change.price !== undefined) update.price = change.price;
if (change.marketPrice !== undefined) update.marketPrice = change.marketPrice;
if (change.flashPrice !== undefined) update.flashPrice = change.flashPrice;
if (change.productQuantity !== undefined) update.productQuantity = change.productQuantity;
if (change.isFlashAvailable !== undefined) update.isFlashAvailable = change.isFlashAvailable;
return update;
});
@ -377,7 +368,6 @@ export default function PricesOverview() {
/>
)}
<BottomDialog open={editDialog.open} onClose={() => setEditDialog({ ...editDialog, open: false, tempFlashPrice: "", tempMarketPrice: "", tempPrice: "", tempProductQuantity: "" })}>
<View style={tw`p-4`}>
<MyText style={tw`text-lg font-bold mb-1`}>{editDialog.productName}</MyText>
<MyText style={tw`text-sm text-gray-500 mb-4`}>{editDialog.sku?.displayName || editDialog.sku?.name || ''}</MyText>
@ -419,8 +409,6 @@ export default function PricesOverview() {
<MyText style={tw`text-sm font-medium mb-1`}>Size</MyText>
<TextInput
style={tw`border border-gray-300 rounded-md px-3 py-2`}
value={editDialog.tempProductQuantity}
onChangeText={(text) => setEditDialog({ ...editDialog, tempProductQuantity: text })}
keyboardType="decimal-pad"
placeholder="Enter size"
/>

View file

@ -11,7 +11,7 @@ const mapBanner = (banner: BannerRow): UserBanner => ({
name: banner.name,
imageUrl: banner.imageUrl,
description: banner.description ?? null,
productIds: banner.productIds ?? null,
skuIds: banner.skuIds ?? null,
redirectUrl: banner.redirectUrl ?? null,
serialNum: banner.serialNum ?? null,
isActive: banner.isActive,