From 8131b37f291640fa504c5a667cd17a4815715fb5 Mon Sep 17 00:00:00 2001 From: Aritra Konar Date: Tue, 27 May 2025 21:45:20 +0000 Subject: [PATCH] --implementation of sanity(CMS) --- app/Events/page.tsx | 124 ++++++++++++++++++++++++++++++++++++ app/NavBar/page.tsx | 8 ++- lib/sanity.ts | 8 +++ package.json | 2 + pnpm-lock.yaml | 150 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 app/Events/page.tsx create mode 100644 lib/sanity.ts diff --git a/app/Events/page.tsx b/app/Events/page.tsx new file mode 100644 index 0000000..1ddab72 --- /dev/null +++ b/app/Events/page.tsx @@ -0,0 +1,124 @@ +"use client"; +import React, { useState, useEffect } from "react"; +import NavBar from "../NavBar/page"; +import Footer from "../Footer/page"; +import { motion, AnimatePresence } from "framer-motion"; +import { sanity } from "@/lib/sanity"; // adjust path as needed + +// GROQ query for your event schema +const query = `*[_type == "event"]{ + _id, + title, + date, + location, + description, + images[]{ + asset->{ + _id, + url + } + } +}`; + +const EventCard = ({ event }: { event: any }) => ( + + {event.images && event.images[0]?.asset?.url && ( + {event.title} + )} +
+

+ {event.title} +

+
+ + {event.date ? new Date(event.date).toLocaleDateString() : ""} + + · {event.location} +
+

+ {event.description} +

