Skip to content

Commit

Permalink
oof. i
Browse files Browse the repository at this point in the history
  • Loading branch information
ripgrim committed Sep 22, 2024
1 parent 1cb9c1e commit a0d2be6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 37 deletions.
15 changes: 10 additions & 5 deletions src/app/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ import { FlipWords } from "@/components/ui/flip-words";
import { FloatingNav } from "@/components/ui/floating-navbar";
import ShinyGrid from "@/components/ui/ShinyGrid";
import { LucideHome, Info, ArrowDownToLine } from "lucide-react";
import { handleGoShopping } from '@/helpers/navigationHelpers';

export default function Home() {
const router = useRouter()

const handleGoShoppingClick = () => handleGoShopping();
const handleGoShopping = () => {
if (localStorage.getItem("setupSkipped")) {
router.push('/cart')
} else {
router.push('/step/1')
}
}

const navItems = [
{
Expand Down Expand Up @@ -70,7 +75,7 @@ export default function Home() {
EZ Cart
</div>
<div className="flex flex-row">
<Button size="lg" className="rounded-full bg-white text-black hover:bg-gray-200" onClick={handleGoShoppingClick}>
<Button size="lg" className="rounded-full bg-white text-black hover:bg-gray-200" onClick={handleGoShopping}>
Go Shopping
</Button>
</div>
Expand All @@ -93,7 +98,7 @@ export default function Home() {
>
Start shopping smarter
</Button> */}
<Button size="lg" className="rounded-full bg-white text-black hover:bg-gray-200" onClick={handleGoShoppingClick}>
<Button size="lg" className="rounded-full bg-white text-black hover:bg-gray-200" onClick={handleGoShopping}>
Start shopping smarter
</Button>
<p className="text-sm text-gray-400 mt-4">No registration required</p>
Expand Down Expand Up @@ -147,7 +152,7 @@ export default function Home() {
EZ Cart automatically applies the correct sales tax<br />for your state, ensuring accurate totals every time
</p>
<p className="text-sm text-gray-400 mt-4 mb-4">(Currently available for USA only)</p>
<Button size="lg" className="rounded-full bg-white text-black hover:bg-gray-200" onClick={handleGoShoppingClick}>
<Button size="lg" className="rounded-full bg-white text-black hover:bg-gray-200" onClick={handleGoShopping}>
Calculate with confidence
</Button>
<p className="text-sm text-gray-400 mt-4">Supports all 50 states</p>
Expand Down
52 changes: 26 additions & 26 deletions src/app/cart/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ function CartContent() {
<div className="flex flex-col py-2 mb-2 w-full">
<div className="flex justify-between items-center">
<span className="text-sm text-white">Subtotal:</span>
{formatNumber(subtotal)} {selectedCountry?.code || ''}
<span className="text-white">{formatNumber(subtotal)} {selectedCountry?.code || ''}</span>
</div>
{selectedRegion && (
<div className="flex justify-between items-center mt-1">
<span className="text-sm text-white">Tax ({taxRate}%):</span>
{formatNumber(taxAmount)} {selectedCountry?.code}
<span className="text-white">{formatNumber(taxAmount)} {selectedCountry?.code}</span>
</div>
)}
<div className="flex justify-between items-center mt-1">
Expand All @@ -261,33 +261,33 @@ function CartContent() {
{formatNumber(total)} {selectedCountry?.code || ''}
</TextTransition>
</div>
</div>
<form onSubmit={handleSubmit} className="flex flex-col space-y-2 pb-4 w-full">
<Input
type="text"
name="itemName"
placeholder="Item name"
className="w-full text-lg h-12 text-white font-normal border-2 border-[#383838] rounded-md placeholder-gray-400"
ref={itemNameInputRef}
maxLength={100}
onKeyDown={handleItemNameKeyDown}
/>
<div className="flex space-x-2 w-full">
<form onSubmit={handleSubmit} className="flex flex-col space-y-2 pb-4 w-full">
<Input
type="text"
name="itemPrice"
inputMode="decimal"
placeholder="Price"
className="flex-grow text-lg h-12 text-white font-normal border-2 border-[#383838] rounded-md placeholder-gray-400"
ref={itemPriceInputRef}
maxLength={10}
onKeyDown={handlePriceKeyDown}
name="itemName"
placeholder="Item name"
className="w-full text-lg h-12 text-white font-normal border-2 border-[#383838] rounded-md placeholder-gray-400"
ref={itemNameInputRef}
maxLength={100}
onKeyDown={handleItemNameKeyDown}
/>
<Button type="submit" size="icon" className="h-12 w-12 bg-white text-black">
<Plus className="h-6 w-6" />
</Button>
</div>
</form>
<div className="flex space-x-2 w-full">
<Input
type="text"
name="itemPrice"
inputMode="decimal"
placeholder="Price"
className="flex-grow text-lg h-12 text-white font-normal border-2 border-[#383838] rounded-md placeholder-gray-400"
ref={itemPriceInputRef}
maxLength={10}
onKeyDown={handlePriceKeyDown}
/>
<Button type="submit" size="icon" className="h-12 w-12 bg-white text-black">
<Plus className="h-6 w-6" />
</Button>
</div>
</form>
</div>
</div>
</div>
<ConfirmationModal
Expand Down
12 changes: 9 additions & 3 deletions src/components/ui/floating-navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ export const FloatingNav = ({
};
}, [scrollTimer]);

const router = useRouter();
const handleGoShopping = () => {
if (localStorage.getItem("setupSkipped")) {
router.push('/cart')
} else {
router.push('/step/1')
}
}

const handleGoShoppingClick = () => handleGoShopping();
const router = useRouter();

useMotionValueEvent(scrollYProgress, "change", (current) => {
if (typeof current === "number") {
Expand Down Expand Up @@ -104,7 +110,7 @@ export const FloatingNav = ({
</Link>
</Button>
))}
<Button onClick={handleGoShoppingClick} className="transition-all duration-300 bg-white text-black border text-sm font-medium relative border-white px-4 py-2 rounded-full hover:bg-neutral-300 hover:text-black">
<Button onClick={handleGoShopping} className="transition-all duration-300 bg-white text-black border text-sm font-medium relative border-white px-4 py-2 rounded-full hover:bg-neutral-300 hover:text-black">
<span>Go Shopping</span>
<span className="absolute inset-x-0 w-1/2 mx-auto -bottom-px bg-gradient-to-r from-transparent via-blue-500 to-transparent h-px" />
</Button>
Expand Down
5 changes: 2 additions & 3 deletions src/helpers/navigationHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useRouter } from 'next/navigation';
import { NextRouter } from 'next/router';

export const handleGoShopping = () => {
const router = useRouter();
export const handleGoShopping = (router: NextRouter) => {
if (localStorage.getItem("setupSkipped")) {
router.push('/cart');
} else {
Expand Down

0 comments on commit a0d2be6

Please sign in to comment.