Skip to content

Commit

Permalink
Merge branch 'add-i18n-typescript' into add-i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
gciotola committed Dec 16, 2024
2 parents b2a36d0 + 92faaad commit 759e87c
Show file tree
Hide file tree
Showing 20 changed files with 695 additions and 503 deletions.
11 changes: 0 additions & 11 deletions packages/app-elements/i18n.d.ts

This file was deleted.

18 changes: 9 additions & 9 deletions packages/app-elements/src/dictionaries/customers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ export function getCustomerDisplayStatus(
switch (customerObj.status) {
case 'prospect':
return {
label: t('common.resources.customers.status.prospect'),
label: t('resources.customers.attributes.status.prospect'),
icon: 'chatCircle',
color: 'orange',
task: t('common.resources.customers.status.prospect')
task: t('resources.customers.attributes.status.prospect')
}

case 'acquired':
return {
label: t('common.resources.customers.status.acquired'),
label: t('resources.customers.attributes.status.acquired'),
icon: 'check',
color: 'orange',
task: t('common.resources.customers.status.acquired')
task: t('resources.customers.attributes.status.acquired')
}

case 'repeat':
return {
label: t('common.resources.customers.status.repeat'),
label: t('resources.customers.attributes.status.repeat'),
icon: 'arrowUpRight',
color: 'orange',
task: t('common.resources.customers.status.repeat')
task: t('resources.customers.attributes.status.repeat')
}
}
}

