Update floating-cart-bar.tsx
This commit is contained in:
parent
306297ed09
commit
5338505bfc
1 changed files with 17 additions and 5 deletions
|
|
@ -29,6 +29,13 @@ import { LinearGradient } from "expo-linear-gradient";
|
|||
|
||||
const { height: screenHeight } = Dimensions.get("window");
|
||||
|
||||
const formatQuantity = (quantity: number, unit: string): { value: string; display: string } => {
|
||||
if (unit?.toLowerCase() === 'kg' && quantity < 1) {
|
||||
return { value: `${Math.round(quantity * 1000)} g`, display: `${Math.round(quantity * 1000)}g` };
|
||||
}
|
||||
return { value: `${quantity} ${unit}(s)`, display: `${quantity}${unit}` };
|
||||
};
|
||||
|
||||
interface FloatingCartBarProps {
|
||||
isFlashDelivery?: boolean;
|
||||
isExpanded?: boolean;
|
||||
|
|
@ -259,10 +266,15 @@ const FloatingCartBar: React.FC<FloatingCartBarProps> = ({
|
|||
<React.Fragment key={item.id}>
|
||||
<View style={tw`py-4`}>
|
||||
<View style={tw`flex-row items-center`}>
|
||||
<Image
|
||||
source={{ uri: productsById[item.productId]?.images?.[0] }}
|
||||
style={tw`w-8 h-8 rounded-lg bg-slate-50 border border-slate-100`}
|
||||
/>
|
||||
<View style={tw`items-center`}>
|
||||
<Image
|
||||
source={{ uri: productsById[item.productId]?.images?.[0] }}
|
||||
style={tw`w-8 h-8 rounded-lg bg-slate-50 border border-slate-100`}
|
||||
/>
|
||||
<MyText style={tw`text-gray-500 text-[9px] font-medium mt-1`}>
|
||||
<MyText style={tw`text-[#f81260] font-semibold`}>{formatQuantity(productsById[item.productId]?.productQuantity || 1, productsById[item.productId]?.unitNotation || '').display}</MyText>
|
||||
</MyText>
|
||||
</View>
|
||||
|
||||
<View style={tw`flex-1 ml-4`}>
|
||||
<View style={tw`flex-row items-center justify-between mb-1`}>
|
||||
|
|
@ -283,7 +295,7 @@ const FloatingCartBar: React.FC<FloatingCartBarProps> = ({
|
|||
}}
|
||||
step={productsById[item.productId]?.incrementStep || 1}
|
||||
showUnits={true}
|
||||
unit={productsById[item.productId]?.unitNotation}
|
||||
// unit={productsById[item.productId]?.unitNotation}
|
||||
/>
|
||||
</View>
|
||||
<View style={tw`flex-row items-center justify-between`}>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue