@pradip1995/segment-animation-order 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +44 -0
- package/src/animation-order.css +823 -0
- package/src/confirmation-back-handler.tsx +32 -0
- package/src/index.ts +2 -0
- package/src/manifest.ts +11 -0
- package/src/order-actions-server.ts +52 -0
- package/src/order-actions.tsx +341 -0
- package/src/order-details.tsx +253 -0
- package/src/order-status.tsx +252 -0
- package/src/order-tracking.tsx +412 -0
- package/src/product-details-path.ts +22 -0
- package/src/segment.tsx +79 -0
package/src/segment.tsx
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { HttpTypes } from "@medusajs/types"
|
|
2
|
+
import AnimationOrderStatus from "./order-status"
|
|
3
|
+
import OrderDetailsView from "./order-details"
|
|
4
|
+
import { isLoggedInCustomerAction } from "./order-actions-server"
|
|
5
|
+
import LocalizedLink from "@pradip1995/segment-primitives/localized-link"
|
|
6
|
+
import "./animation-order.css"
|
|
7
|
+
|
|
8
|
+
export type AnimationOrderProps = {
|
|
9
|
+
order?: HttpTypes.StoreOrder | null
|
|
10
|
+
view?: "confirmed" | "failed" | "details" | string
|
|
11
|
+
isLoggedIn?: boolean
|
|
12
|
+
shopName?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function OrderNotFound() {
|
|
16
|
+
return (
|
|
17
|
+
<section className="anim-order anim-order--details" data-testid="segment-animation-order-empty">
|
|
18
|
+
<div className="anim-order__atmosphere" aria-hidden />
|
|
19
|
+
<div className="anim-order__inner">
|
|
20
|
+
<header className="anim-order__hero">
|
|
21
|
+
<p className="anim-order__eyebrow">Order</p>
|
|
22
|
+
<h1 className="anim-order__title">Order not found</h1>
|
|
23
|
+
<p className="anim-order__subtitle">
|
|
24
|
+
We couldn't find this order. Check the link or sign in to your account.
|
|
25
|
+
</p>
|
|
26
|
+
</header>
|
|
27
|
+
<div className="anim-order__actions">
|
|
28
|
+
<LocalizedLink href="/account" className="anim-order__btn anim-order__btn--primary">
|
|
29
|
+
Go to account
|
|
30
|
+
</LocalizedLink>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</section>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default async function AnimationOrder({
|
|
38
|
+
order,
|
|
39
|
+
view,
|
|
40
|
+
isLoggedIn: isLoggedInProp,
|
|
41
|
+
shopName,
|
|
42
|
+
}: AnimationOrderProps) {
|
|
43
|
+
const resolvedView = view || "details"
|
|
44
|
+
|
|
45
|
+
if (resolvedView === "failed") {
|
|
46
|
+
return (
|
|
47
|
+
<AnimationOrderStatus
|
|
48
|
+
order={order}
|
|
49
|
+
view="failed"
|
|
50
|
+
shopName={shopName}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (resolvedView === "confirmed") {
|
|
56
|
+
if (!order) return <OrderNotFound />
|
|
57
|
+
const isLoggedIn =
|
|
58
|
+
typeof isLoggedInProp === "boolean"
|
|
59
|
+
? isLoggedInProp
|
|
60
|
+
: await isLoggedInCustomerAction()
|
|
61
|
+
return (
|
|
62
|
+
<AnimationOrderStatus
|
|
63
|
+
order={order}
|
|
64
|
+
view="confirmed"
|
|
65
|
+
isLoggedIn={isLoggedIn}
|
|
66
|
+
shopName={shopName}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!order) return <OrderNotFound />
|
|
72
|
+
|
|
73
|
+
const isLoggedIn =
|
|
74
|
+
typeof isLoggedInProp === "boolean"
|
|
75
|
+
? isLoggedInProp
|
|
76
|
+
: await isLoggedInCustomerAction()
|
|
77
|
+
|
|
78
|
+
return <OrderDetailsView order={order} isLoggedIn={isLoggedIn} />
|
|
79
|
+
}
|