diff --git a/app/(main)/profile/_components/_view_section/education/education.tsx b/app/(main)/profile/_components/_view_section/education/education.tsx index 81fac77..a6300f6 100644 --- a/app/(main)/profile/_components/_view_section/education/education.tsx +++ b/app/(main)/profile/_components/_view_section/education/education.tsx @@ -1,4 +1,5 @@ import { databaseDrizzle } from "@/db/database"; +import { EducationSelection } from "@/db/schemes/profileSchema"; import { formatDate } from "@/utils/helper_function"; import { eq } from "drizzle-orm"; import { notFound } from "next/navigation"; @@ -9,46 +10,40 @@ import { IoSchoolSharp } from "react-icons/io5"; * param {number} props.profileId - The ID of the profile for which education data needs to be fetched. * returns {JSX.Element} - JSX code that displays the education data on a webpage. */ -export const Education = async ({ profileId }: { profileId: number }): Promise => { - try { - const educations = await databaseDrizzle.query.education.findMany({ - where: (edu) => eq(edu.profileId, profileId), - }); - if(educations.length ===0) return
- - return ( -
-

- Education -

-
- {educations.map((edu) => ( -
-
- -
-

- {edu.school} -

-

- {edu.degree} -

-

- {formatDate(edu.startDate)} -{" "} - {edu.endDate ? formatDate(edu.endDate) : "Current"} -

-
+export const Education = ({ + educations, +}: { + educations: EducationSelection[]; +}) => { + return ( +
+

+ Education +

+
+ {educations.map((edu) => ( +
+
+ +
+

+ {edu.school} +

+

+ {edu.degree} +

+

+ {formatDate(edu.startDate)} -{" "} + {edu.endDate ? formatDate(edu.endDate) : "Current"} +

- ))} -
-
- ); - } catch (error) { - return notFound(); - - } +
+ ))} +
+
+ ); }; diff --git a/app/(main)/profile/_components/_view_section/experience/experience.tsx b/app/(main)/profile/_components/_view_section/experience/experience.tsx index d578389..bf9aaaa 100644 --- a/app/(main)/profile/_components/_view_section/experience/experience.tsx +++ b/app/(main)/profile/_components/_view_section/experience/experience.tsx @@ -1,14 +1,11 @@ import { Slide } from "@/animation/Slide"; -import { databaseDrizzle } from "@/db/database"; +import { ExperienceSelection } from "@/db/schemes/profileSchema"; import { formatDate } from "@/utils/helper_function"; import DOMPurify from "isomorphic-dompurify"; import { MdWork } from "react-icons/md"; -export const Experience = async ({ profileId }: { profileId: number }) => { - const jobs = await databaseDrizzle.query.experience.findMany({ - where: (e, o) => o.eq(e.profileId, profileId), - }); - if(!jobs || jobs.length === 0) return
+export const Experience = async ({ experiences }: { experiences: ExperienceSelection[]}) => { + return (
@@ -22,7 +19,7 @@ export const Experience = async ({ profileId }: { profileId: number }) => {
- {jobs.map((data) => ( + {experiences.map((data) => (
= ({ user Image diff --git a/app/(main)/profile/_components/_view_section/section/section.tsx b/app/(main)/profile/_components/_view_section/section/section.tsx index 18b5516..19f93a2 100644 --- a/app/(main)/profile/_components/_view_section/section/section.tsx +++ b/app/(main)/profile/_components/_view_section/section/section.tsx @@ -1,10 +1,8 @@ -import { databaseDrizzle } from "@/db/database"; +import { SectionSelection } from "@/db/schemes/profileSchema"; import { FaPen } from "react-icons/fa"; -const Sections = async ({ profileId }: { profileId: number }) => { - const sections = await databaseDrizzle.query.section.findMany({ - where: (s, o) => o.eq(s.profileId, profileId), - }); +const Sections = async ({ sections }: { sections: SectionSelection[] }) => { + return (
{sections.map((section) => ( diff --git a/app/(main)/profile/_components/_view_section/skills/skills.tsx b/app/(main)/profile/_components/_view_section/skills/skills.tsx index 8f4d975..e6c942c 100644 --- a/app/(main)/profile/_components/_view_section/skills/skills.tsx +++ b/app/(main)/profile/_components/_view_section/skills/skills.tsx @@ -20,7 +20,7 @@ const Skills = ({ skills }: { skills: string }) => { }); const [imageErrors, setImageErrors] = useState<{ [key: string]: boolean }>( - {} + {}, ); /** @@ -53,7 +53,8 @@ const Skills = ({ skills }: { skills: string }) => { ) : ( {skill} { ); }; -export default Skills; \ No newline at end of file +export default Skills; + diff --git a/app/(main)/profile/view/[id]/page.tsx b/app/(main)/profile/view/[id]/page.tsx index ffb0246..f703945 100644 --- a/app/(main)/profile/view/[id]/page.tsx +++ b/app/(main)/profile/view/[id]/page.tsx @@ -1,12 +1,10 @@ import { databaseDrizzle } from "@/db/database"; import { notFound } from "next/navigation"; -import React, { Suspense } from "react"; +import React from "react"; import { getServerSession } from "next-auth"; import { authOptions } from "@/app/api/auth/[...nextauth]/route"; -import ShimmerLoading from "@/global-components/ShimmerLoading"; -import ErrorBoundary from "@/global-components/ErrorBoundary"; import dynamic from "next/dynamic"; import { Spinner } from "@nextui-org/react"; import { ProfileSummary } from "../../_components/_view_section/profile_summary/profile_summary"; @@ -110,32 +108,17 @@ async function ViewProfile({ params }: Props) { /> {user.id === session?.user.id && } - - }> - - - - - }> - - - + + + {profile.skills && } {projects.length !== 0 && } - - }> - - - - - }> - - - + + ); }