Skip to content

Commit

Permalink
feat: Basic UI
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Dec 5, 2024
1 parent e8ec90d commit c194c07
Showing 1 changed file with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,52 @@ const ApplicationFee: React.FC<{ amount: number }> = ({ amount }) => (
</TableRow>
);

const Reductions: React.FC<{ amount?: number }> = ({ amount }) => {
const Reductions: React.FC<{ amount?: number, reductions: string[] }> = ({ amount, reductions }) => {
if (!amount) return null;

return (
<>
<TableRow>
<TableCell>Reductions</TableCell>
<TableCell align="right">
{formattedPriceWithCurrencySymbol(-amount)}
</TableCell>
</TableRow>
{
reductions.map((reduction) => (
<TableRow>
<TableCell colSpan={2}>
<Box sx={{ pl: 2, color: "grey" }}>{reduction}</Box>
</TableCell>
</TableRow>
))
}
</>
);
};

// TODO: This won't show as if a fee is 0, we hide the whole Pay component from the user
const Exemptions: React.FC<{ amount: number, exemptions: string[] }> = ({ amount, exemptions }) => {
if (!exemptions.length) return null;

return (
<>
<TableRow>
<TableCell>Exemptions</TableCell>
<TableCell align="right">
{formattedPriceWithCurrencySymbol(-amount)}
</TableCell>
</TableRow>
{
exemptions.map((exemption) => (
<TableRow>
<TableCell colSpan={2}>
<Box sx={{ pl: 2, color: "grey" }}>{exemption}</Box>
</TableCell>
</TableRow>
))
}
</>
);
};

Expand Down Expand Up @@ -90,7 +126,7 @@ export const FeeBreakdown: React.FC = () => {
const breakdown = useFeeBreakdown();
if (!breakdown) return null;

const { amount, exemptions: _exemptions, reductions: _reductions } = breakdown;
const { amount, reductions, exemptions } = breakdown;

return (
<Box mt={3}>
Expand All @@ -105,7 +141,8 @@ export const FeeBreakdown: React.FC = () => {
<Header />
<TableBody>
<ApplicationFee amount={amount.applicationFee} />
<Reductions amount={amount.reduction} />
<Reductions amount={amount.reduction} reductions={reductions}/>
<Exemptions amount={amount.applicationFee} exemptions={exemptions}/>
<Total amount={amount.total} />
<VAT amount={amount.vat} />
</TableBody>
Expand Down

0 comments on commit c194c07

Please sign in to comment.