feat(dashboard,types): add credit lines + loyalty changes (#11885)
* feat(dashboard,types): add credit lines + loyalty changes * chore: fix types * chore: fix specs * chore: use correct plugin name * chore: use new currency input --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Oli Juhl
parent
65f9333501
commit
44d1d18689
@@ -0,0 +1,8 @@
|
||||
import { OrderCreditLineDTO } from "@medusajs/types"
|
||||
|
||||
export const getTotalCreditLines = (creditLines: OrderCreditLineDTO[]) =>
|
||||
creditLines.reduce((acc, creditLine) => {
|
||||
acc = acc + (creditLine.amount as number)
|
||||
|
||||
return acc
|
||||
}, 0)
|
||||
@@ -0,0 +1,8 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const getPaymentsFromOrder = (order: HttpTypes.AdminOrder) => {
|
||||
return order.payment_collections
|
||||
.map((collection: HttpTypes.AdminPaymentCollection) => collection.payments)
|
||||
.flat(1)
|
||||
.filter(Boolean) as HttpTypes.AdminPayment[]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const LOYALTY_PLUGIN_NAME = "@medusajs/loyalty-plugin"
|
||||
|
||||
export const getLoyaltyPlugin = (plugins: HttpTypes.AdminPlugin[]) => {
|
||||
return plugins?.find((plugin) => plugin.name === LOYALTY_PLUGIN_NAME)
|
||||
}
|
||||
Reference in New Issue
Block a user