From 5c7014ddfa541627bff00d4354e2166cc45094e1 Mon Sep 17 00:00:00 2001 From: Shardendu Mishra Date: Sun, 26 Jan 2025 14:11:20 +0530 Subject: [PATCH 1/9] fix: clean up code style and formatting across multiple files --- .gitignore | 5 +- components.json | 2 +- next.config.ts | 2 +- sanity.cli.ts | 14 +- sanity.config.ts | 26 +-- src/app/actions/github.ts | 109 ++++++------ src/app/studio/[[...tool]]/page.tsx | 10 +- src/sanity/components/facultyIdInput.tsx | 30 ++-- src/sanity/env.ts | 10 +- src/sanity/lib/client.ts | 6 +- src/sanity/lib/image.ts | 12 +- src/sanity/lib/live.ts | 12 +- src/sanity/schemaTypes/About.ts | 159 ------------------ src/sanity/schemaTypes/CSEAcademics.ts | 24 --- src/sanity/schemaTypes/ChairPerson.ts | 76 --------- src/sanity/schemaTypes/DSAIAcademics.ts | 24 --- src/sanity/schemaTypes/ECEAcademics.ts | 24 --- src/sanity/schemaTypes/Former.ts | 86 +++++----- src/sanity/schemaTypes/HomePage.ts | 1 - src/sanity/schemaTypes/Visitor.ts | 76 --------- .../schemaTypes/academics/CSEAcademics.ts | 23 +++ .../schemaTypes/academics/DSAIAcademics.ts | 23 +++ .../schemaTypes/academics/ECEAcademics.ts | 23 +++ src/sanity/schemaTypes/generalInfo/About.ts | 159 ++++++++++++++++++ .../schemaTypes/generalInfo/ChairPerson.ts | 76 +++++++++ .../{ => generalInfo}/ContactInfo.ts | 2 - src/sanity/schemaTypes/generalInfo/Visitor.ts | 76 +++++++++ src/sanity/schemaTypes/index.ts | 34 ++-- .../Annual_reports.ts | 0 .../{ => researchDevelopment}/KrcData.ts | 0 .../{ => researchDevelopment}/KrcDataTel.ts | 0 .../KrcDataTelFull.ts | 0 .../{ => studentLife}/CampusData.ts | 0 .../schemaTypes/{ => studentLife}/Events.ts | 0 .../{ => studentLife}/Facilities.ts | 0 .../schemaTypes/{ => studentLife}/Magazine.ts | 0 src/sanity/structure.ts | 109 ++++++++---- 37 files changed, 635 insertions(+), 598 deletions(-) delete mode 100644 src/sanity/schemaTypes/About.ts delete mode 100644 src/sanity/schemaTypes/CSEAcademics.ts delete mode 100644 src/sanity/schemaTypes/ChairPerson.ts delete mode 100644 src/sanity/schemaTypes/DSAIAcademics.ts delete mode 100644 src/sanity/schemaTypes/ECEAcademics.ts delete mode 100644 src/sanity/schemaTypes/Visitor.ts create mode 100644 src/sanity/schemaTypes/academics/CSEAcademics.ts create mode 100644 src/sanity/schemaTypes/academics/DSAIAcademics.ts create mode 100644 src/sanity/schemaTypes/academics/ECEAcademics.ts create mode 100644 src/sanity/schemaTypes/generalInfo/About.ts create mode 100644 src/sanity/schemaTypes/generalInfo/ChairPerson.ts rename src/sanity/schemaTypes/{ => generalInfo}/ContactInfo.ts (99%) create mode 100644 src/sanity/schemaTypes/generalInfo/Visitor.ts rename src/sanity/schemaTypes/{ => reportsAndRankings}/Annual_reports.ts (100%) rename src/sanity/schemaTypes/{ => researchDevelopment}/KrcData.ts (100%) rename src/sanity/schemaTypes/{ => researchDevelopment}/KrcDataTel.ts (100%) rename src/sanity/schemaTypes/{ => researchDevelopment}/KrcDataTelFull.ts (100%) rename src/sanity/schemaTypes/{ => studentLife}/CampusData.ts (100%) rename src/sanity/schemaTypes/{ => studentLife}/Events.ts (100%) rename src/sanity/schemaTypes/{ => studentLife}/Facilities.ts (100%) rename src/sanity/schemaTypes/{ => studentLife}/Magazine.ts (100%) diff --git a/.gitignore b/.gitignore index 5e38e3f..e48e555 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ !.yarn/plugins !.yarn/releases !.yarn/versions +package-lock.json # testing /coverage @@ -39,5 +40,5 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts - -.vercel + +.vercel diff --git a/components.json b/components.json index a577707..2233015 100644 --- a/components.json +++ b/components.json @@ -18,4 +18,4 @@ "hooks": "@/hooks" }, "iconLibrary": "lucide" -} \ No newline at end of file +} diff --git a/next.config.ts b/next.config.ts index e9ffa30..5e891cf 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,4 +1,4 @@ -import type { NextConfig } from "next"; +import type { NextConfig } from 'next'; const nextConfig: NextConfig = { /* config options here */ diff --git a/sanity.cli.ts b/sanity.cli.ts index e53410c..e758e96 100644 --- a/sanity.cli.ts +++ b/sanity.cli.ts @@ -1,10 +1,10 @@ /** -* This configuration file lets you run `$ sanity [command]` in this folder -* Go to https://www.sanity.io/docs/cli to learn more. -**/ -import { defineCliConfig } from 'sanity/cli' + * This configuration file lets you run `$ sanity [command]` in this folder + * Go to https://www.sanity.io/docs/cli to learn more. + **/ +import { defineCliConfig } from 'sanity/cli'; -const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID -const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET +const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID; +const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET; -export default defineCliConfig({ api: { projectId, dataset } }) +export default defineCliConfig({ api: { projectId, dataset } }); diff --git a/sanity.config.ts b/sanity.config.ts index 4bf4519..c4b1238 100644 --- a/sanity.config.ts +++ b/sanity.config.ts @@ -1,18 +1,18 @@ -'use client' +'use client'; /** * This configuration is used to for the Sanity Studio that’s mounted on the `/app/studio/[[...tool]]/page.tsx` route */ -import {visionTool} from '@sanity/vision' -import {defineConfig} from 'sanity' -import {structureTool} from 'sanity/structure' +import { visionTool } from '@sanity/vision'; +import { defineConfig } from 'sanity'; +import { structureTool } from 'sanity/structure'; // Go to https://www.sanity.io/docs/api-versioning to learn how API versioning works -import {apiVersion, dataset, projectId} from './src/sanity/env' -import {schema} from './src/sanity/schemaTypes' -import {structure} from './src/sanity/structure' -import { CustomNavbar } from '@/sanity/components/CustomNavbar' +import { apiVersion, dataset, projectId } from './src/sanity/env'; +import { schema } from './src/sanity/schemaTypes'; +import { structure } from './src/sanity/structure'; +import { CustomNavbar } from '@/sanity/components/CustomNavbar'; export default defineConfig({ basePath: '/studio', @@ -22,13 +22,13 @@ export default defineConfig({ schema, studio: { components: { - navbar: CustomNavbar - } + navbar: CustomNavbar, + }, }, plugins: [ - structureTool({structure}), + structureTool({ structure }), // Vision is for querying with GROQ from inside the Studio // https://www.sanity.io/docs/the-vision-plugin - visionTool({defaultApiVersion: apiVersion}), + visionTool({ defaultApiVersion: apiVersion }), ], -}) +}); diff --git a/src/app/actions/github.ts b/src/app/actions/github.ts index 29ad333..a94bfe7 100644 --- a/src/app/actions/github.ts +++ b/src/app/actions/github.ts @@ -1,53 +1,56 @@ -"use server"; -import { Octokit } from "@octokit/core"; - -type RunType = { - status: string; - id: string; -}; - -export async function dispatchWorkflow() { - const repoURL = process.env.DEPLOY_REPO_URL; - const workflow = process.env.DEPLOY_WORKFLOW; - const ref = process.env.DEPLOY_REF; - - try { - const octokit = new Octokit({ - auth: process.env.GITHUB_PAT, - }); - - // Get all workflow runs to check the uncompleted ones - const { data: runs } = await octokit.request( - `GET /repos/${repoURL}/actions/workflows/${workflow}/runs`, - { - per_page: 100, - } - ); - - const unCompletedRuns = runs.workflow_runs.filter( - (run: RunType) => run.status !== "completed" - ); - - if (unCompletedRuns.length > 0) { - // Cancel the uncompleted ones - for (const run of unCompletedRuns) { - await octokit.request(`POST /repos/${repoURL}/actions/runs/${run.id}/cancel`, { - headers: { - Accept: "application/vnd.github.v3+json", - }, - }); - console.log(`Cancelled workflow run: ${run.id}`); - } - } - - // Dispatch a new workflow run - await octokit.request( - `POST /repos/${repoURL}/actions/workflows/${workflow}/dispatches`, - { ref } - ); - - console.log("Dispatched new workflow run"); - } catch (error) { - throw error; - } -} +'use server'; +import { Octokit } from '@octokit/core'; + +type RunType = { + status: string; + id: string; +}; + +export async function dispatchWorkflow() { + const repoURL = process.env.DEPLOY_REPO_URL; + const workflow = process.env.DEPLOY_WORKFLOW; + const ref = process.env.DEPLOY_REF; + + try { + const octokit = new Octokit({ + auth: process.env.GITHUB_PAT, + }); + + // Get all workflow runs to check the uncompleted ones + const { data: runs } = await octokit.request( + `GET /repos/${repoURL}/actions/workflows/${workflow}/runs`, + { + per_page: 100, + } + ); + + const unCompletedRuns = runs.workflow_runs.filter( + (run: RunType) => run.status !== 'completed' + ); + + if (unCompletedRuns.length > 0) { + // Cancel the uncompleted ones + for (const run of unCompletedRuns) { + await octokit.request( + `POST /repos/${repoURL}/actions/runs/${run.id}/cancel`, + { + headers: { + Accept: 'application/vnd.github.v3+json', + }, + } + ); + console.log(`Cancelled workflow run: ${run.id}`); + } + } + + // Dispatch a new workflow run + await octokit.request( + `POST /repos/${repoURL}/actions/workflows/${workflow}/dispatches`, + { ref } + ); + + console.log('Dispatched new workflow run'); + } catch (error) { + throw error; + } +} diff --git a/src/app/studio/[[...tool]]/page.tsx b/src/app/studio/[[...tool]]/page.tsx index efc2154..ed45df3 100644 --- a/src/app/studio/[[...tool]]/page.tsx +++ b/src/app/studio/[[...tool]]/page.tsx @@ -7,13 +7,13 @@ * https://github.com/sanity-io/next-sanity */ -import { NextStudio } from 'next-sanity/studio' -import config from '../../../../sanity.config' +import { NextStudio } from 'next-sanity/studio'; +import config from '../../../../sanity.config'; -export const dynamic = 'force-static' +export const dynamic = 'force-static'; -export { metadata, viewport } from 'next-sanity/studio' +export { metadata, viewport } from 'next-sanity/studio'; export default function StudioPage() { - return + return ; } diff --git a/src/sanity/components/facultyIdInput.tsx b/src/sanity/components/facultyIdInput.tsx index 30b4c4f..e106b68 100644 --- a/src/sanity/components/facultyIdInput.tsx +++ b/src/sanity/components/facultyIdInput.tsx @@ -1,20 +1,20 @@ /* eslint-disable react-hooks/exhaustive-deps */ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { forwardRef, useEffect, useMemo } from "react"; -import { PatchEvent, set, StringInputProps, unset, useFormValue } from "sanity"; -import { TextInput } from "@sanity/ui"; +import { forwardRef, useEffect, useMemo } from 'react'; +import { PatchEvent, set, StringInputProps, unset, useFormValue } from 'sanity'; +import { TextInput } from '@sanity/ui'; export function formatName(input: string) { - let cleanedInput = input.replace(/^['"]|['"]$/g, "").trim(); // Remove the leading and trailing quotes (if any) + let cleanedInput = input.replace(/^['"]|['"]$/g, '').trim(); // Remove the leading and trailing quotes (if any) cleanedInput = cleanedInput.replace( /^(Mr|Mrs|Ms|Dr|Prof|Professor|Rev|Sir|Lord|Mx)\.?\s*/i, - "" + '' ); // Remove common prefixes (Mr., Mrs., Ms., Dr., Prof., Professor, Rev., Sir, Lord, Mx., etc.) - cleanedInput = cleanedInput.replace(/\./g, ""); // Remove all periods (.) + cleanedInput = cleanedInput.replace(/\./g, ''); // Remove all periods (.) - const formattedName = cleanedInput.replace(/\s+/g, ""); // Remove any spaces between the first and last names + const formattedName = cleanedInput.replace(/\s+/g, ''); // Remove any spaces between the first and last names return formattedName; } @@ -22,8 +22,8 @@ export function formatName(input: string) { const FacultyIdInput = forwardRef( (props, ref) => { const facultyName = - (useFormValue(["content", "head", "name"]) as string) ?? ""; - + (useFormValue(['content', 'head', 'name']) as string) ?? ''; + const idValue = useMemo(() => formatName(facultyName), [facultyName]); const { schemaType, @@ -40,16 +40,10 @@ const FacultyIdInput = forwardRef( onChange(PatchEvent.from(idValue ? set(idValue) : unset())); }, [idValue]); - return ( - - ); + return ; } ); -FacultyIdInput.displayName = "FacultyIdInput"; +FacultyIdInput.displayName = 'FacultyIdInput'; -export default FacultyIdInput; \ No newline at end of file +export default FacultyIdInput; diff --git a/src/sanity/env.ts b/src/sanity/env.ts index 8872daa..bdc22c2 100644 --- a/src/sanity/env.ts +++ b/src/sanity/env.ts @@ -1,19 +1,19 @@ -export const apiVersion = '2024-11-28' +export const apiVersion = '2024-11-28'; export const dataset = assertValue( process.env.NEXT_PUBLIC_SANITY_DATASET, 'Missing environment variable: NEXT_PUBLIC_SANITY_DATASET' -) +); export const projectId = assertValue( process.env.NEXT_PUBLIC_SANITY_PROJECT_ID, 'Missing environment variable: NEXT_PUBLIC_SANITY_PROJECT_ID' -) +); function assertValue(v: T | undefined, errorMessage: string): T { if (v === undefined) { - throw new Error(errorMessage) + throw new Error(errorMessage); } - return v + return v; } diff --git a/src/sanity/lib/client.ts b/src/sanity/lib/client.ts index c254375..5aa1680 100644 --- a/src/sanity/lib/client.ts +++ b/src/sanity/lib/client.ts @@ -1,10 +1,10 @@ -import { createClient } from 'next-sanity' +import { createClient } from 'next-sanity'; -import { apiVersion, dataset, projectId } from '../env' +import { apiVersion, dataset, projectId } from '../env'; export const client = createClient({ projectId, dataset, apiVersion, useCdn: false, // Set to false if statically generating pages, using ISR or tag-based revalidation -}) +}); diff --git a/src/sanity/lib/image.ts b/src/sanity/lib/image.ts index 3ed0a5e..94a8080 100644 --- a/src/sanity/lib/image.ts +++ b/src/sanity/lib/image.ts @@ -1,11 +1,11 @@ -import createImageUrlBuilder from '@sanity/image-url' -import { SanityImageSource } from "@sanity/image-url/lib/types/types"; +import createImageUrlBuilder from '@sanity/image-url'; +import { SanityImageSource } from '@sanity/image-url/lib/types/types'; -import { dataset, projectId } from '../env' +import { dataset, projectId } from '../env'; // https://www.sanity.io/docs/image-url -const builder = createImageUrlBuilder({ projectId, dataset }) +const builder = createImageUrlBuilder({ projectId, dataset }); export const urlFor = (source: SanityImageSource) => { - return builder.image(source) -} + return builder.image(source); +}; diff --git a/src/sanity/lib/live.ts b/src/sanity/lib/live.ts index 8299535..ac679f3 100644 --- a/src/sanity/lib/live.ts +++ b/src/sanity/lib/live.ts @@ -1,13 +1,13 @@ // Querying with "sanityFetch" will keep content automatically updated // Before using it, import and render "" in your layout, see // https://github.com/sanity-io/next-sanity#live-content-api for more information. -import { defineLive } from "next-sanity"; -import { client } from './client' +import { defineLive } from 'next-sanity'; +import { client } from './client'; -export const { sanityFetch, SanityLive } = defineLive({ - client: client.withConfig({ +export const { sanityFetch, SanityLive } = defineLive({ + client: client.withConfig({ // Live content is currently only available on the experimental API // https://www.sanity.io/docs/api-versioning - apiVersion: 'vX' - }) + apiVersion: 'vX', + }), }); diff --git a/src/sanity/schemaTypes/About.ts b/src/sanity/schemaTypes/About.ts deleted file mode 100644 index 7b62a1c..0000000 --- a/src/sanity/schemaTypes/About.ts +++ /dev/null @@ -1,159 +0,0 @@ -import { SearchSlashIcon } from "lucide-react"; -import { defineField, defineType } from "sanity"; - -export const About = defineType({ - name: "about", - title: "About", - type: "document", - icon: SearchSlashIcon, - fields: [ - defineField({ - name: "aboutText", - title: "About Text", - type: "string", - description: "About Text", - }), - defineField({ - name: "profiles", - title: "Profiles", - type: "array", - of: [ - { - type: "object", - fields: [ - defineField({ - name: "title", - title: "Profile Title", - type: "string", - description: "Title of the profile", - }), - defineField({ - name: "content", - title: "Content", - type: "array", - of: [{ type: "string" }], - description: "Content of the profile", - }), - defineField({ - name: "imageURL", - title: "Image URL", - type: "string", - description: "URL of the profile image", - }), - ], - }, - ], - description: "Profiles associated with the visitor", - }), - defineField({ - name: "briefProfile", - title: "Brief Profile", - description: "Brief of The Profile", - type: "string", - }), - defineField({ - name: "vision", - title: "Vision", - description: "Vision Regarding The Topic", - type: "string", - }), - defineField({ - name: "image_prof", - title: "Image Prof", - description: "Image related to the topic", - type: "object", // Explicitly defining it as an object - fields: [ - defineField({ - name: "name", - type: "string", - title: "Name", - description: "Name of the image", - }), - defineField({ - name: "imageURL", - title: "Image URL", - type: "string", - description: "URL of the image", - }), - ], - }), - defineField({ - name: "mission", - title: "Mission", - description: "Mission Regarding The Topic", - type: "array", - of: [ - { - type: "object", - fields: [ - defineField({ - name: "missionText", - title: "Mission Text", - type: "string", - }), - ], - }, - ], - }), - defineField({ - name: "coreValues", - title: "Core Values", - description: "Core Values Regarding The Topic", - type: "array", - of: [ - { - type: "object", - fields: [ - defineField({ - name: "id", - title: "ID", - type: "string", - }), - defineField({ - name: "text", - title: "Text", - type: "string", - }), - ], - }, - ], - }), - defineField({ - name: "href", - title: "Href", - type: "string", - }), - defineField({ - name: "directorMessage", - title: "Director Message", - type: "array", // Explicitly defining it as an array of objects - of: [ - { - type: "object", - fields: [ - defineField({ - name: "heading", - title: "Heading", - type: "string", - }), - defineField({ - name: "text1", - title: "Text 1", - type: "string", - }), - defineField({ - name: "text2", - title: "Text 2", - type: "string", - }), - defineField({ - name: "text3", - title: "Text 3", - type: "string", - }), - ], - }, - ], - }), - ], -}); diff --git a/src/sanity/schemaTypes/CSEAcademics.ts b/src/sanity/schemaTypes/CSEAcademics.ts deleted file mode 100644 index 6a6b83b..0000000 --- a/src/sanity/schemaTypes/CSEAcademics.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ComputerIcon } from "lucide-react"; -import { defineField, defineType } from "sanity"; - - -export const cseDetail = defineType({ - name : 'cseDetail', - title : 'CSE Course Details', - type : 'document', - icon : ComputerIcon, - fields : [ - defineField({ - name : "course", - title : "Course", - type : "string", - description : "Course Name" - }), - defineField({ - name : "credits", - title : "Credits", - type : "string", - description : "Credit Percentage of the Course" - }), - ] -}) \ No newline at end of file diff --git a/src/sanity/schemaTypes/ChairPerson.ts b/src/sanity/schemaTypes/ChairPerson.ts deleted file mode 100644 index 013557b..0000000 --- a/src/sanity/schemaTypes/ChairPerson.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { defineField, defineType } from "sanity"; -import { Users2Icon } from "lucide-react"; - -export const chairPerson = defineType({ - name: "chairPerson", - title: "Chair Person", - type: "document", - icon: Users2Icon, - fields: [ - defineField({ - name: "title", - title: "Title", - type: "string", - description: "Title of the profile group", - }), - defineField({ - name: "profiles", - title: "Profiles", - type: "array", - of: [ - { - type: "object", - fields: [ - defineField({ - name: "title", - title: "Profile Title", - type: "string", - description: "Title of the profile", - }), - defineField({ - name: "content", - title: "Content", - type: "array", - of: [{ type: "string" }], - description: "Content of the profile", - }), - defineField({ - name: "imageURL", - title: "Image URL", - type: "string", - description: "URL of the profile image", - }), - ], - }, - ], - description: "Profiles associated with the visitor", - }), - ], -}); - -export const profile = defineType({ - name: "profile", - title: "Profile", - type: "document", - fields: [ - defineField({ - name: "title", - title: "Title", - type: "string", - description: "Profile title", - }), - defineField({ - name: "content", - title: "Content", - type: "array", - of: [{ type: "string" }], - description: "Content of the profile", - }), - defineField({ - name: "imageURL", - title: "Image URL", - type: "string", - description: "URL of the profile image", - }), - ], -}); diff --git a/src/sanity/schemaTypes/DSAIAcademics.ts b/src/sanity/schemaTypes/DSAIAcademics.ts deleted file mode 100644 index a41b51b..0000000 --- a/src/sanity/schemaTypes/DSAIAcademics.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ComputerIcon } from "lucide-react"; -import { defineField, defineType } from "sanity"; - - -export const dsaiDetail = defineType({ - name : 'dsaiDetail', - title : 'DSAI Course Details', - type : 'document', - icon : ComputerIcon, - fields : [ - defineField({ - name : "course", - title : "Course", - type : "string", - description : "Course Name" - }), - defineField({ - name : "credits", - title : "Credits", - type : "string", - description : "Credit Percentage of the Course" - }), - ] -}) \ No newline at end of file diff --git a/src/sanity/schemaTypes/ECEAcademics.ts b/src/sanity/schemaTypes/ECEAcademics.ts deleted file mode 100644 index 06c04df..0000000 --- a/src/sanity/schemaTypes/ECEAcademics.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { BluetoothIcon } from "lucide-react"; -import { defineField, defineType } from "sanity"; - - -export const eceDetail = defineType({ - name : 'eceDetail', - title : 'ECE Course Details', - type : 'document', - icon : BluetoothIcon, - fields : [ - defineField({ - name : "course", - title : "Course", - type : "string", - description : "Course Name" - }), - defineField({ - name : "credits", - title : "Credits", - type : "string", - description : "Credit Percentage of the Course" - }), - ] -}) \ No newline at end of file diff --git a/src/sanity/schemaTypes/Former.ts b/src/sanity/schemaTypes/Former.ts index eaae678..c94317b 100644 --- a/src/sanity/schemaTypes/Former.ts +++ b/src/sanity/schemaTypes/Former.ts @@ -1,76 +1,76 @@ -import { defineField, defineType } from "sanity"; -import { UsersIcon } from "lucide-react"; +import { defineField, defineType } from 'sanity'; +import { UsersIcon } from 'lucide-react'; export const former = defineType({ - name: "former", - title: "Former", - type: "document", + name: 'former', + title: 'Former', + type: 'document', icon: UsersIcon, fields: [ defineField({ - name: "title", - title: "Title", - type: "string", - description: "Title of the profile group", + name: 'title', + title: 'Title', + type: 'string', + description: 'Title of the profile group', }), defineField({ - name: "profiles", - title: "Profiles", - type: "array", + name: 'profiles', + title: 'Profiles', + type: 'array', of: [ { - type: "object", + type: 'object', fields: [ defineField({ - name: "title", - title: "Profile Title", - type: "string", - description: "Title of the profile", + name: 'title', + title: 'Profile Title', + type: 'string', + description: 'Title of the profile', }), defineField({ - name: "content", - title: "Content", - type: "array", - of: [{ type: "string" }], - description: "Content of the profile", + name: 'content', + title: 'Content', + type: 'array', + of: [{ type: 'string' }], + description: 'Content of the profile', }), defineField({ - name: "imageURL", - title: "Image URL", - type: "string", - description: "URL of the profile image", + name: 'imageURL', + title: 'Image URL', + type: 'string', + description: 'URL of the profile image', }), ], }, ], - description: "Profiles associated with the visitor", + description: 'Profiles associated with the visitor', }), ], }); export const profile = defineType({ - name: "profile", - title: "Profile", - type: "document", + name: 'profile', + title: 'Profile', + type: 'document', fields: [ defineField({ - name: "title", - title: "Title", - type: "string", - description: "Profile title", + name: 'title', + title: 'Title', + type: 'string', + description: 'Profile title', }), defineField({ - name: "content", - title: "Content", - type: "array", - of: [{ type: "string" }], - description: "Content of the profile", + name: 'content', + title: 'Content', + type: 'array', + of: [{ type: 'string' }], + description: 'Content of the profile', }), defineField({ - name: "imageURL", - title: "Image URL", - type: "string", - description: "URL of the profile image", + name: 'imageURL', + title: 'Image URL', + type: 'string', + description: 'URL of the profile image', }), ], }); diff --git a/src/sanity/schemaTypes/HomePage.ts b/src/sanity/schemaTypes/HomePage.ts index d73e16e..306c6bc 100644 --- a/src/sanity/schemaTypes/HomePage.ts +++ b/src/sanity/schemaTypes/HomePage.ts @@ -30,7 +30,6 @@ export const MainCarouselImage = defineType({ ], }); - export const ProgramCards = defineType({ name: 'programCards', title: 'Program Cards', diff --git a/src/sanity/schemaTypes/Visitor.ts b/src/sanity/schemaTypes/Visitor.ts deleted file mode 100644 index 1e233b6..0000000 --- a/src/sanity/schemaTypes/Visitor.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { defineField, defineType } from "sanity"; -import { Users2Icon } from "lucide-react"; - -export const visitor = defineType({ - name: "visitor", - title: "Visitor", - type: "document", - icon: Users2Icon, - fields: [ - defineField({ - name: "title", - title: "Title", - type: "string", - description: "Title of the profile group", - }), - defineField({ - name: "profiles", - title: "Profiles", - type: "array", - of: [ - { - type: "object", - fields: [ - defineField({ - name: "title", - title: "Profile Title", - type: "string", - description: "Title of the profile", - }), - defineField({ - name: "content", - title: "Content", - type: "array", - of: [{ type: "string" }], - description: "Content of the profile", - }), - defineField({ - name: "imageURL", - title: "Image URL", - type: "string", - description: "URL of the profile image", - }), - ], - }, - ], - description: "Profiles associated with the visitor", - }), - ], -}); - -export const profile = defineType({ - name: "profile", - title: "Profile", - type: "document", - fields: [ - defineField({ - name: "title", - title: "Title", - type: "string", - description: "Profile title", - }), - defineField({ - name: "content", - title: "Content", - type: "array", - of: [{ type: "string" }], - description: "Content of the profile", - }), - defineField({ - name: "imageURL", - title: "Image URL", - type: "string", - description: "URL of the profile image", - }), - ], -}); diff --git a/src/sanity/schemaTypes/academics/CSEAcademics.ts b/src/sanity/schemaTypes/academics/CSEAcademics.ts new file mode 100644 index 0000000..cf2452d --- /dev/null +++ b/src/sanity/schemaTypes/academics/CSEAcademics.ts @@ -0,0 +1,23 @@ +import { ComputerIcon } from 'lucide-react'; +import { defineField, defineType } from 'sanity'; + +export const cseDetail = defineType({ + name: 'cseDetail', + title: 'CSE Course Details', + type: 'document', + icon: ComputerIcon, + fields: [ + defineField({ + name: 'course', + title: 'Course', + type: 'string', + description: 'Course Name', + }), + defineField({ + name: 'credits', + title: 'Credits', + type: 'string', + description: 'Credit Percentage of the Course', + }), + ], +}); diff --git a/src/sanity/schemaTypes/academics/DSAIAcademics.ts b/src/sanity/schemaTypes/academics/DSAIAcademics.ts new file mode 100644 index 0000000..0e3b04a --- /dev/null +++ b/src/sanity/schemaTypes/academics/DSAIAcademics.ts @@ -0,0 +1,23 @@ +import { ComputerIcon } from 'lucide-react'; +import { defineField, defineType } from 'sanity'; + +export const dsaiDetail = defineType({ + name: 'dsaiDetail', + title: 'DSAI Course Details', + type: 'document', + icon: ComputerIcon, + fields: [ + defineField({ + name: 'course', + title: 'Course', + type: 'string', + description: 'Course Name', + }), + defineField({ + name: 'credits', + title: 'Credits', + type: 'string', + description: 'Credit Percentage of the Course', + }), + ], +}); diff --git a/src/sanity/schemaTypes/academics/ECEAcademics.ts b/src/sanity/schemaTypes/academics/ECEAcademics.ts new file mode 100644 index 0000000..3d1dec9 --- /dev/null +++ b/src/sanity/schemaTypes/academics/ECEAcademics.ts @@ -0,0 +1,23 @@ +import { BluetoothIcon } from 'lucide-react'; +import { defineField, defineType } from 'sanity'; + +export const eceDetail = defineType({ + name: 'eceDetail', + title: 'ECE Course Details', + type: 'document', + icon: BluetoothIcon, + fields: [ + defineField({ + name: 'course', + title: 'Course', + type: 'string', + description: 'Course Name', + }), + defineField({ + name: 'credits', + title: 'Credits', + type: 'string', + description: 'Credit Percentage of the Course', + }), + ], +}); diff --git a/src/sanity/schemaTypes/generalInfo/About.ts b/src/sanity/schemaTypes/generalInfo/About.ts new file mode 100644 index 0000000..46cad94 --- /dev/null +++ b/src/sanity/schemaTypes/generalInfo/About.ts @@ -0,0 +1,159 @@ +import { SearchSlashIcon } from 'lucide-react'; +import { defineField, defineType } from 'sanity'; + +export const About = defineType({ + name: 'about', + title: 'About', + type: 'document', + icon: SearchSlashIcon, + fields: [ + defineField({ + name: 'aboutText', + title: 'About Text', + type: 'string', + description: 'About Text', + }), + defineField({ + name: 'profiles', + title: 'Profiles', + type: 'array', + of: [ + { + type: 'object', + fields: [ + defineField({ + name: 'title', + title: 'Profile Title', + type: 'string', + description: 'Title of the profile', + }), + defineField({ + name: 'content', + title: 'Content', + type: 'array', + of: [{ type: 'string' }], + description: 'Content of the profile', + }), + defineField({ + name: 'imageURL', + title: 'Image URL', + type: 'string', + description: 'URL of the profile image', + }), + ], + }, + ], + description: 'Profiles associated with the visitor', + }), + defineField({ + name: 'briefProfile', + title: 'Brief Profile', + description: 'Brief of The Profile', + type: 'string', + }), + defineField({ + name: 'vision', + title: 'Vision', + description: 'Vision Regarding The Topic', + type: 'string', + }), + defineField({ + name: 'image_prof', + title: 'Image Prof', + description: 'Image related to the topic', + type: 'object', // Explicitly defining it as an object + fields: [ + defineField({ + name: 'name', + type: 'string', + title: 'Name', + description: 'Name of the image', + }), + defineField({ + name: 'imageURL', + title: 'Image URL', + type: 'string', + description: 'URL of the image', + }), + ], + }), + defineField({ + name: 'mission', + title: 'Mission', + description: 'Mission Regarding The Topic', + type: 'array', + of: [ + { + type: 'object', + fields: [ + defineField({ + name: 'missionText', + title: 'Mission Text', + type: 'string', + }), + ], + }, + ], + }), + defineField({ + name: 'coreValues', + title: 'Core Values', + description: 'Core Values Regarding The Topic', + type: 'array', + of: [ + { + type: 'object', + fields: [ + defineField({ + name: 'id', + title: 'ID', + type: 'string', + }), + defineField({ + name: 'text', + title: 'Text', + type: 'string', + }), + ], + }, + ], + }), + defineField({ + name: 'href', + title: 'Href', + type: 'string', + }), + defineField({ + name: 'directorMessage', + title: 'Director Message', + type: 'array', // Explicitly defining it as an array of objects + of: [ + { + type: 'object', + fields: [ + defineField({ + name: 'heading', + title: 'Heading', + type: 'string', + }), + defineField({ + name: 'text1', + title: 'Text 1', + type: 'string', + }), + defineField({ + name: 'text2', + title: 'Text 2', + type: 'string', + }), + defineField({ + name: 'text3', + title: 'Text 3', + type: 'string', + }), + ], + }, + ], + }), + ], +}); diff --git a/src/sanity/schemaTypes/generalInfo/ChairPerson.ts b/src/sanity/schemaTypes/generalInfo/ChairPerson.ts new file mode 100644 index 0000000..1cad7b7 --- /dev/null +++ b/src/sanity/schemaTypes/generalInfo/ChairPerson.ts @@ -0,0 +1,76 @@ +import { defineField, defineType } from 'sanity'; +import { Users2Icon } from 'lucide-react'; + +export const chairPerson = defineType({ + name: 'chairPerson', + title: 'Chair Person', + type: 'document', + icon: Users2Icon, + fields: [ + defineField({ + name: 'title', + title: 'Title', + type: 'string', + description: 'Title of the profile group', + }), + defineField({ + name: 'profiles', + title: 'Profiles', + type: 'array', + of: [ + { + type: 'object', + fields: [ + defineField({ + name: 'title', + title: 'Profile Title', + type: 'string', + description: 'Title of the profile', + }), + defineField({ + name: 'content', + title: 'Content', + type: 'array', + of: [{ type: 'string' }], + description: 'Content of the profile', + }), + defineField({ + name: 'imageURL', + title: 'Image URL', + type: 'string', + description: 'URL of the profile image', + }), + ], + }, + ], + description: 'Profiles associated with the visitor', + }), + ], +}); + +export const profile = defineType({ + name: 'profile', + title: 'Profile', + type: 'document', + fields: [ + defineField({ + name: 'title', + title: 'Title', + type: 'string', + description: 'Profile title', + }), + defineField({ + name: 'content', + title: 'Content', + type: 'array', + of: [{ type: 'string' }], + description: 'Content of the profile', + }), + defineField({ + name: 'imageURL', + title: 'Image URL', + type: 'string', + description: 'URL of the profile image', + }), + ], +}); diff --git a/src/sanity/schemaTypes/ContactInfo.ts b/src/sanity/schemaTypes/generalInfo/ContactInfo.ts similarity index 99% rename from src/sanity/schemaTypes/ContactInfo.ts rename to src/sanity/schemaTypes/generalInfo/ContactInfo.ts index a546628..2c22c6b 100644 --- a/src/sanity/schemaTypes/ContactInfo.ts +++ b/src/sanity/schemaTypes/generalInfo/ContactInfo.ts @@ -37,7 +37,6 @@ export const ContactInf = defineType({ ], }); - export const ContactCategory = defineType({ name: 'contactCategory', title: 'Contact Category', @@ -59,7 +58,6 @@ export const ContactCategory = defineType({ ], }); - export const ContactData = defineType({ name: 'contactData', title: 'Contact Data', diff --git a/src/sanity/schemaTypes/generalInfo/Visitor.ts b/src/sanity/schemaTypes/generalInfo/Visitor.ts new file mode 100644 index 0000000..baaa010 --- /dev/null +++ b/src/sanity/schemaTypes/generalInfo/Visitor.ts @@ -0,0 +1,76 @@ +import { defineField, defineType } from 'sanity'; +import { Users2Icon } from 'lucide-react'; + +export const visitor = defineType({ + name: 'visitor', + title: 'Visitor', + type: 'document', + icon: Users2Icon, + fields: [ + defineField({ + name: 'title', + title: 'Title', + type: 'string', + description: 'Title of the profile group', + }), + defineField({ + name: 'profiles', + title: 'Profiles', + type: 'array', + of: [ + { + type: 'object', + fields: [ + defineField({ + name: 'title', + title: 'Profile Title', + type: 'string', + description: 'Title of the profile', + }), + defineField({ + name: 'content', + title: 'Content', + type: 'array', + of: [{ type: 'string' }], + description: 'Content of the profile', + }), + defineField({ + name: 'imageURL', + title: 'Image URL', + type: 'string', + description: 'URL of the profile image', + }), + ], + }, + ], + description: 'Profiles associated with the visitor', + }), + ], +}); + +export const profile = defineType({ + name: 'profile', + title: 'Profile', + type: 'document', + fields: [ + defineField({ + name: 'title', + title: 'Title', + type: 'string', + description: 'Profile title', + }), + defineField({ + name: 'content', + title: 'Content', + type: 'array', + of: [{ type: 'string' }], + description: 'Content of the profile', + }), + defineField({ + name: 'imageURL', + title: 'Image URL', + type: 'string', + description: 'URL of the profile image', + }), + ], +}); diff --git a/src/sanity/schemaTypes/index.ts b/src/sanity/schemaTypes/index.ts index 77386b2..cb048fe 100644 --- a/src/sanity/schemaTypes/index.ts +++ b/src/sanity/schemaTypes/index.ts @@ -1,39 +1,43 @@ import { type SchemaTypeDefinition } from 'sanity'; -import { About } from './About'; +import { About } from './generalInfo/About'; import { descriptionStructure, linksStructure, seatStructure, } from './academics/Admission'; import { boardOfGovernor } from './governanceAndAdministration/BoardOfGovernor'; -import { cseDetail } from './CSEAcademics'; -import { campusData } from './CampusData'; -import { chairPerson } from './ChairPerson'; +import { cseDetail } from './academics/CSEAcademics'; +import { campusData } from './studentLife/CampusData'; +import { chairPerson } from './generalInfo/ChairPerson'; import { Credit } from './Credits'; -import { dsaiDetail } from './DSAIAcademics'; -import { eceDetail } from './ECEAcademics'; -import { facilities } from './Facilities'; +import { dsaiDetail } from './academics/DSAIAcademics'; +import { eceDetail } from './academics/ECEAcademics'; +import { facilities } from './studentLife/Facilities'; import { former } from './Former'; import { formerBoardOfGovernor } from './FormerBoardOfGovernor'; import { Jobs } from './Jobs'; -import { krcData } from './KrcData'; -import { krcDataTel } from './KrcDataTel'; -import { krcDataTelFull } from './KrcDataTelFull'; -import { FacultyAdvisor, Issues, Member, Team } from './Magazine'; +import { krcData } from './researchDevelopment/KrcData'; +import { krcDataTel } from './researchDevelopment/KrcDataTel'; +import { krcDataTelFull } from './researchDevelopment/KrcDataTelFull'; +import { FacultyAdvisor, Issues, Member, Team } from './studentLife/Magazine'; import { Club } from './Members'; import { NIRF } from './reportsAndRankings/Nirf'; import { research, advertisement } from './Research'; import { senate } from './governanceAndAdministration/Senate'; import { staff } from './academics/Staff'; -import { visitor } from './Visitor'; +import { visitor } from './generalInfo/Visitor'; import { Faculty } from './academics/Faculty'; import { announcementType } from './newsAndUpdates/Announcement'; import { Tender } from './newsAndUpdates/Tenders'; -import { AnnualReport } from './Annual_reports'; +import { AnnualReport } from './reportsAndRankings/Annual_reports'; import { Gallery } from './Gallery'; -import { EventInfo } from './Events'; +import { EventInfo } from './studentLife/Events'; import { MainCarouselImage, ProgramCards, ProgramsType } from './HomePage'; -import { ContactCategory, ContactData, ContactInf } from './ContactInfo'; +import { + ContactCategory, + ContactData, + ContactInf, +} from './generalInfo/ContactInfo'; export const schema: { types: SchemaTypeDefinition[] } = { types: [ diff --git a/src/sanity/schemaTypes/Annual_reports.ts b/src/sanity/schemaTypes/reportsAndRankings/Annual_reports.ts similarity index 100% rename from src/sanity/schemaTypes/Annual_reports.ts rename to src/sanity/schemaTypes/reportsAndRankings/Annual_reports.ts diff --git a/src/sanity/schemaTypes/KrcData.ts b/src/sanity/schemaTypes/researchDevelopment/KrcData.ts similarity index 100% rename from src/sanity/schemaTypes/KrcData.ts rename to src/sanity/schemaTypes/researchDevelopment/KrcData.ts diff --git a/src/sanity/schemaTypes/KrcDataTel.ts b/src/sanity/schemaTypes/researchDevelopment/KrcDataTel.ts similarity index 100% rename from src/sanity/schemaTypes/KrcDataTel.ts rename to src/sanity/schemaTypes/researchDevelopment/KrcDataTel.ts diff --git a/src/sanity/schemaTypes/KrcDataTelFull.ts b/src/sanity/schemaTypes/researchDevelopment/KrcDataTelFull.ts similarity index 100% rename from src/sanity/schemaTypes/KrcDataTelFull.ts rename to src/sanity/schemaTypes/researchDevelopment/KrcDataTelFull.ts diff --git a/src/sanity/schemaTypes/CampusData.ts b/src/sanity/schemaTypes/studentLife/CampusData.ts similarity index 100% rename from src/sanity/schemaTypes/CampusData.ts rename to src/sanity/schemaTypes/studentLife/CampusData.ts diff --git a/src/sanity/schemaTypes/Events.ts b/src/sanity/schemaTypes/studentLife/Events.ts similarity index 100% rename from src/sanity/schemaTypes/Events.ts rename to src/sanity/schemaTypes/studentLife/Events.ts diff --git a/src/sanity/schemaTypes/Facilities.ts b/src/sanity/schemaTypes/studentLife/Facilities.ts similarity index 100% rename from src/sanity/schemaTypes/Facilities.ts rename to src/sanity/schemaTypes/studentLife/Facilities.ts diff --git a/src/sanity/schemaTypes/Magazine.ts b/src/sanity/schemaTypes/studentLife/Magazine.ts similarity index 100% rename from src/sanity/schemaTypes/Magazine.ts rename to src/sanity/schemaTypes/studentLife/Magazine.ts diff --git a/src/sanity/structure.ts b/src/sanity/structure.ts index ce43916..6659770 100644 --- a/src/sanity/structure.ts +++ b/src/sanity/structure.ts @@ -10,65 +10,106 @@ export const structure: StructureResolver = (S) => .title('Content') .items([ S.listItem() - .title('News & Updates') + .title('General Information') .child( S.list() - .title('News & Updates Documents') + .title('General Information') .items([ S.listItem() - .title('Announcements') - .child( - S.documentTypeList('announcement').title('Announcements') - ), + .title('About') + .child(S.documentTypeList('about').title('About')), S.listItem() - .title('Tenders') - .child(S.documentTypeList('tender').title('Tenders')), + .title('Chair Person') + .child(S.documentTypeList('chairPerson').title('chairPerson')), + S.listItem() + .title('Contact') + .child(S.documentTypeList('Contact').title('Contact')), + S.listItem() + .title('Visitor') + .child(S.documentTypeList('visitor').title('Visitor')), ]) ), S.listItem() - .title('Governance & Administration') + .title('Academics') .child( S.list() - .title('Governance & Administration Documents') + .title('Academics') .items([ S.listItem() - .title('Board Of Governors') + .title('Admission') + .child(S.documentTypeList('Admission').title('Admission')), + S.listItem() + .title('CSE Academic') + .child(S.documentTypeList('cseDetail').title('CSE')), + S.listItem() + .title('ECE Academic') + .child(S.documentTypeList('eceDetail').title('ECE')), + S.listItem() + .title('DSAI Academic') + .child(S.documentTypeList('dsaiDetail').title('DSAI')), + S.listItem() + .title('Faculty') + .child(S.documentTypeList('faculty').title('Faculty')), + S.listItem() + .title('Staff') + .child(S.documentTypeList('staff').title('Staff')), + ]) + ), + S.listItem() + .title('Student Life') + .child( + S.list() + .title('Student Life') + .items([ + S.listItem() + .title('Campus') + .child(S.documentTypeList('campusData').title('Campus Data')), + S.listItem() + .title('Events') + .child(S.documentTypeList('eventInf').title('Events')), + S.listItem() + .title('Faciliy') + .child(S.documentTypeList('facility').title('Facility')), + S.listItem() + .title('Magazine') + .child(S.documentTypeList('issues').title('Magazines')), + ]) + ), + S.listItem() + .title('') + .child( + S.list() + .title('Research and Development') + .items([ + S.listItem() + .title('KRC Data') + .child(S.documentTypeList('krcData').title('KRC Data')), + S.listItem() + .title('KRC Data Tel') + .child(S.documentTypeList('krcDataTEL').title('KRC Data Tel')), + S.listItem() + .title('KRC Data Tel Full') .child( - S.documentTypeList('boardOfGovernor').title( - 'Board Of Governors' + S.documentTypeList('krcDataTelFull').title( + 'KRC Data Tel Full' ) ), - S.listItem() - .title('Senate') - .child(S.documentTypeList('senate').title('Senate')), ]) ), S.listItem() - .title('Academics') + .title('News & Updates') .child( S.list() - .title('Academics Documents') + .title('News & Updates Documents') .items([ S.listItem() - .title('Admission') + .title('Announcements') .child( - S.list() - .title('Admission') - .items([ - S.listItem() - .title('Description') - .child(S.documentTypeList('descriptionStructure')), - S.listItem() - .title('Links') - .child(S.documentTypeList('linksStructure')), - S.listItem() - .title('Seats') - .child(S.documentTypeList('seatStructure')), - ]) + S.documentTypeList('announcement').title('Announcements') ), S.listItem() - .title('Faculty') - .child(S.documentTypeList('faculty').title('Faculty')), + .title('Tenders') + .child(S.documentTypeList('tender').title('Tenders')), ]) ), ...S.documentTypeListItems().filter(schemaFilter), From 54a5e40ac590f76b75de6f6cf7aff9cd8ac10526 Mon Sep 17 00:00:00 2001 From: Shardendu Mishra Date: Sun, 26 Jan 2025 14:44:48 +0530 Subject: [PATCH 2/9] fix: add missing newline at end of package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ebafdb7..05c1212 100644 --- a/package.json +++ b/package.json @@ -70,4 +70,4 @@ "typescript": "^5" }, "packageManager": "pnpm@9.15.3+sha512.1f79bc245a66eb0b07c5d4d83131240774642caaa86ef7d0434ab47c0d16f66b04e21e0c086eb61e62c77efc4d7f7ec071afad3796af64892fae66509173893a" -} +} \ No newline at end of file From 243bf5cfa4c8d7f0eadc1902d23daa0e1bef2447 Mon Sep 17 00:00:00 2001 From: Shardendu Mishra Date: Sun, 26 Jan 2025 18:57:51 +0530 Subject: [PATCH 3/9] fix: standardize casing in schema types and structure definitions --- src/sanity/schemaTypes/index.ts | 4 ++- .../researchDevelopment/KrcDataTel.ts | 2 +- src/sanity/structure.ts | 30 +++++++++++++------ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/sanity/schemaTypes/index.ts b/src/sanity/schemaTypes/index.ts index cb048fe..658ef25 100644 --- a/src/sanity/schemaTypes/index.ts +++ b/src/sanity/schemaTypes/index.ts @@ -41,6 +41,7 @@ import { export const schema: { types: SchemaTypeDefinition[] } = { types: [ + // advice: please Maintain Consistence in Code In-appropriate Casing will cause app to break when data is used else where research, advertisement, campusData, @@ -49,6 +50,7 @@ export const schema: { types: SchemaTypeDefinition[] } = { krcDataTel, krcDataTelFull, Faculty, + senate, staff, chairPerson, @@ -65,6 +67,7 @@ export const schema: { types: SchemaTypeDefinition[] } = { eceDetail, dsaiDetail, Credit, + Jobs, Member, FacultyAdvisor, @@ -75,7 +78,6 @@ export const schema: { types: SchemaTypeDefinition[] } = { Tender, AnnualReport, - ContactInf, ContactCategory, ContactData, diff --git a/src/sanity/schemaTypes/researchDevelopment/KrcDataTel.ts b/src/sanity/schemaTypes/researchDevelopment/KrcDataTel.ts index f2316cf..24fb87d 100644 --- a/src/sanity/schemaTypes/researchDevelopment/KrcDataTel.ts +++ b/src/sanity/schemaTypes/researchDevelopment/KrcDataTel.ts @@ -1,7 +1,7 @@ import { defineType, defineField } from 'sanity'; export const krcDataTel = defineType({ - name: 'krcDataTEL', + name: 'krcDataTel', title: 'Krc Data TEL(First three)', type: 'document', fields: [ diff --git a/src/sanity/structure.ts b/src/sanity/structure.ts index 6659770..4551e9b 100644 --- a/src/sanity/structure.ts +++ b/src/sanity/structure.ts @@ -23,7 +23,7 @@ export const structure: StructureResolver = (S) => .child(S.documentTypeList('chairPerson').title('chairPerson')), S.listItem() .title('Contact') - .child(S.documentTypeList('Contact').title('Contact')), + .child(S.documentTypeList('contact').title('Contact')), S.listItem() .title('Visitor') .child(S.documentTypeList('visitor').title('Visitor')), @@ -36,8 +36,22 @@ export const structure: StructureResolver = (S) => .title('Academics') .items([ S.listItem() - .title('Admission') - .child(S.documentTypeList('Admission').title('Admission')), + .title('Seat Structure') + .child( + S.documentTypeList('seatStructure').title('Seat Structure') + ), + S.listItem() + .title('Links Structure') + .child( + S.documentTypeList('linksStructure').title('Links Structure') + ), + S.listItem() + .title('Description Structure') + .child( + S.documentTypeList('descriptionStructure').title( + 'Description Structure' + ) + ), S.listItem() .title('CSE Academic') .child(S.documentTypeList('cseDetail').title('CSE')), @@ -76,23 +90,21 @@ export const structure: StructureResolver = (S) => ]) ), S.listItem() - .title('') + .title('Research and Development') .child( S.list() .title('Research and Development') .items([ S.listItem() .title('KRC Data') - .child(S.documentTypeList('krcData').title('KRC Data')), + .child(S.documentTypeList('krcData').title('krcData')), S.listItem() .title('KRC Data Tel') - .child(S.documentTypeList('krcDataTEL').title('KRC Data Tel')), + .child(S.documentTypeList('krcDataTel').title('krcDataTel')), S.listItem() .title('KRC Data Tel Full') .child( - S.documentTypeList('krcDataTelFull').title( - 'KRC Data Tel Full' - ) + S.documentTypeList('krcDataTelFull').title('krcDataTelFull') ), ]) ), From 25e2a782a7facb1f53bca8514497162a8d19324a Mon Sep 17 00:00:00 2001 From: Shardendu Mishra Date: Sun, 26 Jan 2025 19:24:17 +0530 Subject: [PATCH 4/9] fix: improve casing consistency in schema types and structure definitions --- package.json | 2 +- src/sanity/schemaTypes/index.ts | 5 ----- src/sanity/structure.ts | 10 ++++++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 05c1212..ebafdb7 100644 --- a/package.json +++ b/package.json @@ -70,4 +70,4 @@ "typescript": "^5" }, "packageManager": "pnpm@9.15.3+sha512.1f79bc245a66eb0b07c5d4d83131240774642caaa86ef7d0434ab47c0d16f66b04e21e0c086eb61e62c77efc4d7f7ec071afad3796af64892fae66509173893a" -} \ No newline at end of file +} diff --git a/src/sanity/schemaTypes/index.ts b/src/sanity/schemaTypes/index.ts index 658ef25..6a36d75 100644 --- a/src/sanity/schemaTypes/index.ts +++ b/src/sanity/schemaTypes/index.ts @@ -41,7 +41,6 @@ import { export const schema: { types: SchemaTypeDefinition[] } = { types: [ - // advice: please Maintain Consistence in Code In-appropriate Casing will cause app to break when data is used else where research, advertisement, campusData, @@ -50,7 +49,6 @@ export const schema: { types: SchemaTypeDefinition[] } = { krcDataTel, krcDataTelFull, Faculty, - senate, staff, chairPerson, @@ -67,7 +65,6 @@ export const schema: { types: SchemaTypeDefinition[] } = { eceDetail, dsaiDetail, Credit, - Jobs, Member, FacultyAdvisor, @@ -76,12 +73,10 @@ export const schema: { types: SchemaTypeDefinition[] } = { Club, NIRF, Tender, - AnnualReport, ContactInf, ContactCategory, ContactData, - EventInfo, Gallery, MainCarouselImage, diff --git a/src/sanity/structure.ts b/src/sanity/structure.ts index d7268de..29236e9 100644 --- a/src/sanity/structure.ts +++ b/src/sanity/structure.ts @@ -20,7 +20,7 @@ export const structure: StructureResolver = (S) => .child(S.documentTypeList('about').title('About')), S.listItem() .title('Chair Person') - .child(S.documentTypeList('chairPerson').title('chairPerson')), + .child(S.documentTypeList('chairPerson').title('Chair Person')), S.listItem() .title('Contact') .child(S.documentTypeList('contact').title('Contact')), @@ -97,14 +97,16 @@ export const structure: StructureResolver = (S) => .items([ S.listItem() .title('KRC Data') - .child(S.documentTypeList('krcData').title('krcData')), + .child(S.documentTypeList('krcData').title('KRC Data')), S.listItem() .title('KRC Data Tel') - .child(S.documentTypeList('krcDataTel').title('krcDataTel')), + .child(S.documentTypeList('krcDataTel').title('KRC Data Tel')), S.listItem() .title('KRC Data Tel Full') .child( - S.documentTypeList('krcDataTelFull').title('krcDataTelFull') + S.documentTypeList('krcDataTelFull').title( + 'KRC Data Tel Full' + ) ), ]) ), From 2e5f14daee831953fe4730e4f13de57ee8778a32 Mon Sep 17 00:00:00 2001 From: Shardendu Mishra Date: Mon, 27 Jan 2025 20:58:03 +0530 Subject: [PATCH 5/9] fix: added schema to folder --- .../schemaTypes/{ => generalInfo}/Jobs.ts | 0 .../Gallery.ts | 0 src/sanity/schemaTypes/{ => home}/HomePage.ts | 0 src/sanity/schemaTypes/index.ts | 14 +- .../{ => newsAndUpdates}/Former.ts | 0 .../FormerBoardOfGovernor.ts | 0 .../{ => researchDevelopment}/Research.ts | 0 .../schemaTypes/{ => studentLife}/Members.ts | 0 src/sanity/structure.ts | 152 +++++++++++++----- 9 files changed, 121 insertions(+), 45 deletions(-) rename src/sanity/schemaTypes/{ => generalInfo}/Jobs.ts (100%) rename src/sanity/schemaTypes/{ => governanceAndAdministration}/Gallery.ts (100%) rename src/sanity/schemaTypes/{ => home}/HomePage.ts (100%) rename src/sanity/schemaTypes/{ => newsAndUpdates}/Former.ts (100%) rename src/sanity/schemaTypes/{ => newsAndUpdates}/FormerBoardOfGovernor.ts (100%) rename src/sanity/schemaTypes/{ => researchDevelopment}/Research.ts (100%) rename src/sanity/schemaTypes/{ => studentLife}/Members.ts (100%) diff --git a/src/sanity/schemaTypes/Jobs.ts b/src/sanity/schemaTypes/generalInfo/Jobs.ts similarity index 100% rename from src/sanity/schemaTypes/Jobs.ts rename to src/sanity/schemaTypes/generalInfo/Jobs.ts diff --git a/src/sanity/schemaTypes/Gallery.ts b/src/sanity/schemaTypes/governanceAndAdministration/Gallery.ts similarity index 100% rename from src/sanity/schemaTypes/Gallery.ts rename to src/sanity/schemaTypes/governanceAndAdministration/Gallery.ts diff --git a/src/sanity/schemaTypes/HomePage.ts b/src/sanity/schemaTypes/home/HomePage.ts similarity index 100% rename from src/sanity/schemaTypes/HomePage.ts rename to src/sanity/schemaTypes/home/HomePage.ts diff --git a/src/sanity/schemaTypes/index.ts b/src/sanity/schemaTypes/index.ts index 6a36d75..b2296fd 100644 --- a/src/sanity/schemaTypes/index.ts +++ b/src/sanity/schemaTypes/index.ts @@ -13,16 +13,16 @@ import { Credit } from './Credits'; import { dsaiDetail } from './academics/DSAIAcademics'; import { eceDetail } from './academics/ECEAcademics'; import { facilities } from './studentLife/Facilities'; -import { former } from './Former'; -import { formerBoardOfGovernor } from './FormerBoardOfGovernor'; -import { Jobs } from './Jobs'; +import { former } from './newsAndUpdates/Former'; +import { formerBoardOfGovernor } from './newsAndUpdates/FormerBoardOfGovernor'; +import { Jobs } from './generalInfo/Jobs'; import { krcData } from './researchDevelopment/KrcData'; import { krcDataTel } from './researchDevelopment/KrcDataTel'; import { krcDataTelFull } from './researchDevelopment/KrcDataTelFull'; import { FacultyAdvisor, Issues, Member, Team } from './studentLife/Magazine'; -import { Club } from './Members'; +import { Club } from './studentLife/Members'; import { NIRF } from './reportsAndRankings/Nirf'; -import { research, advertisement } from './Research'; +import { research, advertisement } from './researchDevelopment/Research'; import { senate } from './governanceAndAdministration/Senate'; import { staff } from './academics/Staff'; import { visitor } from './generalInfo/Visitor'; @@ -30,9 +30,9 @@ import { Faculty } from './academics/Faculty'; import { announcementType } from './newsAndUpdates/Announcement'; import { Tender } from './newsAndUpdates/Tenders'; import { AnnualReport } from './reportsAndRankings/Annual_reports'; -import { Gallery } from './Gallery'; +import { Gallery } from './governanceAndAdministration/Gallery'; import { EventInfo } from './studentLife/Events'; -import { MainCarouselImage, ProgramCards, ProgramsType } from './HomePage'; +import { MainCarouselImage, ProgramCards, ProgramsType } from './home/HomePage'; import { ContactCategory, ContactData, diff --git a/src/sanity/schemaTypes/Former.ts b/src/sanity/schemaTypes/newsAndUpdates/Former.ts similarity index 100% rename from src/sanity/schemaTypes/Former.ts rename to src/sanity/schemaTypes/newsAndUpdates/Former.ts diff --git a/src/sanity/schemaTypes/FormerBoardOfGovernor.ts b/src/sanity/schemaTypes/newsAndUpdates/FormerBoardOfGovernor.ts similarity index 100% rename from src/sanity/schemaTypes/FormerBoardOfGovernor.ts rename to src/sanity/schemaTypes/newsAndUpdates/FormerBoardOfGovernor.ts diff --git a/src/sanity/schemaTypes/Research.ts b/src/sanity/schemaTypes/researchDevelopment/Research.ts similarity index 100% rename from src/sanity/schemaTypes/Research.ts rename to src/sanity/schemaTypes/researchDevelopment/Research.ts diff --git a/src/sanity/schemaTypes/Members.ts b/src/sanity/schemaTypes/studentLife/Members.ts similarity index 100% rename from src/sanity/schemaTypes/Members.ts rename to src/sanity/schemaTypes/studentLife/Members.ts diff --git a/src/sanity/structure.ts b/src/sanity/structure.ts index 29236e9..a55cfbf 100644 --- a/src/sanity/structure.ts +++ b/src/sanity/structure.ts @@ -9,26 +9,6 @@ export const structure: StructureResolver = (S) => S.list() .title('Content') .items([ - S.listItem() - .title('General Information') - .child( - S.list() - .title('General Information') - .items([ - S.listItem() - .title('About') - .child(S.documentTypeList('about').title('About')), - S.listItem() - .title('Chair Person') - .child(S.documentTypeList('chairPerson').title('Chair Person')), - S.listItem() - .title('Contact') - .child(S.documentTypeList('contact').title('Contact')), - S.listItem() - .title('Visitor') - .child(S.documentTypeList('visitor').title('Visitor')), - ]) - ), S.listItem() .title('Academics') .child( @@ -70,23 +50,107 @@ export const structure: StructureResolver = (S) => ]) ), S.listItem() - .title('Student Life') + .title('Home') .child( S.list() - .title('Student Life') + .title('Home') .items([ S.listItem() - .title('Campus') - .child(S.documentTypeList('campusData').title('Campus Data')), + .title('Main Carousel Image') + .child( + S.documentTypeList('mainCarouselImage').title( + 'Main Carousel Image' + ) + ), S.listItem() - .title('Events') - .child(S.documentTypeList('eventInf').title('Events')), + .title('Program Cards') + .child( + S.documentTypeList('programCards').title('Program Cards') + ), S.listItem() - .title('Facility') - .child(S.documentTypeList('facility').title('Facility')), + .title('Program Type') + .child( + S.documentTypeList('programsType').title('Program Type') + ), + ]) + ), + S.listItem() + .title('General Information') + .child( + S.list() + .title('General Information') + .items([ S.listItem() - .title('Magazine') - .child(S.documentTypeList('issues').title('Magazines')), + .title('About') + .child(S.documentTypeList('about').title('About')), + S.listItem() + .title('Chair Person') + .child(S.documentTypeList('chairPerson').title('Chair Person')), + S.listItem() + .title('Contact') + .child(S.documentTypeList('contact').title('Contact')), + S.listItem() + .title('Visitor') + .child(S.documentTypeList('visitor').title('Visitor')), + S.listItem() + .title('Jobs') + .child(S.documentTypeList('jobs').title('Jobs')), + ]) + ), + S.listItem() + .title('Governance & Administration') + .child( + S.list() + .title('Governance & Administration') + .items([ + S.listItem() + .title('Board Of Governor') + .child( + S.documentTypeList('boardOfGovernor').title( + 'Board Of Governor' + ) + ), + S.listItem() + .title('Gallery') + .child(S.documentTypeList('gallery').title('Gallery')), + S.listItem() + .title('Senate') + .child(S.documentTypeList('senate').title('Senate')), + ]) + ), + S.listItem() + .title('News & Updates') + .child( + S.list() + .title('News & Updates Documents') + .items([ + S.listItem() + .title('Announcements') + .child( + S.documentTypeList('announcement').title('Announcements') + ), + S.listItem() + .title('Tenders') + .child(S.documentTypeList('tender').title('Tenders')), + S.listItem() + .title('Former') + .child(S.documentTypeList('former').title('Former')), + ]) + ), + S.listItem() + .title('Report and Ranking') + .child( + S.list() + .title('Report and Ranking') + .items([ + S.listItem() + .title('Annunal Report') + .child( + S.documentTypeList('annualReport').title('Annual Report') + ), + S.listItem() + .title('NIRF') + .child(S.documentTypeList('nirf').title('NIRF')), ]) ), S.listItem() @@ -108,22 +172,34 @@ export const structure: StructureResolver = (S) => 'KRC Data Tel Full' ) ), + S.listItem() + .title('Research Profiles') + .child( + S.documentTypeList('profiles').title('Research Profiles') + ), ]) ), S.listItem() - .title('News & Updates') + .title('Student Life') .child( S.list() - .title('News & Updates Documents') + .title('Student Life') .items([ S.listItem() - .title('Announcements') - .child( - S.documentTypeList('announcement').title('Announcements') - ), + .title('Campus') + .child(S.documentTypeList('campusData').title('Campus Data')), S.listItem() - .title('Tenders') - .child(S.documentTypeList('tender').title('Tenders')), + .title('Events') + .child(S.documentTypeList('eventInf').title('Events')), + S.listItem() + .title('Facility') + .child(S.documentTypeList('facility').title('Facility')), + S.listItem() + .title('Magazine') + .child(S.documentTypeList('issues').title('Magazines')), + S.listItem() + .title('Clubs') + .child(S.documentTypeList('club').title('Clubs')), ]) ), ...S.documentTypeListItems().filter(schemaFilter), From bb74f34191f06c031df07387efa420537f930f7c Mon Sep 17 00:00:00 2001 From: Shardendu Mishra Date: Mon, 27 Jan 2025 21:11:46 +0530 Subject: [PATCH 6/9] refactor: reorganize schema imports and move definitions to appropriate directories --- src/sanity/schemaTypes/{ => cgc}/cgc.ts | 0 .../schemaTypes/{ => generalInfo}/Finance.ts | 0 src/sanity/schemaTypes/index.ts | 8 +++--- .../building_and_works.ts | 0 .../{ => studentLife}/student_coordinators.ts | 0 src/sanity/structure.ts | 28 +++++++++++++++++++ 6 files changed, 32 insertions(+), 4 deletions(-) rename src/sanity/schemaTypes/{ => cgc}/cgc.ts (100%) rename src/sanity/schemaTypes/{ => generalInfo}/Finance.ts (100%) rename src/sanity/schemaTypes/{ => newsAndUpdates}/building_and_works.ts (100%) rename src/sanity/schemaTypes/{ => studentLife}/student_coordinators.ts (100%) diff --git a/src/sanity/schemaTypes/cgc.ts b/src/sanity/schemaTypes/cgc/cgc.ts similarity index 100% rename from src/sanity/schemaTypes/cgc.ts rename to src/sanity/schemaTypes/cgc/cgc.ts diff --git a/src/sanity/schemaTypes/Finance.ts b/src/sanity/schemaTypes/generalInfo/Finance.ts similarity index 100% rename from src/sanity/schemaTypes/Finance.ts rename to src/sanity/schemaTypes/generalInfo/Finance.ts diff --git a/src/sanity/schemaTypes/index.ts b/src/sanity/schemaTypes/index.ts index bd094e9..22537c3 100644 --- a/src/sanity/schemaTypes/index.ts +++ b/src/sanity/schemaTypes/index.ts @@ -38,10 +38,10 @@ import { ContactData, ContactInf, } from './generalInfo/ContactInfo'; -import { building_and_works } from './building_and_works'; -import { cgc } from './cgc'; -import { Finance } from './Finance'; -import { student_coordinators } from './student_coordinators'; +import { building_and_works } from './newsAndUpdates/building_and_works'; +import { cgc } from './cgc/cgc'; +import { Finance } from './generalInfo/Finance'; +import { student_coordinators } from './studentLife/student_coordinators'; export const schema: { types: SchemaTypeDefinition[] } = { types: [ diff --git a/src/sanity/schemaTypes/building_and_works.ts b/src/sanity/schemaTypes/newsAndUpdates/building_and_works.ts similarity index 100% rename from src/sanity/schemaTypes/building_and_works.ts rename to src/sanity/schemaTypes/newsAndUpdates/building_and_works.ts diff --git a/src/sanity/schemaTypes/student_coordinators.ts b/src/sanity/schemaTypes/studentLife/student_coordinators.ts similarity index 100% rename from src/sanity/schemaTypes/student_coordinators.ts rename to src/sanity/schemaTypes/studentLife/student_coordinators.ts diff --git a/src/sanity/structure.ts b/src/sanity/structure.ts index a55cfbf..2d58624 100644 --- a/src/sanity/structure.ts +++ b/src/sanity/structure.ts @@ -95,6 +95,9 @@ export const structure: StructureResolver = (S) => S.listItem() .title('Jobs') .child(S.documentTypeList('jobs').title('Jobs')), + S.listItem() + .title('Finance') + .child(S.documentTypeList('finance').title('Finance')), ]) ), S.listItem() @@ -135,6 +138,13 @@ export const structure: StructureResolver = (S) => S.listItem() .title('Former') .child(S.documentTypeList('former').title('Former')), + S.listItem() + .title('Building And Works') + .child( + S.documentTypeList('buildingAndWorks').title( + 'Building And Works' + ) + ), ]) ), S.listItem() @@ -200,6 +210,24 @@ export const structure: StructureResolver = (S) => S.listItem() .title('Clubs') .child(S.documentTypeList('club').title('Clubs')), + S.listItem() + .title('Student Coordinators') + .child( + S.documentTypeList('student_coordinators').title( + 'Student Coordinators' + ) + ), + ]) + ), + S.listItem() + .title('CGC') + .child( + S.list() + .title('CGC') + .items([ + S.listItem() + .title('CGC') + .child(S.documentTypeList('cgc').title('CGC')), ]) ), ...S.documentTypeListItems().filter(schemaFilter), From c593c8a8183eea94f6323ed9ea343f51001a0bb9 Mon Sep 17 00:00:00 2001 From: Shardendu Mishra Date: Mon, 27 Jan 2025 21:43:16 +0530 Subject: [PATCH 7/9] fix: standardize schema names and remove duplicate files --- src/sanity/schemaTypes/cgc/cgc.ts | 2 +- .../{generalInfo => generalnfo}/About.ts | 0 .../{generalInfo => generalnfo}/ChairPerson.ts | 0 .../{generalInfo => generalnfo}/ContactInfo.ts | 0 .../{generalInfo => generalnfo}/Finance.ts | 4 ++-- .../{generalInfo => generalnfo}/Jobs.ts | 0 .../{generalInfo => generalnfo}/Visitor.ts | 0 src/sanity/schemaTypes/index.ts | 14 +++++++------- .../studentLife/student_coordinators.ts | 2 +- src/sanity/structure.ts | 12 +----------- 10 files changed, 12 insertions(+), 22 deletions(-) rename src/sanity/schemaTypes/{generalInfo => generalnfo}/About.ts (100%) rename src/sanity/schemaTypes/{generalInfo => generalnfo}/ChairPerson.ts (100%) rename src/sanity/schemaTypes/{generalInfo => generalnfo}/ContactInfo.ts (100%) rename src/sanity/schemaTypes/{generalInfo => generalnfo}/Finance.ts (95%) rename src/sanity/schemaTypes/{generalInfo => generalnfo}/Jobs.ts (100%) rename src/sanity/schemaTypes/{generalInfo => generalnfo}/Visitor.ts (100%) diff --git a/src/sanity/schemaTypes/cgc/cgc.ts b/src/sanity/schemaTypes/cgc/cgc.ts index 39a4196..913ede1 100644 --- a/src/sanity/schemaTypes/cgc/cgc.ts +++ b/src/sanity/schemaTypes/cgc/cgc.ts @@ -2,7 +2,7 @@ import { defineField, defineType } from 'sanity'; export const cgc = defineType({ title: 'cgc', - name: 'Cgc', + name: 'cgc', type: 'document', fields: [ defineField({ diff --git a/src/sanity/schemaTypes/generalInfo/About.ts b/src/sanity/schemaTypes/generalnfo/About.ts similarity index 100% rename from src/sanity/schemaTypes/generalInfo/About.ts rename to src/sanity/schemaTypes/generalnfo/About.ts diff --git a/src/sanity/schemaTypes/generalInfo/ChairPerson.ts b/src/sanity/schemaTypes/generalnfo/ChairPerson.ts similarity index 100% rename from src/sanity/schemaTypes/generalInfo/ChairPerson.ts rename to src/sanity/schemaTypes/generalnfo/ChairPerson.ts diff --git a/src/sanity/schemaTypes/generalInfo/ContactInfo.ts b/src/sanity/schemaTypes/generalnfo/ContactInfo.ts similarity index 100% rename from src/sanity/schemaTypes/generalInfo/ContactInfo.ts rename to src/sanity/schemaTypes/generalnfo/ContactInfo.ts diff --git a/src/sanity/schemaTypes/generalInfo/Finance.ts b/src/sanity/schemaTypes/generalnfo/Finance.ts similarity index 95% rename from src/sanity/schemaTypes/generalInfo/Finance.ts rename to src/sanity/schemaTypes/generalnfo/Finance.ts index af2a35e..a15ac64 100644 --- a/src/sanity/schemaTypes/generalInfo/Finance.ts +++ b/src/sanity/schemaTypes/generalnfo/Finance.ts @@ -1,8 +1,8 @@ import { defineField, defineType } from 'sanity'; -export const Finance = defineType({ +export const finance = defineType({ title: 'finance', - name: 'Finance', + name: 'finance', type: 'document', fields: [ defineField({ diff --git a/src/sanity/schemaTypes/generalInfo/Jobs.ts b/src/sanity/schemaTypes/generalnfo/Jobs.ts similarity index 100% rename from src/sanity/schemaTypes/generalInfo/Jobs.ts rename to src/sanity/schemaTypes/generalnfo/Jobs.ts diff --git a/src/sanity/schemaTypes/generalInfo/Visitor.ts b/src/sanity/schemaTypes/generalnfo/Visitor.ts similarity index 100% rename from src/sanity/schemaTypes/generalInfo/Visitor.ts rename to src/sanity/schemaTypes/generalnfo/Visitor.ts diff --git a/src/sanity/schemaTypes/index.ts b/src/sanity/schemaTypes/index.ts index 22537c3..6c8fa95 100644 --- a/src/sanity/schemaTypes/index.ts +++ b/src/sanity/schemaTypes/index.ts @@ -1,5 +1,5 @@ import { type SchemaTypeDefinition } from 'sanity'; -import { About } from './generalInfo/About'; +import { About } from './generalnfo/About'; import { descriptionStructure, linksStructure, @@ -8,14 +8,14 @@ import { import { boardOfGovernor } from './governanceAndAdministration/BoardOfGovernor'; import { cseDetail } from './academics/CSEAcademics'; import { campusData } from './studentLife/CampusData'; -import { chairPerson } from './generalInfo/ChairPerson'; +import { chairPerson } from './generalnfo/ChairPerson'; import { Credit } from './Credits'; import { dsaiDetail } from './academics/DSAIAcademics'; import { eceDetail } from './academics/ECEAcademics'; import { facilities } from './studentLife/Facilities'; import { former } from './newsAndUpdates/Former'; import { formerBoardOfGovernor } from './newsAndUpdates/FormerBoardOfGovernor'; -import { Jobs } from './generalInfo/Jobs'; +import { Jobs } from './generalnfo/Jobs'; import { krcData } from './researchDevelopment/KrcData'; import { krcDataTel } from './researchDevelopment/KrcDataTel'; import { krcDataTelFull } from './researchDevelopment/KrcDataTelFull'; @@ -25,7 +25,7 @@ import { NIRF } from './reportsAndRankings/Nirf'; import { research, advertisement } from './researchDevelopment/Research'; import { senate } from './governanceAndAdministration/Senate'; import { staff } from './academics/Staff'; -import { visitor } from './generalInfo/Visitor'; +import { visitor } from './generalnfo/Visitor'; import { Faculty } from './academics/Faculty'; import { announcementType } from './newsAndUpdates/Announcement'; import { Tender } from './newsAndUpdates/Tenders'; @@ -37,10 +37,10 @@ import { ContactCategory, ContactData, ContactInf, -} from './generalInfo/ContactInfo'; +} from './generalnfo/ContactInfo'; import { building_and_works } from './newsAndUpdates/building_and_works'; import { cgc } from './cgc/cgc'; -import { Finance } from './generalInfo/Finance'; +import { finance } from './generalnfo/Finance'; import { student_coordinators } from './studentLife/student_coordinators'; export const schema: { types: SchemaTypeDefinition[] } = { @@ -88,7 +88,7 @@ export const schema: { types: SchemaTypeDefinition[] } = { ProgramsType, building_and_works, cgc, - Finance, + finance, student_coordinators, ], }; diff --git a/src/sanity/schemaTypes/studentLife/student_coordinators.ts b/src/sanity/schemaTypes/studentLife/student_coordinators.ts index f816f43..29c7c8f 100644 --- a/src/sanity/schemaTypes/studentLife/student_coordinators.ts +++ b/src/sanity/schemaTypes/studentLife/student_coordinators.ts @@ -2,7 +2,7 @@ import { defineField, defineType } from 'sanity'; export const student_coordinators = defineType({ title: 'student_coordinators', - name: 'student_Coordinators', + name: 'student_coordinators', type: 'document', fields: [ defineField({ diff --git a/src/sanity/structure.ts b/src/sanity/structure.ts index 2d58624..f541290 100644 --- a/src/sanity/structure.ts +++ b/src/sanity/structure.ts @@ -219,17 +219,7 @@ export const structure: StructureResolver = (S) => ), ]) ), - S.listItem() - .title('CGC') - .child( - S.list() - .title('CGC') - .items([ - S.listItem() - .title('CGC') - .child(S.documentTypeList('cgc').title('CGC')), - ]) - ), + S.listItem().title('CGC').child(S.documentTypeList('cgc').title('CGC')), ...S.documentTypeListItems().filter(schemaFilter), S.divider(), ]); From 95ae2942cf98e3ee64c996b71d85a4822630210b Mon Sep 17 00:00:00 2001 From: Shardendu Mishra Date: Mon, 27 Jan 2025 23:18:35 +0530 Subject: [PATCH 8/9] feat: add file search functionality to FTP component --- src/components/FTPComponent.tsx | 59 ++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/src/components/FTPComponent.tsx b/src/components/FTPComponent.tsx index 14bedad..0eb9054 100644 --- a/src/components/FTPComponent.tsx +++ b/src/components/FTPComponent.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ 'use client'; import { useCallback, useEffect, useMemo, useState } from 'react'; @@ -28,28 +29,40 @@ export default function FTPComponent() { const [isRenaming, setIsRenaming] = useState(false); const [updatedFilename, setUpdatedFilename] = useState(''); const [loc, setLoc] = useState<'images' | 'docs'>('images'); - const [editingFilename, setEditingFilename] = useState(null); // Track which file is being edited + const [editingFilename, setEditingFilename] = useState(null); const toast = useToast(); const fetchData = useCallback(async () => { - if (toast && loc) { - try { - setIsLoading(true); - const result = await GetFiles(loc); - setData(result); - } catch (err) { - console.error(`FTP Error: ${err}`); - toast.push({ - status: 'error', - title: "Can't connect to FTP server", - description: 'Check logs', - }); - } finally { - setIsLoading(false); - } + try { + setIsLoading(true); + const result = await GetFiles(loc); + setData(result); + setAllFiles(result); + } catch (err) { + console.log(`FTP Error: ${err}`); + toast.push({ + status: 'error', + title: "Can't connect to FTP server", + description: 'Check logs', + }); + } finally { + setIsLoading(false); } - }, [toast, loc]); + }, [loc]); + + const searchFile = (searchQuery: string) => { + if (!searchQuery.trim()) { + setData(allFiles); + return; + } + + const filteredFiles = allFiles.filter((file: any) => + file.name.toLowerCase().includes(searchQuery.toLowerCase()) + ); + + setData(filteredFiles); + }; // Fetch files on component mount useEffect(() => { @@ -197,7 +210,7 @@ export default function FTPComponent() { { header: 'Name', accessorKey: 'name', - // eslint-disable-next-line @typescript-eslint/no-explicit-any + cell: ({ row }: any) => (
{editingFilename === row.original.name ? ( @@ -229,7 +242,7 @@ export default function FTPComponent() { header: 'Actions', accessorKey: 'actions', enableSorting: false, - // eslint-disable-next-line @typescript-eslint/no-explicit-any + cell: ({ row }: any) => (