#Trying to load page, get HotReload

11 messages · Page 1 of 1 (latest)

vestal rain
#
import EmptyState from "@/components/EmptyState";

import prisma from "@/libs/prismadb";
import { getSession } from "../../libs/actions/getCurrentUser";
import Heading from "../../components/Heading";

import Container from "../../components/Container";

import ListingCardContainer from "../../components/listings/ListingCardContainer";
import { Suspense } from "react";

const PropertiesPage = async () => {
  const session = await getSession();
  const listings = await prisma.listing.findMany({
    where: {
      userId: session?.user?.id,
    },
  });

  if (listings.length === 0) {
    return (
      <EmptyState
        title="No properties found"
        subtitle="Looks like you have no properties."
      />
    );
  }

  return (
    <Container>
      <Heading title="Properties" subtitle="List of your properties" />
      <div
        className="
          mt-10
          grid
          grid-cols-1
          sm:grid-cols-2
          md:grid-cols-3
          lg:grid-cols-4
          xl:grid-cols-5
          2xl:grid-cols-6
          gap-8
        "
      >
        <Suspense fallback={<div>Loading...</div>}>
          <ListingCardContainer listings={listings} />
        </Suspense>
      </div>
    </Container>
  );
};

export default PropertiesPage;

// container.tsx

"use client";

function ListingCardContainer(listings: any) {
  return (
    <>
      {listings.map((listing: any) => (
        <div key={listing.id}>Something</div>
      ))}
    </>
  );
}

export default ListingCardContainer;
wheat steppe
#

getSession can't be used in the server...

#

use getServerSession

#

try changing ur getSession() into getServerSession(authOption) (import your own authOption)

vestal rain
#

think i found it 😄

#

its not getSession sorry

#

yes i do that its caleld getSession sorry i rename it 😄

#

i think i found solution

#

listing didnt return listings, but a key called "listings" with listings inside

#

no that wasn't the issue hmm