diff --git a/src/app/(root)/(routes)/dashboard/page.tsx b/src/app/(root)/(routes)/dashboard/page.tsx
index a7daa9b..bb90879 100644
--- a/src/app/(root)/(routes)/dashboard/page.tsx
+++ b/src/app/(root)/(routes)/dashboard/page.tsx
@@ -1,9 +1,106 @@
"use client";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "@/components/ui/card";
-import React from "react";
+import { auth, useUser } from "@clerk/nextjs";
+import Link from "next/link";
+import axios from "axios";
+import { useState, useEffect } from "react";
+import { Search } from "@prisma/client";
+import { Button } from "@/components/ui/button";
const dashboardPage = () => {
- return
dashboardPage
;
+ const [searches, setSearches] = useState(null);
+ const { user } = useUser();
+ useEffect(() => {
+ const fetchSearches = async () => {
+ if (user) {
+ try {
+ const response = await axios.post(`/api/get-searches`, {
+ userId: user.id,
+ });
+ setSearches(response.data);
+ } catch (error) {
+ console.log("Error feteching searches: ", error);
+ }
+ }
+ };
+ fetchSearches();
+ }, [user]);
+
+ const formatDate = (dateString) => {
+ // Check if dateString is not provided or is empty
+ if (!dateString) {
+ return "N/A";
+ }
+
+ // Try to parse the dateString into a Date object
+ const date = new Date(dateString);
+
+ // Check if the date is valid
+ if (isNaN(date.getTime())) {
+ return "N/A";
+ }
+
+ // Format the date
+ return date.toLocaleDateString("en-US", {
+ day: "numeric",
+ month: "short",
+ year: "numeric",
+ });
+ };
+
+ if (searches == null) {
+ return Loading searches...
;
+ }
+
+ if (searches.length == 0) {
+ return No searches yet
;
+ }
+
+ return (
+
+ {searches.map((search, index) => (
+
+
+
+ {"Search " + (index + 1)}
+ {/* Card Description */}
+
+
+
+ -
+ Query: {search.query}
+
+ -
+ Filters:{" "}
+ {search.prefixFilters ? search.prefixFilters : "N/A"}
+
+ -
+ Search Period: {formatDate(search.minDate)} -{" "}
+ {formatDate(search.maxDate)}
+
+ -
+ Search Date: {formatDate(search.createdAt)}
+
+
+
+
+
+
+
+
+
+
+ ))}
+
+ );
};
export default dashboardPage;
diff --git a/src/app/components/Chat/Messages.tsx b/src/app/OLD_CODES/Chat/Messages.tsx
similarity index 100%
rename from src/app/components/Chat/Messages.tsx
rename to src/app/OLD_CODES/Chat/Messages.tsx
diff --git a/src/app/components/Chat/index.tsx b/src/app/OLD_CODES/Chat/index.tsx
similarity index 100%
rename from src/app/components/Chat/index.tsx
rename to src/app/OLD_CODES/Chat/index.tsx
diff --git a/src/app/components/Search/index.tsx b/src/app/OLD_CODES/Search/index.tsx
similarity index 100%
rename from src/app/components/Search/index.tsx
rename to src/app/OLD_CODES/Search/index.tsx
diff --git a/src/app/notused-dashboard/[searchId]/page.tsx b/src/app/OLD_CODES/[searchId]/page.tsx
similarity index 98%
rename from src/app/notused-dashboard/[searchId]/page.tsx
rename to src/app/OLD_CODES/[searchId]/page.tsx
index f4267cb..1247e85 100644
--- a/src/app/notused-dashboard/[searchId]/page.tsx
+++ b/src/app/OLD_CODES/[searchId]/page.tsx
@@ -2,8 +2,8 @@
import React, { useState } from "react";
import Header from "@/components/Header";
-import Chat from "@/components/Chat";
-import Search from "@/components/Search";
+import Chat from "@/OLD_CODES/Chat";
+import Search from "@/OLD_CODES/Search";
import dayjs from "dayjs";
import { useRouter } from "next/router";
diff --git a/src/app/notused-dashboard/page.tsx b/src/app/OLD_CODES/page.tsx
similarity index 98%
rename from src/app/notused-dashboard/page.tsx
rename to src/app/OLD_CODES/page.tsx
index f4267cb..1247e85 100644
--- a/src/app/notused-dashboard/page.tsx
+++ b/src/app/OLD_CODES/page.tsx
@@ -2,8 +2,8 @@
import React, { useState } from "react";
import Header from "@/components/Header";
-import Chat from "@/components/Chat";
-import Search from "@/components/Search";
+import Chat from "@/OLD_CODES/Chat";
+import Search from "@/OLD_CODES/Search";
import dayjs from "dayjs";
import { useRouter } from "next/router";
diff --git a/src/app/api/get-searches/route.ts b/src/app/api/get-searches/route.ts
new file mode 100644
index 0000000..a40ec65
--- /dev/null
+++ b/src/app/api/get-searches/route.ts
@@ -0,0 +1,16 @@
+import prismadb from "../../../lib/prismadb";
+import { NextResponse } from "next/server";
+
+export const POST = async (req: Request) => {
+ const { userId } = await req.json();
+ const _searches = await prismadb.search.findMany({
+ where: {
+ userId: userId,
+ },
+ orderBy: {
+ createdAt: 'desc'
+ }
+ });
+
+ return NextResponse.json(_searches);
+ };
\ No newline at end of file
diff --git a/src/app/components/search-card.tsx b/src/app/components/search-card.tsx
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/components/ui/card.tsx b/src/app/components/ui/card.tsx
new file mode 100644
index 0000000..afa13ec
--- /dev/null
+++ b/src/app/components/ui/card.tsx
@@ -0,0 +1,79 @@
+import * as React from "react"
+
+import { cn } from "@/lib/utils"
+
+const Card = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+Card.displayName = "Card"
+
+const CardHeader = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+CardHeader.displayName = "CardHeader"
+
+const CardTitle = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+CardTitle.displayName = "CardTitle"
+
+const CardDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+CardDescription.displayName = "CardDescription"
+
+const CardContent = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+CardContent.displayName = "CardContent"
+
+const CardFooter = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+CardFooter.displayName = "CardFooter"
+
+export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }