-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/invoice/src/templates/html/components/line-items.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { formatAmount } from "../../../utils/format"; | ||
import type { LineItem } from "../../types"; | ||
type Props = { | ||
lineItems: LineItem[]; | ||
currency: string; | ||
descriptionLabel: string; | ||
quantityLabel: string; | ||
priceLabel: string; | ||
totalLabel: string; | ||
}; | ||
|
||
export function LineItems({ | ||
lineItems, | ||
currency, | ||
descriptionLabel, | ||
quantityLabel, | ||
priceLabel, | ||
totalLabel, | ||
}: Props) { | ||
return ( | ||
<div className="mt-5"> | ||
<div className="flex border-b border-black pb-1 mb-1"> | ||
<div className="flex-3 text-xs font-medium">{descriptionLabel}</div> | ||
<div className="flex-1 text-xs font-medium">{priceLabel}</div> | ||
<div className="flex-[0.5] text-xs font-medium">{quantityLabel}</div> | ||
<div className="flex-1 text-xs font-medium text-right"> | ||
{totalLabel} | ||
</div> | ||
</div> | ||
{lineItems.map((item, index) => ( | ||
<div key={`line-item-${index.toString()}`} className="flex py-1"> | ||
<div className="flex-3 text-xs">{item.name}</div> | ||
<div className="flex-1 text-xs"> | ||
{formatAmount({ currency, amount: item.price })} | ||
</div> | ||
<div className="flex-[0.5] text-xs">{item.quantity}</div> | ||
<div className="flex-1 text-xs text-right"> | ||
{formatAmount({ currency, amount: item.quantity * item.price })} | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters