49 lines
2.0 KiB
TypeScript
49 lines
2.0 KiB
TypeScript
// Metro module 13925 (f13926).
|
|
import FamilyCenterStore from "../FamilyCenterStore";
|
|
import { TeenActionDisplayType } from "../FamilyCenterConstants";
|
|
import { useStateFromStoresArray, useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
|
|
import { formatTotalTime } from "../FamilyCenterUtils";
|
|
import { shortenAndFormatPrice } from "../../../utils/PriceUtils";
|
|
function $mk92281($env) {
|
|
return () => $env.$parent[2].getTotalForDisplayType($env[0]);
|
|
}
|
|
let env9716 = {};
|
|
export function useActionsForDisplayType(c20789_0) {
|
|
return useStateFromStoresArray([FamilyCenterStore], () => FamilyCenterStore.getActionsForDisplayType(c20789_0));
|
|
}
|
|
export function useActionTotalsForDisplayType(a0) {
|
|
let env20788;
|
|
const r1 = env20788 = {
|
|
$parent: env9716
|
|
};
|
|
env20788[0] = a0;
|
|
return useStateFromStores([FamilyCenterStore], $mk92281(r1));
|
|
}
|
|
export function useHasActionForAnyDisplayType() {
|
|
return useStateFromStores([FamilyCenterStore], () => Object.values(TeenActionDisplayType).some((item) => FamilyCenterStore.getTotalForDisplayType(item) > 0));
|
|
}
|
|
export function useFormattedTotalForDisplayType(a0) {
|
|
let env20790;
|
|
const r5 = env20790 = {
|
|
$parent: env9716
|
|
};
|
|
env20790[0] = a0;
|
|
let r14 = useStateFromStores([FamilyCenterStore], $mk92281(r5));
|
|
if (r14 == null) {
|
|
r14 = 0;
|
|
}
|
|
if (a0 === TeenActionDisplayType.TOTAL_VOICE_MINUTES) {
|
|
return formatTotalTime(r14);
|
|
}
|
|
if (a0 === TeenActionDisplayType.PURCHASES) {
|
|
const totalSpendAmount = FamilyCenterStore.getTotalSpendAmount();
|
|
const totalSpendCurrency = FamilyCenterStore.getTotalSpendCurrency();
|
|
return totalSpendAmount != null ? totalSpendCurrency != null ? shortenAndFormatPrice(totalSpendAmount, totalSpendCurrency) : r14 : r14;
|
|
}
|
|
if (a0 === TeenActionDisplayType.GIFTS) {
|
|
const totalGiftValue = FamilyCenterStore.getTotalGiftValue();
|
|
return totalGiftValue != null ? shortenAndFormatPrice(totalGiftValue.amount, totalGiftValue.currency) : r14;
|
|
}
|
|
return r14;
|
|
}
|