Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anrok Credit notes #1758

Merged
merged 18 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/components/creditNote/CreditNoteBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { CREDIT_NOTE_TYPE_TRANSLATIONS_MAP, creditNoteType } from '~/components/creditNote/utils'
import { Icon, Tooltip, Typography } from '~/components/designSystem'
import { CreditNote, CreditNoteTableItemFragment } from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'

const CreditNoteBadge = ({
creditNote,
}: {
creditNote?: CreditNoteTableItemFragment | CreditNote | null
}) => {
const { translate } = useInternationalization()

if (!creditNote) return null

const { creditAmountCents, refundAmountCents, voidedAt, taxProviderSyncable } = creditNote

const type = creditNoteType({
creditAmountCents,
refundAmountCents,
voidedAt,
})

if (type === null) return null

const label = translate(CREDIT_NOTE_TYPE_TRANSLATIONS_MAP[type])

const hasError = taxProviderSyncable

return (
<Tooltip
title={hasError ? translate('text_1727090499191gqzispoy1qz') : null}
placement="top-start"
>
<div className="flex items-center gap-2 rounded-lg border border-grey-400 bg-grey-100 px-2 py-1">
<Typography className="whitespace-nowrap text-sm font-medium text-grey-700">
{label}
</Typography>

{hasError && <Icon name="warning-unfilled" />}
</div>
</Tooltip>
)
}

export default CreditNoteBadge
Loading
Loading