-
-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #414 from medusajs/v2
merge v2 branch into main
- Loading branch information
Showing
5 changed files
with
9,197 additions
and
5,431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/modules/layout/components/cart-mismatch-banner/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"use client" | ||
|
||
import { transferCart } from "@lib/data/customer" | ||
import { ExclamationCircleSolid } from "@medusajs/icons" | ||
import { StoreCart, StoreCustomer } from "@medusajs/types" | ||
import { Button } from "@medusajs/ui" | ||
import { useState } from "react" | ||
|
||
function CartMismatchBanner(props: { | ||
customer: StoreCustomer | ||
cart: StoreCart | ||
}) { | ||
const { customer, cart } = props | ||
const [isPending, setIsPending] = useState(false) | ||
const [actionText, setActionText] = useState("Run transfer again") | ||
|
||
if (!customer || !!cart.customer_id) { | ||
return | ||
} | ||
|
||
const handleSubmit = async () => { | ||
try { | ||
setIsPending(true) | ||
setActionText("Transferring..") | ||
|
||
await transferCart() | ||
} catch { | ||
setActionText("Run transfer again") | ||
setIsPending(false) | ||
} | ||
} | ||
|
||
return ( | ||
<div className="flex items-center justify-center small:p-4 p-2 text-center bg-orange-300 small:gap-2 gap-1 text-sm mt-2 text-orange-800"> | ||
<div className="flex flex-col small:flex-row small:gap-2 gap-1 items-center"> | ||
<span className="flex items-center gap-1"> | ||
<ExclamationCircleSolid className="inline" /> | ||
Something went wrong when we tried to transfer your cart | ||
</span> | ||
|
||
<span>·</span> | ||
|
||
<Button | ||
variant="transparent" | ||
className="hover:bg-transparent active:bg-transparent focus:bg-transparent disabled:text-orange-500 text-orange-950 p-0 bg-transparent" | ||
size="base" | ||
disabled={isPending} | ||
onClick={handleSubmit} | ||
> | ||
{actionText} | ||
</Button> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default CartMismatchBanner |
Oops, something went wrong.