-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor cart and add total price (#112)
- Loading branch information
1 parent
a650913
commit c78c548
Showing
12 changed files
with
210 additions
and
102 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use client"; | ||
|
||
import { useHeroContext } from "@/components/contexts/HeroContext"; | ||
|
||
export default function SelectedCurrency({ | ||
baseCurrencyTotal, | ||
}: { | ||
baseCurrencyTotal: number; | ||
}) { | ||
const { selectedCurrency } = useHeroContext(); | ||
|
||
return ( | ||
<div> | ||
<div>total</div> | ||
<div> base currency: {baseCurrencyTotal}</div> | ||
<div> | ||
todo: convert to {selectedCurrency}: {baseCurrencyTotal} | ||
</div> | ||
</div> | ||
); | ||
} |
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,19 @@ | ||
import { getCookieCart } from "@/lib/utils/cart"; | ||
import SelectedCurrency from "./SelectedCurrency"; | ||
|
||
export default function TotalPrice() { | ||
const cartData = getCookieCart(); | ||
|
||
if (!cartData) return; | ||
|
||
const total = Object.values(cartData.products).reduce( | ||
(acc, p) => acc + p.price, | ||
0, | ||
); | ||
|
||
return ( | ||
<div> | ||
<SelectedCurrency baseCurrencyTotal={total} /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.