Skip to content

Commit

Permalink
fix: make currency not optional
Browse files Browse the repository at this point in the history
to do with #810
  • Loading branch information
Simon committed Aug 21, 2024
1 parent 429cff2 commit 8edd651
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion client/src/components/Admin/AdminPurchases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const AdminPurchases: React.FC = () => {
{Object.keys(total).map((currency) => (
<tr key={currency}>
<td>{currency}</td>
<Money amount={total[currency] / 100} />
<Money amount={total[currency] / 100} currency={currency} />
</tr>
))}
</tbody>
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/common/Money.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const moneyDisplay = ({
amount,
currency = "USD",
currency,
}: {
amount?: number | string;
currency?: string;
currency: string;
}) => {
if (!amount) {
return "-";
Expand All @@ -16,8 +16,8 @@ export const moneyDisplay = ({

export const Money: React.FC<{
amount?: number | string;
currency?: string;
}> = ({ amount, currency = "USD" }) => {
currency: string;
}> = ({ amount, currency }) => {
return <>{moneyDisplay({ amount, currency })}</>;
};

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/common/PlatformPercent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { css } from "@emotion/css";
const PlatformPercent: React.FC<{
percent: number;
chosenPrice?: string | number;
currency?: string;
currency: string;
artist?: Pick<Artist, "name">;
}> = ({ percent, chosenPrice, currency = "USD", artist }) => {
const chosenNumber =
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/common/SupportArtistPopUpTiers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const ListItem = styled.li`
const SupportArtistPopUpTiers = forwardRef<
HTMLInputElement,
{
options: Partial<ArtistSubscriptionTier>[];
options: ArtistSubscriptionTier[];
}
>(function ({ options, ...props }, ref) {
const { t } = useTranslation("translation", { keyPrefix: "artist" });
Expand Down
15 changes: 8 additions & 7 deletions client/src/components/common/TipArtistForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const TipArtistForm: React.FC<{
id={`priceButton-${gift.value}`}
/>
<label htmlFor={`priceButton-${gift.value}`}>
{gift.value !== "other"
{currency && gift.value !== "other"
? moneyDisplay({
amount: gift.value,
currency,
Expand Down Expand Up @@ -165,12 +165,13 @@ const TipArtistForm: React.FC<{
width: 100% !important;
`}
>
{t(!actualValue ? "enterGiftAmount" : "giveOnce", {
amount: moneyDisplay({
amount: actualValue,
currency,
}),
})}
{currency &&
t(!actualValue ? "enterGiftAmount" : "giveOnce", {
amount: moneyDisplay({
amount: actualValue,
currency,
}),
})}
</Button>
</div>
);
Expand Down

0 comments on commit 8edd651

Please sign in to comment.