last fixes, home and videos
This commit is contained in:
@@ -13,6 +13,7 @@ import Page from "../../layouts/Page";
|
||||
import { useUser } from "../../providers/UserDataProvider";
|
||||
import { gutters, Palette } from "../../styles";
|
||||
import { FONT_FAMILY } from "../../styles/Fonts";
|
||||
import CreditAmount from "../../components/CreditAmount";
|
||||
|
||||
const ORDER_TYPE_LABELS = {
|
||||
GIFT: "Crédit offert",
|
||||
@@ -21,19 +22,6 @@ const ORDER_TYPE_LABELS = {
|
||||
SUBSCRIPTION: "Abonnement",
|
||||
};
|
||||
|
||||
const formatCoins = (amount) => {
|
||||
if (typeof amount !== "number" || !Number.isFinite(amount)) {
|
||||
return "0";
|
||||
}
|
||||
try {
|
||||
return new Intl.NumberFormat("fr-FR", {
|
||||
maximumFractionDigits: 0,
|
||||
}).format(amount);
|
||||
} catch (_error) {
|
||||
return `${amount}`;
|
||||
}
|
||||
};
|
||||
|
||||
const formatDateParts = (date) => {
|
||||
if (!date) {
|
||||
return {
|
||||
@@ -133,9 +121,10 @@ const OrderHistory = () => {
|
||||
? item.amount
|
||||
: 0;
|
||||
const isPositive = amountValue > 0;
|
||||
const amountLabel = `${isPositive ? "+" : ""}${formatCoins(amountValue)} ${
|
||||
Math.abs(amountValue) === 1 ? "coin" : "coins"
|
||||
}`;
|
||||
const amountTextStyle = [
|
||||
styles.orderAmount,
|
||||
isPositive ? styles.amountPositive : styles.amountNegative,
|
||||
];
|
||||
|
||||
const { dateLabel } = formatDateParts(item.createdAt);
|
||||
|
||||
@@ -182,14 +171,12 @@ const OrderHistory = () => {
|
||||
|
||||
return (
|
||||
<View style={styles.orderCard}>
|
||||
<Text
|
||||
style={[
|
||||
styles.orderAmount,
|
||||
isPositive ? styles.amountPositive : styles.amountNegative,
|
||||
]}
|
||||
>
|
||||
{amountLabel}
|
||||
</Text>
|
||||
<CreditAmount
|
||||
value={amountValue}
|
||||
showPlus
|
||||
textStyle={amountTextStyle}
|
||||
iconSize={18}
|
||||
/>
|
||||
<Text style={styles.orderReason}>{reasonLabel}</Text>
|
||||
<Text style={styles.orderTimestamp}>{dateLabel}</Text>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user