|
|
|
@ -22,6 +22,19 @@ const width = Dimensions.get("window").width; |
|
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
|
|
|
|
|
|
function Product({ product, grades, pushToCart, loading, mobile, theme }) { |
|
|
|
|
const [selectedProduct, setSelectedProduct] = React.useState(null); |
|
|
|
|
|
|
|
|
|
const submit = async (action) => { |
|
|
|
|
setSelectedProduct(product?.productId); |
|
|
|
|
await action(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
React.useEffect(() => { |
|
|
|
|
if(!loading){ |
|
|
|
|
setSelectedProduct(null); |
|
|
|
|
} |
|
|
|
|
},[loading]); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<View |
|
|
|
|
style={[ |
|
|
|
@ -105,7 +118,7 @@ function Product({ product, grades, pushToCart, loading, mobile, theme }) { |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
{separate(product?.product?.price) || ' '} |
|
|
|
|
{separate(product?.product?.price) || " "} |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
@ -118,6 +131,7 @@ function Product({ product, grades, pushToCart, loading, mobile, theme }) { |
|
|
|
|
size={mobile ? 20 : 30} |
|
|
|
|
color={Colors.theme1[theme].redFF1} |
|
|
|
|
onPress={() => |
|
|
|
|
submit( |
|
|
|
|
pushToCart( |
|
|
|
|
{ |
|
|
|
|
productId: product?.productId, |
|
|
|
@ -127,6 +141,7 @@ function Product({ product, grades, pushToCart, loading, mobile, theme }) { |
|
|
|
|
{}, |
|
|
|
|
{ id: product?.factorId } |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
<View style={tw("flex items-center mt-2")}> |
|
|
|
@ -137,11 +152,13 @@ function Product({ product, grades, pushToCart, loading, mobile, theme }) { |
|
|
|
|
> |
|
|
|
|
<Pressable |
|
|
|
|
onPress={() => |
|
|
|
|
submit( |
|
|
|
|
pushToCart({ |
|
|
|
|
productId: product?.productId, |
|
|
|
|
userId: product?.userId, |
|
|
|
|
count: 1, |
|
|
|
|
}) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
style={[ |
|
|
|
|
tw( |
|
|
|
@ -164,13 +181,13 @@ function Product({ product, grades, pushToCart, loading, mobile, theme }) { |
|
|
|
|
+ |
|
|
|
|
</Text> |
|
|
|
|
</Pressable> |
|
|
|
|
{/* {loading ? ( |
|
|
|
|
{loading && selectedProduct === product?.productId ? ( |
|
|
|
|
<ActivityIndicator |
|
|
|
|
style={tw("mx-2")} |
|
|
|
|
size="small" |
|
|
|
|
color={Colors.theme1[theme].greenBA} |
|
|
|
|
/> |
|
|
|
|
) : ( */} |
|
|
|
|
) : ( |
|
|
|
|
<Text |
|
|
|
|
style={[ |
|
|
|
|
tw("mx-2.5"), |
|
|
|
@ -183,15 +200,17 @@ function Product({ product, grades, pushToCart, loading, mobile, theme }) { |
|
|
|
|
> |
|
|
|
|
{product?.count} |
|
|
|
|
</Text> |
|
|
|
|
{/* )} */} |
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
<Pressable |
|
|
|
|
onPress={() => |
|
|
|
|
submit( |
|
|
|
|
pushToCart({ |
|
|
|
|
productId: product?.productId, |
|
|
|
|
userId: product?.userId, |
|
|
|
|
count: -1, |
|
|
|
|
}) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
style={[ |
|
|
|
|
tw( |
|
|
|
@ -233,7 +252,7 @@ function Product({ product, grades, pushToCart, loading, mobile, theme }) { |
|
|
|
|
}, |
|
|
|
|
]} |
|
|
|
|
> |
|
|
|
|
{separate(product?.product?.price * product?.count) || ' '} |
|
|
|
|
{separate(product?.product?.price * product?.count) || " "} |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
@ -245,7 +264,7 @@ function Product({ product, grades, pushToCart, loading, mobile, theme }) { |
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
|
grades: state.publicApi.grades, |
|
|
|
|
mobile: state.publicApi.mobile, |
|
|
|
|
theme: state.publicApi.theme |
|
|
|
|
theme: state.publicApi.theme, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
|