Skip to content

Commit

Permalink
Anrok Credit notes (#1758)
Browse files Browse the repository at this point in the history
* Create Credit Note Badge component

* Create Anrok credit note URL builder

* Remove old components

* Add error/translation utils for credit notes

* Export TableColumn type

* Use the Table component for Credit notes

* Codegen

* Create translations

* Remove custom link. Codegen. Update translations

* Fix Table width. Improve CreditNoteBadge. Add missing translations.

* Remove redundant creditNoteTaxError function

* Use new taxProviderId

* Add placeholders for empty states. Add tooltip

* LAGO-348 fix credit note type

* LAGO-350 fix tooltip positioning

* LAGO-347 fix table colors, columns width

* Improve table design

* Remove comment
  • Loading branch information
stephenlago99 authored Sep 27, 2024
1 parent 3fabd72 commit 98c1166
Show file tree
Hide file tree
Showing 14 changed files with 852 additions and 1,091 deletions.
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

0 comments on commit 98c1166

Please sign in to comment.