Skip to content

Commit

Permalink
Fixed navbar menu toggle and product form rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
calvadev committed Sep 12, 2024
1 parent ece4dbd commit bd54d62
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 38 deletions.
2 changes: 1 addition & 1 deletion components/display-products.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const DisplayProducts = ({
productEventContext.isLoading ||
isProductsLoading ||
isLoadingMore ? (
<div className="mt-8 flex items-center justify-center">
<div className="mt-6 mb-6 flex items-center justify-center">
<ShopstrSpinner />
</div>
) : canShowLoadMore && productEvents.length != 0 ? (
Expand Down
26 changes: 1 addition & 25 deletions components/home/home-feed.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
"use client";

import React, { useEffect, useState } from "react";
import React from "react";

import MarketplacePage from "./marketplace";
import ProductForm from "../product-form";
import { useRouter } from "next/router";
import { useSearchParams } from "next/navigation";
import { isUserLoggedIn } from "../utility/nostr-helper-functions";

const HomeFeed = ({
focusedPubkey,
Expand All @@ -15,21 +11,6 @@ const HomeFeed = ({
focusedPubkey: string;
setFocusedPubkey: (value: string) => void;
}) => {
const router = useRouter();
const searchParams = useSearchParams();

const [showModal, setShowModal] = useState(false);

useEffect(() => {
if (!searchParams || !isUserLoggedIn()) return;
setShowModal(searchParams.has("addNewListing"));
}, [searchParams]);

const handleProductModalToggle = () => {
setShowModal(!showModal);
router.push("/");
};

return (
<div className="flex flex-1 flex-col">
<div className="flex h-screen flex-1">
Expand All @@ -38,11 +19,6 @@ const HomeFeed = ({
setFocusedPubkey={setFocusedPubkey}
/>
</div>

<ProductForm
showModal={showModal}
handleModalToggle={handleProductModalToggle}
/>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion components/my-listings/my-listings-feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const MyListingsFeed = () => {

const handleProductModalToggle = () => {
setShowModal(!showModal);
router.push("/");
router.push("");
};

return (
Expand Down
18 changes: 9 additions & 9 deletions components/my-listings/my-listings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const MyListingsPage = () => {

const handleCreateNewListing = () => {
if (usersPubkey) {
router.push("/?addNewListing");
router.push("?addNewListing");
} else {
onOpen();
}
Expand All @@ -26,14 +26,6 @@ export const MyListingsPage = () => {
return (
<div className="mx-auto h-full w-full">
<div className="flex max-w-[100%] flex-col bg-light-bg px-3 pb-2 dark:bg-dark-bg">
<div>
<Button
className={`${SHOPSTRBUTTONCLASSNAMES} w-full`}
onClick={() => handleCreateNewListing()}
>
+ Add new listing
</Button>
</div>
{usersPubkey && (
<DisplayProducts
focusedPubkey={usersPubkey}
Expand All @@ -44,6 +36,14 @@ export const MyListingsPage = () => {
isMyListings={true}
/>
)}
<div>
<Button
className={`${SHOPSTRBUTTONCLASSNAMES} w-full`}
onClick={() => handleCreateNewListing()}
>
+ Add new listing
</Button>
</div>
</div>
<SignInModal isOpen={isOpen} onClose={onClose} />
</div>
Expand Down
2 changes: 2 additions & 0 deletions components/nav-top.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const TopNav = ({
const handleRoute = (path: string) => {
if (signedIn) {
router.push(path);
setIsMobileMenuOpen(false);
} else {
onOpen();
}
Expand All @@ -88,6 +89,7 @@ const TopNav = ({
const handleHomeClick = () => {
setFocusedPubkey("");
router.push("/");
setIsMobileMenuOpen(false);
};

const MobileMenu = () => (
Expand Down
4 changes: 2 additions & 2 deletions pages/my-listings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import MyListingsPage from "@/components/my-listings/my-listings";
import MyListingsFeed from "@/components/my-listings/my-listings-feed";

export default function ShopView() {
return (
<div className="flex h-full min-h-screen flex-col bg-light-bg pt-24 dark:bg-dark-bg">
<MyListingsPage />
<MyListingsFeed />
</div>
);
}

0 comments on commit bd54d62

Please sign in to comment.