From fddf1e885b63b557f3a9e2714b8d759c5da54184 Mon Sep 17 00:00:00 2001 From: Nickolausen Date: Fri, 15 Nov 2024 12:47:14 +0100 Subject: [PATCH] temporary fix to cors issue --- src/components/EducationCard.tsx | 2 +- src/components/GHRepoCard.tsx | 13 ++++++---- src/components/ProjectCard.tsx | 2 +- src/{data => model}/Education.tsx | 0 src/{data => model}/ProjectDetails.tsx | 0 src/pages/Education.tsx | 2 +- src/pages/Projects.tsx | 34 +++++++++++++++++++------- 7 files changed, 36 insertions(+), 17 deletions(-) rename src/{data => model}/Education.tsx (100%) rename src/{data => model}/ProjectDetails.tsx (100%) diff --git a/src/components/EducationCard.tsx b/src/components/EducationCard.tsx index b23c372..a82fe67 100644 --- a/src/components/EducationCard.tsx +++ b/src/components/EducationCard.tsx @@ -1,5 +1,5 @@ // import styles from './EducationCard.module.css' -import { EducationTitle } from '../data/Education' +import { EducationTitle } from '../model/Education' interface IProps { data?: EducationTitle diff --git a/src/components/GHRepoCard.tsx b/src/components/GHRepoCard.tsx index 070f885..61bca90 100644 --- a/src/components/GHRepoCard.tsx +++ b/src/components/GHRepoCard.tsx @@ -1,5 +1,5 @@ // import template_img from '../assets/media/template.jpeg' -import { GHRepoDetails, languageToID } from '../data/ProjectDetails' +import { GHRepoDetails, languageToID } from '../model/ProjectDetails' interface IProps { data: GHRepoDetails @@ -21,10 +21,13 @@ function GHRepoCard({ data }: IProps ) {

<{data.name}/>

{data.description}

- + { + data.language && + + } VIEW ON GITHUB diff --git a/src/components/ProjectCard.tsx b/src/components/ProjectCard.tsx index 8a462e1..bb697d0 100644 --- a/src/components/ProjectCard.tsx +++ b/src/components/ProjectCard.tsx @@ -1,5 +1,5 @@ import { ReactNode } from "react"; -import { languageToID, ProjectDetails } from "../data/ProjectDetails" +import { languageToID, ProjectDetails } from "../model/ProjectDetails" interface IProps { project_info?: ProjectDetails diff --git a/src/data/Education.tsx b/src/model/Education.tsx similarity index 100% rename from src/data/Education.tsx rename to src/model/Education.tsx diff --git a/src/data/ProjectDetails.tsx b/src/model/ProjectDetails.tsx similarity index 100% rename from src/data/ProjectDetails.tsx rename to src/model/ProjectDetails.tsx diff --git a/src/pages/Education.tsx b/src/pages/Education.tsx index e923d47..19feb41 100644 --- a/src/pages/Education.tsx +++ b/src/pages/Education.tsx @@ -1,5 +1,5 @@ import EducationCard from "../components/EducationCard" -import { EducationTitle, Expertise } from "../data/Education" +import { EducationTitle, Expertise } from "../model/Education" import styles from './Education.module.css' const from_school = [ diff --git a/src/pages/Projects.tsx b/src/pages/Projects.tsx index 14bbf64..99d2f8b 100644 --- a/src/pages/Projects.tsx +++ b/src/pages/Projects.tsx @@ -1,6 +1,6 @@ import { ReactNode, useEffect, useState } from "react" import GHRepoCard from "../components/GHRepoCard" -import { GHRepoDetails, ProjectDetails } from "../data/ProjectDetails" +import { GHRepoDetails, ProjectDetails } from "../model/ProjectDetails" import ProjectCard from "../components/ProjectCard" function Projects() @@ -10,7 +10,16 @@ function Projects() useEffect(() => { let fetchedRepos: GHRepoDetails[] = [] - fetch("https://pinned.berrysauce.me/get/Nickolausen") + // TODO: Fix CORS issue + fetch("https://pinned.berrysauce.me/get/Nickolausen", + { + method: "GET", + mode: "cors", + headers: { + "Access-Control-Allow-Origin": "*", + "Content-Type": "application/json" + } + }) .then((res) => res.json()) .then((data) => { data.forEach((el: any) => { @@ -26,6 +35,7 @@ function Projects() setRepos(fetchedRepos) }) + .catch((e) => console.log(e)) }, []) let projects: ProjectDetails[] = [ @@ -70,13 +80,19 @@ function Projects() return <>

Projects

-

From my GitHub's pinned repositories

-
- { - repos.map((repo: GHRepoDetails, idx: number) => ) - } -
-

From previous work experiences

+ { repos.length > 0 && <> +

From my GitHub's pinned repositories

+
+ { + repos.map((repo: GHRepoDetails, idx: number) => ) + } +
+ } + { + repos.length > 0 ? +

From previous work experiences

: +

From previous work experiences

+ }
{ projects.map((proj: ProjectDetails, idx: number) => )