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