Skip to content

Commit

Permalink
prettyAmount without fraction digits
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlukas committed Jan 21, 2025
1 parent 0ae2921 commit cc17da9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions frontend/src/components/Bank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as React from "react"
import { ListGroup, ListGroupItem, Table } from "reactstrap"

import BankService from "../api/services/BankService"
import { BANKING_URL, CURRENCY } from "../global/constants"
import { BANKING_URL } from "../global/constants"
import { isToday, prettyDateWithDayYearIfDiff, prettyTimeWithSeconds } from "../global/funcDateTime"
import { prettyAmount } from "../global/utils"
import { BankType } from "../types/models"
Expand Down Expand Up @@ -121,7 +121,7 @@ export default class Bank extends React.PureComponent<{}, State> {
Aktuální stav:{" "}
{balance ? (
<span className="font-weight-bold text-nowrap">
{`${prettyAmount(balance)} ${CURRENCY}`}
{prettyAmount(balance)}
</span>
) : this.state.isDataProblem ? (
"neznámý"
Expand All @@ -133,7 +133,7 @@ export default class Bank extends React.PureComponent<{}, State> {
<UncontrolledTooltipWrapper target="Bank_RentWarning">
Na účtu není dostatek peněz (alespoň{" "}
<span className="font-weight-bold text-nowrap">
{`${prettyAmount(rentPrice)} ${CURRENCY}`}
{prettyAmount(rentPrice)}
</span>
) pro zaplacení nájmu!
</UncontrolledTooltipWrapper>
Expand Down Expand Up @@ -247,7 +247,7 @@ export default class Bank extends React.PureComponent<{}, State> {
<td
className={`${amountClassName} font-weight-bold text-right text-nowrap`}
style={{ minWidth: "7em" }}>
{prettyAmount(amount)} {CURRENCY}
{prettyAmount(amount)}
</td>
</tr>
)
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/global/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ export enum USER_CELEBRATION {
NAMEDAY = 2,
}

/** Výchozí měna. */
export const CURRENCY = "Kč"

/** URL adresa GitHub repozitáře s aplikací. */
export const GITHUB_REPO_URL = "https://github.com/rodlukas/UP-admin"

Expand Down
6 changes: 5 additions & 1 deletion frontend/src/global/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ export function getDefaultValuesForLecture(

/** Vrátí částku ve srozumitelném formátu. */
export function prettyAmount(amount: number): string {
return amount.toLocaleString(LOCALE_CZ)
return amount.toLocaleString(LOCALE_CZ, {
style: "currency",
currency: "CZK",
maximumFractionDigits: 0,
})
}

/** Workaround dokud nebude fungovat required v react-selectu - TODO. */
Expand Down

0 comments on commit cc17da9

Please sign in to comment.