({
transaction,
user,
}: {
transaction: UserTransaction;
user: LoggedUser;
})
| 32 | }; |
| 33 | |
| 34 | export const getTransactionLabel = ({ |
| 35 | transaction, |
| 36 | user, |
| 37 | }: { |
| 38 | transaction: UserTransaction; |
| 39 | user: LoggedUser; |
| 40 | }): ReactNode => { |
| 41 | const type = getTransactionType({ transaction, user }); |
| 42 | |
| 43 | if (transaction.flags.error) { |
| 44 | return ( |
| 45 | <span className="text-accent-ketchup-default"> |
| 46 | {transaction.flags.error || 'Failed'} |
| 47 | </span> |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | if (UserTransactionStatus.Created === transaction.status) { |
| 52 | return 'Created'; |
| 53 | } |
| 54 | |
| 55 | if (UserTransactionStatus.Processing === transaction.status) { |
| 56 | return 'Pending'; |
| 57 | } |
| 58 | |
| 59 | if (type === 'purchase') { |
| 60 | return 'Purchased'; |
| 61 | } |
| 62 | |
| 63 | if ( |
| 64 | transaction.referenceType === UserTransactionType.PostBoost && |
| 65 | transaction.flags.note |
| 66 | ) { |
| 67 | return transaction.flags.note; |
| 68 | } |
| 69 | |
| 70 | if ( |
| 71 | transaction.referenceType?.startsWith(QUEST_REWARD_REFERENCE_PREFIX) && |
| 72 | transaction.flags.note |
| 73 | ) { |
| 74 | return transaction.flags.note; |
| 75 | } |
| 76 | |
| 77 | if (['receive', 'send'].includes(type)) { |
| 78 | if (transaction.product) { |
| 79 | return ( |
| 80 | <div className="flex items-center gap-1"> |
| 81 | <Image |
| 82 | src={transaction.product.image} |
| 83 | alt={transaction.product.name} |
| 84 | className="size-5" |
| 85 | /> |
| 86 | Award{' '} |
| 87 | </div> |
| 88 | ); |
| 89 | } |
| 90 | |
| 91 | if (transaction.flags.note === 'Streak restore') { |
no test coverage detected