()
+
for (const ret of returns) {
+ returnMap.set(ret.id, ret)
+
+ if (ret.claim_id || ret.exchange_id) {
+ continue
+ }
+
// Always display created action
items.push({
title: t("orders.activity.events.return.created", {
@@ -192,6 +238,32 @@ const useActivityItems = (order: AdminOrder) => {
}
}
+ for (const claim of claims) {
+ const claimReturn = returnMap.get(claim.return_id!)
+
+ items.push({
+ title: t("orders.activity.events.claim.created", {
+ claimId: claim.id.slice(-7),
+ }),
+ timestamp: claim.created_at,
+ children: ,
+ })
+ }
+
+ for (const exchange of exchanges) {
+ const exchangeReturn = returnMap.get(exchange.return_id!)
+
+ items.push({
+ title: t("orders.activity.events.exchange.created", {
+ exchangeId: exchange.id.slice(-7),
+ }),
+ timestamp: exchange.created_at,
+ children: (
+
+ ),
+ })
+ }
+
// for (const note of notes || []) {
// items.push({
// title: t("orders.activity.events.note.comment"),
@@ -431,3 +503,83 @@ const ReturnBody = ({ orderReturn }: { orderReturn: AdminReturn }) => {
)
}
+
+const ClaimBody = ({
+ claim,
+ claimReturn,
+}: {
+ claim: AdminClaim
+ claimReturn?: AdminReturn
+}) => {
+ const { t } = useTranslation()
+
+ const outboundItems = (claim.additional_items || []).reduce(
+ (acc, item) => (acc + item.quantity) as number,
+ 0
+ )
+
+ const inboundItems = (claimReturn?.items || []).reduce(
+ (acc, item) => acc + item.quantity,
+ 0
+ )
+
+ return (
+
+ {outboundItems > 0 && (
+
+ {t("orders.activity.events.claim.itemsInbound", {
+ count: outboundItems,
+ })}
+
+ )}
+
+ {inboundItems > 0 && (
+
+ {t("orders.activity.events.claim.itemsOutbound", {
+ count: inboundItems,
+ })}
+
+ )}
+
+ )
+}
+
+const ExchangeBody = ({
+ exchange,
+ exchangeReturn,
+}: {
+ exchange: AdminExchange
+ exchangeReturn?: AdminReturn
+}) => {
+ const { t } = useTranslation()
+
+ const outboundItems = (exchange.additional_items || []).reduce(
+ (acc, item) => (acc + item.quantity) as number,
+ 0
+ )
+
+ const inboundItems = (exchangeReturn?.items || []).reduce(
+ (acc, item) => acc + item.quantity,
+ 0
+ )
+
+ return (
+
+ {outboundItems > 0 && (
+
+ {t("orders.activity.events.exchange.itemsInbound", {
+ count: outboundItems,
+ })}
+
+ )}
+
+ {inboundItems > 0 && (
+
+ {t("orders.activity.events.exchange.itemsOutbound", {
+ count: inboundItems,
+ })}
+
+ )}
+
+ )
+}