-
Notifications
You must be signed in to change notification settings - Fork 4
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
11 changed files
with
247 additions
and
49 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
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
44 changes: 44 additions & 0 deletions
44
frontend/src/components/transaction/import/MapCsvFields/MetaFieldValue.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 * as React from "react"; | ||
import { FieldValueType, MetaField } from "../../../../models/meta"; | ||
import Tooltip from "../../../common/Tooltip"; | ||
import { useTranslation } from "react-i18next"; | ||
import { formatNumberWithUser } from "../../../../lib/Utils"; | ||
import { useUser } from "../../../App"; | ||
import { CsvCreateTransactionMetaValue } from "../importModels"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faExclamationTriangle } from "@fortawesome/free-solid-svg-icons"; | ||
import Decimal from "decimal.js"; | ||
|
||
interface Props { | ||
field: MetaField | ||
value?: CsvCreateTransactionMetaValue | ||
} | ||
|
||
export function MetaFieldValue (props: Props): React.ReactElement { | ||
const { t } = useTranslation(); | ||
const user = useUser(); | ||
|
||
if (props.value === undefined) { | ||
return <p>-</p>; | ||
} | ||
|
||
switch (props.value.type) { | ||
case FieldValueType.TextLine: | ||
case FieldValueType.TextLong: | ||
return <p>{props.value.value as string}</p>; | ||
case FieldValueType.Number: | ||
if (props.value.value !== "invalid") { | ||
return <Tooltip content={t("import.amount_parsed_from", { raw_value: props.value.sourceText })}> | ||
{formatNumberWithUser(props.value.value as Decimal, user)} | ||
</Tooltip>; | ||
} else { | ||
return <Tooltip content={t("import.amount_parsed_from", { raw_value: props.value.sourceText })}> | ||
<span className="icon has-text-danger"> | ||
<FontAwesomeIcon icon={faExclamationTriangle} /> | ||
</span> {t("import.could_not_parse_amount")} | ||
</Tooltip>; | ||
} | ||
default: | ||
return <p>-</p>; | ||
} | ||
} |
Oops, something went wrong.