export function getCustomerStatusName(status: Customer['status']): string {
const dictionary: Record<typeof status, string> = {
prospect: t('common.resources.customers.status.prospect'),
acquired: t('common.resources.customers.status.acquired'),
repeat: t('common.resources.customers.status.repeat')
prospect: t('resources.customers.attributes.status.prospect'),
acquired: t('resources.customers.attributes.status.acquired'),
repeat: t('resources.customers.attributes.status.repeat')
}

return dictionary[status]
Expand Down
94 changes: 52 additions & 42 deletions packages/app-elements/src/dictionaries/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export function getOrderDisplayStatus(order: Order): OrderDisplayStatus {

if (order.status === 'editing') {
return {
label: t('common.resources.orders.status.editing'),
label: t('resources.orders.attributes.status.editing'),
icon: 'pencilSimple',
color: 'orange',
task: t('common.resources.orders.status.editing')
task: t('resources.orders.attributes.status.editing')
}
}

Expand All @@ -32,79 +32,81 @@ export function getOrderDisplayStatus(order: Order): OrderDisplayStatus {
case 'placed:free:unfulfilled':
case 'placed:free:not_required':
return {
label: t('common.resources.orders.status.placed'),
label: t('resources.orders.attributes.status.placed'),
icon: 'arrowDown',
color: 'orange',
task: t('common.resources.orders.task.awaiting_approval')
task: t('apps.orders.task.awaiting_approval')
}

case 'placed:unpaid:unfulfilled':
return {
label: t('common.resources.orders.status.placed'),
label: t('resources.orders.attributes.status.placed'),
icon: 'x',
color: 'red',
task: t('common.resources.orders.task.error_to_cancel')
task: t('apps.orders.task.error_to_cancel')
}

case 'approved:authorized:unfulfilled':
case 'approved:authorized:not_required':
return {
label: t('common.resources.orders.status.approved'),
label: t('resources.orders.attributes.status.approved'),
icon: 'creditCard',
color: 'orange',
task: t('common.resources.orders.task.payment_to_capture')
task: t('apps.orders.task.payment_to_capture')
}

case 'approved:paid:in_progress':
case 'approved:partially_refunded:in_progress':
return {
label: t('common.resources.orders.status.in_progress'),
label: t('resources.orders.attributes.status.in_progress'),
icon: 'arrowClockwise',
color: 'orange',
task: t('common.resources.orders.task.fulfillment_in_progress')
task: t('apps.orders.task.fulfillment_in_progress')
}

case 'approved:authorized:in_progress':
return {
label: t('common.resources.orders.status.in_progress_manual'),
label: t('apps.orders.display_status.in_progress_manual'),
icon: 'arrowClockwise',
color: 'orange',
task: t('common.resources.orders.task.fulfillment_in_progress')
task: t('apps.orders.task.fulfillment_in_progress')
}

case 'approved:paid:fulfilled':
return {
label: t('common.resources.orders.fulfillment_status.fulfilled'),
label: t('resources.orders.attributes.fulfillment_status.fulfilled'),
icon: 'check',
color: 'green'
}

// TODO: This could be a gift-card and what If i do return?
case 'approved:free:fulfilled':
return {
label: t('common.resources.orders.fulfillment_status.fulfilled'),
label: t('resources.orders.attributes.fulfillment_status.fulfilled'),
icon: 'check',
color: 'green'
}

case 'approved:paid:not_required':
case 'approved:partially_refunded:not_required':
return {
label: t('common.resources.orders.status.approved'),
label: t('resources.orders.attributes.status.approved'),
icon: 'check',
color: 'green'
}

case 'approved:free:not_required':
return {
label: t('common.resources.orders.status.approved'),
label: t('resources.orders.attributes.status.approved'),
icon: 'check',
color: 'green'
}

case 'approved:partially_refunded:fulfilled':
return {
label: t('common.resources.orders.payment_status.partially_refunded'),
label: t(
'resources.orders.attributes.payment_status.partially_refunded'
),
icon: 'check',
color: 'green'
}
Expand All @@ -115,14 +117,14 @@ export function getOrderDisplayStatus(order: Order): OrderDisplayStatus {
case 'cancelled:unpaid:unfulfilled':
case 'cancelled:free:unfulfilled':
return {
label: t('common.resources.orders.status.cancelled'),
label: t('resources.orders.attributes.status.cancelled'),
icon: 'x',
color: 'gray'
}

case 'cancelled:refunded:fulfilled':
return {
label: t('common.resources.orders.status.cancelled'),
label: t('resources.orders.attributes.status.cancelled'),
icon: 'x',
color: 'gray'
}
Expand All @@ -131,14 +133,14 @@ export function getOrderDisplayStatus(order: Order): OrderDisplayStatus {
case 'pending:authorized:unfulfilled':
case 'pending:free:unfulfilled':
return {
label: t('common.resources.orders.status.pending'),
label: t('resources.orders.attributes.status.pending'),
icon: 'shoppingBag',
color: 'white'
}

default:
return {
label: `${t('common.resources.common.status.not_handled')}: (${combinedStatus})`,
label: `${t('common.not_handled')}: (${combinedStatus})`,
icon: 'warning',
color: 'white'
}
Expand Down Expand Up @@ -169,13 +171,13 @@ export function getOrderTransactionName(

export function getOrderStatusName(status: Order['status']): string {
const dictionary: Record<typeof status, string> = {
approved: t('common.resources.orders.status.approved'),
cancelled: t('common.resources.orders.status.cancelled'),
draft: t('common.resources.orders.status.draft'),
editing: t('common.resources.orders.status.editing'),
pending: t('common.resources.orders.status.pending'),
placed: t('common.resources.orders.status.placed'),
placing: t('common.resources.orders.status.placing')
approved: t('resources.orders.attributes.status.approved'),
cancelled: t('resources.orders.attributes.status.cancelled'),
draft: t('resources.orders.attributes.status.draft'),
editing: t('resources.orders.attributes.status.editing'),
pending: t('resources.orders.attributes.status.pending'),
placed: t('resources.orders.attributes.status.placed'),
placing: t('resources.orders.attributes.status.placing')
}

return dictionary[status]
Expand All @@ -185,21 +187,23 @@ export function getOrderPaymentStatusName(
status: Order['payment_status']
): string {
const dictionary: Record<typeof status, string> = {
authorized: t('common.resources.orders.payment_status.authorized'),
paid: t('common.resources.orders.payment_status.paid'),
unpaid: t('common.resources.orders.payment_status.unpaid'),
free: t('common.resources.orders.payment_status.free'),
voided: t('common.resources.orders.payment_status.voided'),
refunded: t('common.resources.orders.payment_status.refunded'),
authorized: t('resources.orders.attributes.payment_status.authorized'),
paid: t('resources.orders.attributes.payment_status.paid'),
unpaid: t('resources.orders.attributes.payment_status.unpaid'),
free: t('resources.orders.attributes.payment_status.free'),
voided: t('resources.orders.attributes.payment_status.voided'),
refunded: t('resources.orders.attributes.payment_status.refunded'),
partially_authorized: t(
'common.resources.orders.payment_status.partially_authorized'
'resources.orders.attributes.payment_status.partially_authorized'
),
partially_paid: t(
'resources.orders.attributes.payment_status.partially_paid'
),
partially_paid: t('common.resources.orders.payment_status.partially_paid'),
partially_refunded: t(
'common.resources.orders.payment_status.partially_refunded'
'resources.orders.attributes.payment_status.partially_refunded'
),
partially_voided: t(
'common.resources.orders.payment_status.partially_voided'
'resources.orders.attributes.payment_status.partially_voided'
)
}

Expand All @@ -210,10 +214,16 @@ export function getOrderFulfillmentStatusName(
status: Order['fulfillment_status']
): string {
const dictionary: Record<typeof status, string> = {
unfulfilled: t('common.resources.orders.fulfillment_status.unfulfilled'),
in_progress: t('common.resources.orders.fulfillment_status.in_progress'),
fulfilled: t('common.resources.orders.fulfillment_status.fulfilled'),
not_required: t('common.resources.orders.fulfillment_status.not_required')
unfulfilled: t(
'resources.orders.attributes.fulfillment_status.unfulfilled'
),
in_progress: t(
'resources.orders.attributes.fulfillment_status.in_progress'
),
fulfilled: t('resources.orders.attributes.fulfillment_status.fulfilled'),
not_required: t(
'resources.orders.attributes.fulfillment_status.not_required'
)
}

return dictionary[status]
Expand Down
10 changes: 5 additions & 5 deletions packages/app-elements/src/dictionaries/promotions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function getPromotionDisplayStatus(
if (promotion.disabled_at != null) {
return {
status: 'disabled',
label: t('common.resources.promotions.status.disabled'),
label: t('resources.promotions.attributes.status.disabled'),
icon: 'minus',
color: 'lightGray'
}
Expand All @@ -30,7 +30,7 @@ export function getPromotionDisplayStatus(
) {
return {
status: 'used',
label: t('common.resources.promotions.status.expired'),
label: t('resources.promotions.attributes.status.expired'),
icon: 'flag',
color: 'gray'
}
Expand All @@ -40,23 +40,23 @@ export function getPromotionDisplayStatus(
case 'past':
return {
status: 'expired',
label: t('common.resources.promotions.status.expired'),
label: t('resources.promotions.attributes.status.expired'),
icon: 'flag',
color: 'gray'
}

case 'upcoming':
return {
status: 'upcoming',
label: t('common.resources.promotions.status.upcoming'),
label: t('resources.promotions.attributes.status.upcoming'),
icon: 'calendarBlank',
color: 'gray'
}

case 'active':
return {
status: 'active',
label: t('common.resources.promotions.status.active'),
label: t('resources.promotions.attributes.status.active'),
icon: 'pulse',
color: 'green'
}
Expand Down
Loading

0 comments on commit 759e87c

Please sign in to comment.