+
+
+); + +const EventsPage = () => { + const [search, setSearch] = useState(""); + const [events, setEvents] = useState([]); + + useEffect(() => { + sanity.fetch(query).then(setEvents); + }, []); + + const filteredEvents = events.filter((event) => { + const searchText = search.toLowerCase(); + return ( + event.title?.toLowerCase().includes(searchText) || + event.description?.toLowerCase().includes(searchText) || + event.location?.toLowerCase().includes(searchText) + ); + }); + + return ( +
+ +
+ +

+ Upcoming Events +

+

+ Stay updated with our latest events, workshops, and meetups. +

+
+
+ setSearch(e.target.value)} + className="w-full max-w-md px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-primary text-black" + /> +
+ +
+ {filteredEvents.length > 0 ? ( + filteredEvents.map((event) => ( + + )) + ) : ( + + No events found. + + )} +
+
+
+
+ ); +}; + +export default EventsPage; \ No newline at end of file diff --git a/app/NavBar/page.tsx b/app/NavBar/page.tsx index ca93f9e..e437e6b 100644 --- a/app/NavBar/page.tsx +++ b/app/NavBar/page.tsx @@ -1,7 +1,7 @@ "use client" import * as React from "react" -import { Home, User, AppWindowIcon, LogInIcon, ImageIcon } from "lucide-react" +import { Home, User, AppWindowIcon, LogInIcon, ImageIcon, CalendarSearchIcon } from "lucide-react" import { AnimeNavBar } from "@/components/ui/anime-navbar" const items = [ @@ -11,6 +11,12 @@ const items = [ href: "#", icon: Home, }, + { + name: "Events", + url: "/Events", + href: "#", + icon: CalendarSearchIcon, + }, { name: "Team", url: "/Team", diff --git a/lib/sanity.ts b/lib/sanity.ts new file mode 100644 index 0000000..6d832c4 --- /dev/null +++ b/lib/sanity.ts @@ -0,0 +1,8 @@ +import { createClient } from '@sanity/client'; + +export const sanity = createClient({ + projectId: 'ozbeszd1', // find this in sanity.json or your project dashboard + dataset: 'production', + apiVersion: '2023-01-01', + useCdn: true, +}); \ No newline at end of file diff --git a/package.json b/package.json index 29a56df..b25caff 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "@clerk/nextjs": "^6.12.9", + "@portabletext/react": "^3.2.1", "@radix-ui/react-avatar": "^1.1.3", "@radix-ui/react-checkbox": "^1.1.4", "@radix-ui/react-dialog": "^1.1.6", @@ -23,6 +24,7 @@ "@radix-ui/react-switch": "^1.1.3", "@radix-ui/react-tabs": "^1.1.12", "@radix-ui/react-tooltip": "^1.1.8", + "@sanity/client": "^7.3.0", "@shadcn/ui": "^0.0.4", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e8dba33..a43c543 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@clerk/nextjs': specifier: ^6.12.9 version: 6.12.9(next@15.1.2(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@portabletext/react': + specifier: ^3.2.1 + version: 3.2.1(react@19.0.0) '@radix-ui/react-avatar': specifier: ^1.1.3 version: 1.1.3(@types/react-dom@19.0.4(@types/react@19.0.12))(@types/react@19.0.12)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) @@ -50,6 +53,9 @@ importers: '@radix-ui/react-tooltip': specifier: ^1.1.8 version: 1.1.8(@types/react-dom@19.0.4(@types/react@19.0.12))(@types/react@19.0.12)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@sanity/client': + specifier: ^7.3.0 + version: 7.3.0 '@shadcn/ui': specifier: ^0.0.4 version: 0.0.4 @@ -458,6 +464,20 @@ packages: '@popperjs/core@2.11.8': resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} + '@portabletext/react@3.2.1': + resolution: {integrity: sha512-RyFLk6u2q6ZyABTdOk+xoNR2Tq/4fcQFEWayNk4Kbd3gHpUUTabqOrDMChcmG6C7YVLSpwIEBwHoBVcy4vK/hA==} + engines: {node: ^14.13.1 || >=16.0.0} + peerDependencies: + react: ^17 || ^18 || >=19.0.0-0 + + '@portabletext/toolkit@2.0.17': + resolution: {integrity: sha512-5wj+oUaCmHm9Ay1cytPmT1Yc0SrR1twwUIc0qNQ3MtaXaNMPw99Gjt1NcA34yfyKmEf/TAB2NiiT72jFxdddIQ==} + engines: {node: ^14.13.1 || >=16.0.0} + + '@portabletext/types@2.0.13': + resolution: {integrity: sha512-5xk5MSyQU9CrDho3Rsguj38jhijhD36Mk8S6mZo3huv6PM+t4M/5kJN2KFIxgvt4ONpvOEs1pVIZAV0cL0Vi+Q==} + engines: {node: ^14.13.1 || >=16.0.0 || >=18.0.0} + '@radix-ui/number@1.1.0': resolution: {integrity: sha512-V3gRzhVNU1ldS5XhAPTom1fOIo4ccrjjJgmE+LI2h/WaFpHmx0MQApT+KZHnx8abG6Avtfcz4WoEciMnpFT3HQ==} @@ -1039,6 +1059,13 @@ packages: '@rushstack/eslint-patch@1.11.0': resolution: {integrity: sha512-zxnHvoMQVqewTJr/W4pKjF0bMGiKJv1WX7bSrkl46Hg0QjESbzBROWK0Wg4RphzSOS5Jiy7eFimmM3UgMrMZbQ==} + '@sanity/client@7.3.0': + resolution: {integrity: sha512-VmzlvGwvWRNxEqAYHNDdvB6u0460C38fPJSHUaIcdBCTBWKMeCgIE8QI1w4PxO0PiYuWgERexRS2OrF+OYh3tQ==} + engines: {node: '>=20'} + + '@sanity/eventsource@5.0.2': + resolution: {integrity: sha512-/B9PMkUvAlUrpRq0y+NzXgRv5lYCLxZNsBJD2WXVnqZYOfByL9oQBV7KiTaARuObp5hcQYuPfOAVjgXe3hrixA==} + '@shadcn/ui@0.0.4': resolution: {integrity: sha512-0dtu/5ApsOZ24qgaZwtif8jVwqol7a4m1x5AxPuM1k5wxhqU7t/qEfBGtaSki1R8VlbTQfCj5PAlO45NKCa7Gg==} hasBin: true @@ -1082,6 +1109,15 @@ packages: '@types/estree@1.0.7': resolution: {integrity: sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==} + '@types/event-source-polyfill@1.0.5': + resolution: {integrity: sha512-iaiDuDI2aIFft7XkcwMzDWLqo7LVDixd2sR6B4wxJut9xcp/Ev9bO4EFg4rm6S9QxATLBj5OPxdeocgmhjwKaw==} + + '@types/eventsource@1.1.15': + resolution: {integrity: sha512-XQmGcbnxUNa06HR3VBVkc9+A2Vpi9ZyLJcdS5dwaQQ/4ZMWFO+5c90FnMUpbtMZwB/FChoYHwuVg8TvkECacTA==} + + '@types/follow-redirects@1.14.4': + resolution: {integrity: sha512-GWXfsD0Jc1RWiFmMuMFCpXMzi9L7oPDVwxUnZdg89kDNnqsRfUKXEtUYtA98A6lig1WXH/CYY/fvPW9HuN5fTA==} + '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} @@ -1531,6 +1567,10 @@ packages: decimal.js-light@2.5.1: resolution: {integrity: sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==} + decompress-response@7.0.0: + resolution: {integrity: sha512-6IvPrADQyyPGLpMnUh6kfKiqy7SrbXbjoUuZ90WMBJKErzv2pCiwlGEXjRX9/54OnTq+XFVnkOnOMzclLI5aEA==} + engines: {node: '>=10'} + deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} @@ -1750,9 +1790,16 @@ packages: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} + event-source-polyfill@1.0.31: + resolution: {integrity: sha512-4IJSItgS/41IxN5UVAVuAyczwZF7ZIEsM1XAoUzIHA6A+xzusEZUutdXz2Nr+MQPLxfTiCvqE79/C8HT8fKFvA==} + eventemitter3@4.0.7: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} + eventsource@2.0.2: + resolution: {integrity: sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==} + engines: {node: '>=12.0.0'} + execa@7.2.0: resolution: {integrity: sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==} engines: {node: ^14.18.0 || ^16.14.0 || >=18.0.0} @@ -1812,6 +1859,15 @@ packages: flatted@3.3.3: resolution: {integrity: sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==} + follow-redirects@1.15.9: + resolution: {integrity: sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + for-each@0.3.5: resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==} engines: {node: '>= 0.4'} @@ -1861,6 +1917,10 @@ packages: resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==} engines: {node: '>= 0.4'} + get-it@8.6.9: + resolution: {integrity: sha512-CSUbVbfTZZbRrPqiMPaV3mWw+3MDgRPANtqBxLSp94cUUUZVAZfjGDwArvu5z2bx5ABW2MNB5kdT3PTOxe3cTw==} + engines: {node: '>=14.0.0'} + get-nonce@1.0.1: resolution: {integrity: sha512-FJhYRoDaiatfEkUK8HKlicmu/3SGFD51q3itKDGoSTysQJBnfOcxU5GxnhE1E6soB76MbT0MBtnKJuXyAx+96Q==} engines: {node: '>=6'} @@ -2060,6 +2120,10 @@ packages: resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==} engines: {node: '>= 0.4'} + is-retry-allowed@2.2.0: + resolution: {integrity: sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg==} + engines: {node: '>=10'} + is-set@2.0.3: resolution: {integrity: sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==} engines: {node: '>= 0.4'} @@ -2229,6 +2293,10 @@ packages: resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} engines: {node: '>=12'} + mimic-response@3.1.0: + resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} + engines: {node: '>=10'} + minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} @@ -2630,6 +2698,9 @@ packages: run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + rxjs@7.8.2: + resolution: {integrity: sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==} + safe-array-concat@1.1.3: resolution: {integrity: sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q==} engines: {node: '>=0.4'} @@ -2843,6 +2914,9 @@ packages: thenify@3.3.1: resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==} + through2@4.0.2: + resolution: {integrity: sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==} + tiny-invariant@1.3.3: resolution: {integrity: sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==} @@ -2869,6 +2943,9 @@ packages: tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + tunnel-agent@0.6.0: + resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} + type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -3310,6 +3387,18 @@ snapshots: '@popperjs/core@2.11.8': {} + '@portabletext/react@3.2.1(react@19.0.0)': + dependencies: + '@portabletext/toolkit': 2.0.17 + '@portabletext/types': 2.0.13 + react: 19.0.0 + + '@portabletext/toolkit@2.0.17': + dependencies: + '@portabletext/types': 2.0.13 + + '@portabletext/types@2.0.13': {} + '@radix-ui/number@1.1.0': {} '@radix-ui/primitive@1.1.1': {} @@ -3875,6 +3964,22 @@ snapshots: '@rushstack/eslint-patch@1.11.0': {} + '@sanity/client@7.3.0': + dependencies: + '@sanity/eventsource': 5.0.2 + get-it: 8.6.9 + nanoid: 3.3.11 + rxjs: 7.8.2 + transitivePeerDependencies: + - debug + + '@sanity/eventsource@5.0.2': + dependencies: + '@types/event-source-polyfill': 1.0.5 + '@types/eventsource': 1.1.15 + event-source-polyfill: 1.0.31 + eventsource: 2.0.2 + '@shadcn/ui@0.0.4': dependencies: chalk: 5.2.0 @@ -3923,6 +4028,14 @@ snapshots: '@types/estree@1.0.7': {} + '@types/event-source-polyfill@1.0.5': {} + + '@types/eventsource@1.1.15': {} + + '@types/follow-redirects@1.14.4': + dependencies: + '@types/node': 20.17.27 + '@types/json-schema@7.0.15': {} '@types/json5@0.0.29': {} @@ -4378,6 +4491,10 @@ snapshots: decimal.js-light@2.5.1: {} + decompress-response@7.0.0: + dependencies: + mimic-response: 3.1.0 + deep-is@0.1.4: {} defaults@1.0.4: @@ -4742,8 +4859,12 @@ snapshots: esutils@2.0.3: {} + event-source-polyfill@1.0.31: {} + eventemitter3@4.0.7: {} + eventsource@2.0.2: {} + execa@7.2.0: dependencies: cross-spawn: 7.0.6 @@ -4813,6 +4934,8 @@ snapshots: flatted@3.3.3: {} + follow-redirects@1.15.9: {} + for-each@0.3.5: dependencies: is-callable: 1.2.7 @@ -4870,6 +4993,17 @@ snapshots: hasown: 2.0.2 math-intrinsics: 1.1.0 + get-it@8.6.9: + dependencies: + '@types/follow-redirects': 1.14.4 + decompress-response: 7.0.0 + follow-redirects: 1.15.9 + is-retry-allowed: 2.2.0 + through2: 4.0.2 + tunnel-agent: 0.6.0 + transitivePeerDependencies: + - debug + get-nonce@1.0.1: {} get-proto@1.0.1: @@ -5063,6 +5197,8 @@ snapshots: has-tostringtag: 1.0.2 hasown: 2.0.2 + is-retry-allowed@2.2.0: {} + is-set@2.0.3: {} is-shared-array-buffer@1.0.4: @@ -5216,6 +5352,8 @@ snapshots: mimic-fn@4.0.0: {} + mimic-response@3.1.0: {} + minimatch@3.1.2: dependencies: brace-expansion: 1.1.11 @@ -5653,6 +5791,10 @@ snapshots: dependencies: queue-microtask: 1.2.3 + rxjs@7.8.2: + dependencies: + tslib: 2.8.1 + safe-array-concat@1.1.3: dependencies: call-bind: 1.0.8 @@ -5947,6 +6089,10 @@ snapshots: dependencies: any-promise: 1.3.0 + through2@4.0.2: + dependencies: + readable-stream: 3.6.2 + tiny-invariant@1.3.3: {} tinyglobby@0.2.12: @@ -5973,6 +6119,10 @@ snapshots: tslib@2.8.1: {} + tunnel-agent@0.6.0: + dependencies: + safe-buffer: 5.2.1 + type-check@0.4.0: dependencies: prelude-ls: 1.2.1