From 263cd60260d4ebc6bbb2c9f0307448c2f9585871 Mon Sep 17 00:00:00 2001 From: roi Date: Thu, 23 May 2024 19:28:07 +0300 Subject: [PATCH 01/14] change precommit and pre-push fille to .sh --- .husky/_/.gitignore | 0 .husky/_/husky.sh | 36 ++++++++++++++++++++++++++++++++++++ .husky/pre-commit | 1 - .husky/pre-commit.sh | 5 +++++ .husky/pre-push | 1 - .husky/pre-push.sh | 5 +++++ 6 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 .husky/_/.gitignore create mode 100644 .husky/_/husky.sh delete mode 100755 .husky/pre-commit create mode 100644 .husky/pre-commit.sh delete mode 100755 .husky/pre-push create mode 100644 .husky/pre-push.sh diff --git a/.husky/_/.gitignore b/.husky/_/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/.husky/_/husky.sh b/.husky/_/husky.sh new file mode 100644 index 00000000..cec959a6 --- /dev/null +++ b/.husky/_/husky.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh +if [ -z "$husky_skip_init" ]; then + debug () { + if [ "$HUSKY_DEBUG" = "1" ]; then + echo "husky (debug) - $1" + fi + } + + readonly hook_name="$(basename -- "$0")" + debug "starting $hook_name..." + + if [ "$HUSKY" = "0" ]; then + debug "HUSKY env variable is set to 0, skipping hook" + exit 0 + fi + + if [ -f ~/.huskyrc ]; then + debug "sourcing ~/.huskyrc" + . ~/.huskyrc + fi + + readonly husky_skip_init=1 + export husky_skip_init + sh -e "$0" "$@" + exitCode="$?" + + if [ $exitCode != 0 ]; then + echo "husky - $hook_name hook exited with code $exitCode (error)" + fi + + if [ $exitCode = 127 ]; then + echo "husky - command not found in PATH=$PATH" + fi + + exit $exitCode +fi diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index f27575a8..00000000 --- a/.husky/pre-commit +++ /dev/null @@ -1 +0,0 @@ -npm run precommit diff --git a/.husky/pre-commit.sh b/.husky/pre-commit.sh new file mode 100644 index 00000000..1cc81e59 --- /dev/null +++ b/.husky/pre-commit.sh @@ -0,0 +1,5 @@ + +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run precommit \ No newline at end of file diff --git a/.husky/pre-push b/.husky/pre-push deleted file mode 100755 index 63a52e02..00000000 --- a/.husky/pre-push +++ /dev/null @@ -1 +0,0 @@ -npm run prepush \ No newline at end of file diff --git a/.husky/pre-push.sh b/.husky/pre-push.sh new file mode 100644 index 00000000..7cc95bb5 --- /dev/null +++ b/.husky/pre-push.sh @@ -0,0 +1,5 @@ + +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run prepush \ No newline at end of file From 6d28dc26c2bba4397de305e93e62a9515596ddba Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Mon, 27 May 2024 23:10:40 +0300 Subject: [PATCH 02/14] chore: Refactor ProjectDisplay component to improve performance and readability --- actions/fetchProjectsData.ts | 30 +++- app/[locale]/projects/page.tsx | 38 +++-- .../Projects/ProjectCard/ProjectCard.tsx | 42 ++--- components/Projects/ProjectDisplay.tsx | 12 +- types/project.ts | 158 ++++++++++++------ 5 files changed, 176 insertions(+), 104 deletions(-) diff --git a/actions/fetchProjectsData.ts b/actions/fetchProjectsData.ts index 76743b87..21207cd5 100644 --- a/actions/fetchProjectsData.ts +++ b/actions/fetchProjectsData.ts @@ -2,8 +2,8 @@ import { IProjectsDataResponse, - Project, ProjectPaginationFilter, + SummaryProjectType, } from '@/types/project'; export type ProjectPaginationRequest = { @@ -12,7 +12,7 @@ export type ProjectPaginationRequest = { filter?: ProjectPaginationFilter; }; -const PROJECT_API_ENDPOINT = 'https://baas-data-provider.onrender.com/projects'; +const PROJECT_API_ENDPOINT = "http://localhost:8080/projects"//'https://baas-data-provider.onrender.com/projects'; async function fetchProjectsData({ page = 1, @@ -26,12 +26,30 @@ async function fetchProjectsData({ }, body: JSON.stringify({ page, limit, filter }), }); - + // fetch from endpoint POST with page, limit, filter as IProjectsDataResponse - const { projects, total, languages, pageLanguages, timestamp } = - await response.json(); + const data = + await response.json() as IProjectsDataResponse; + + const parsedProjects = SummaryProjectType.array().safeParse(data.projects); + if (!parsedProjects.success) { + throw new Error(`Failed to parse projects: ${parsedProjects.error}`); + } + + console.log(parsedProjects.data.map((p) => p.item.contributors)); - return { projects, total, languages, pageLanguages, timestamp }; + + const send = { + projects: parsedProjects.data, + total: data.total, + languages: data.languages, + pageLanguages: data.pageLanguages, + timestamp: new Date(data.timestamp), + }; + return send; } export default fetchProjectsData; + + +// make interface for \ No newline at end of file diff --git a/app/[locale]/projects/page.tsx b/app/[locale]/projects/page.tsx index 08310301..3bd9b7be 100644 --- a/app/[locale]/projects/page.tsx +++ b/app/[locale]/projects/page.tsx @@ -27,12 +27,14 @@ const ProjectsPage = () => { */ const projectIncludesActiveTags = useCallback( (project: Project) => { - return project.item.data.repository.languages.edges.some(edge => - tags.some(tag => tag.isActive && tag.name === edge.node.name) + console.log({project, tags}) + return project.item.languages?.some(edge => + tags.some(tag => tag.isActive && tag.name === edge) ); }, [tags] ); + /** * @@ -83,32 +85,38 @@ const ProjectsPage = () => { filter, }); - setProjects( - projects.filter((p: Project) => - p.item.data.repository.name - .toLocaleLowerCase() - .trim() - .includes(searchByProjectNameValue.toLocaleLowerCase().trim()) - ) + const projecteFilterdByName = projects.filter((p: Project) => + p.item?.name?.toLocaleLowerCase() + .trim() + .includes(searchByProjectNameValue.toLocaleLowerCase().trim()) ); - const newTags: ProjectFilter[] = []; pageLanguages.forEach((lang: string) => { newTags.push({ name: lang, isActive: true }); }); - setTags(newTags); + + return { + newTags, + projecteFilterdByName, + } } catch (error) { console.error('Failed to fetch projects:', error); - } finally { - setLoading(false); } }, [filter, searchByProjectNameValue]); useEffect(() => { - debouncedFetchProjectsData(); + debouncedFetchProjectsData().then((data) => { + if (!data) return; + console.log(data) + setProjects(data.projecteFilterdByName); + setTags(data.newTags); + }).finally(() => { + setLoading(false); + }); + // eslint-disable-next-line react-hooks/exhaustive-deps - }, [filter, searchByProjectNameValue]); + }, [filter, searchByProjectNameValue, debouncedFetchProjectsData]); return (
diff --git a/components/Projects/ProjectCard/ProjectCard.tsx b/components/Projects/ProjectCard/ProjectCard.tsx index 86050fe9..2b63681d 100644 --- a/components/Projects/ProjectCard/ProjectCard.tsx +++ b/components/Projects/ProjectCard/ProjectCard.tsx @@ -10,35 +10,29 @@ import { getChannelUrl } from '../linkToDiscordChannel'; import { Project } from '@/types/project'; import { useTranslations } from 'next-intl'; -export interface ProjectCardProps { - project: Project; +type ProjectItem = Project["item"] + +export interface ProjectCardProps extends Required { activeLanguagesNames: string[]; } export default function ProjectCard({ - project: { - item: { - data: { - repository: { - openGraphImageUrl, - updatedAt, - createdAt, - name, - url, - description, - languages, - contributors: { edges: contributors }, - }, - }, - }, - }, + owner, + updatedAt, + createdAt, + name, + url, + description, + languages, + contributors, activeLanguagesNames, }: ProjectCardProps) { - const updatedDateString = new Date(updatedAt) + + const updatedDateString = new Date(updatedAt ?? "") .toLocaleDateString('he-IL') .replaceAll('.', '/'); - const createdDateString = new Date(createdAt) + const createdDateString = new Date(createdAt ?? "") .toLocaleDateString('he-IL') .replaceAll('.', '/'); @@ -53,7 +47,7 @@ export default function ProjectCard({ @@ -76,8 +70,8 @@ export default function ProjectCard({
({ - imageSrc: c.node.avatarUrl, - name: c.node.login, + imageSrc: c.avatarUrl, + name: c.login, }))} > @@ -89,7 +83,7 @@ export default function ProjectCard({
l.node.name)} + tags={languages} activeLanguagesNames={activeLanguagesNames} >
diff --git a/components/Projects/ProjectDisplay.tsx b/components/Projects/ProjectDisplay.tsx index 730e1b8d..72f6e819 100644 --- a/components/Projects/ProjectDisplay.tsx +++ b/components/Projects/ProjectDisplay.tsx @@ -13,13 +13,15 @@ const ProjectsDisplay = ({ }: ProjectsDisplayProps) => { return (
- {projects.map((project, i) => ( - { + + return - ))} + } + )}
); }; diff --git a/types/project.ts b/types/project.ts index a402d60d..77bff42b 100644 --- a/types/project.ts +++ b/types/project.ts @@ -1,3 +1,5 @@ +import { z } from "zod"; + export enum ProjectPaginationFilter { ALL = 'all', RECENTLY_UPDATED = 'recently_updated', @@ -13,68 +15,116 @@ export type IProjectsDataResponse = { timestamp: Date; }; -export type Project = { - _id: string; - timestamp: Date; - item: Item; - error: null; - meta: Meta; - __v: number; -}; +const dateToString = z.coerce.date().or(z.string()); -export type Item = { - data: Data; -}; +// Define the summary schema using Zod +const SummarySchema = z.object({ + timestamp: z.string(), + item: z.object({ + name: z.string(), + owner: z + .object({ + id: z.string(), + login: z.string(), + avatarUrl: z.string(), + }) + , + description: z.string().nullable(), + url: z.string(), + stargazerCount: z.number(), + languages: z.array(z.string()), + contributors: z + .array( + z + .object({ + login: z.string(), + avatarUrl: z.string(), + }) + , + ), + createdAt: dateToString, + updatedAt: dateToString, + }), + errorsData: z + .array( + z + .object({ + type: z.string(), + message: z.string(), + }) + , + ) + , +}); -export type Data = { - repository: Repository; -}; +export const SummaryProjectType = SummarySchema; -export type Repository = { - name: string; - owner: Owner; - openGraphImageUrl: string; - description: string; - url: string; - createdAt: Date; - updatedAt: Date; - stargazerCount: number; - languages: Languages; - collaborators: null; - contributors: Contributors; -}; +// Infer the TypeScript type from the summary schema +export type Project = z.infer; -export type Contributors = { - edges: ContributorsEdge[]; -}; -export type ContributorsEdge = { - node: ContributorNode; -}; +// export type Project = { +// _id: string; +// timestamp: Date; +// item: Item; +// error: null; +// meta: Meta; +// __v: number; +// }; -export type ContributorNode = { - avatarUrl: string; - login: string; -}; +// export type Item = { +// data: Data; +// }; -export type Languages = { - edges: LanguagesEdge[]; -}; +// export type Data = { +// repository: Repository; +// }; -export type LanguagesEdge = { - node: LanguageNode; -}; +// export type Repository = { +// name: string; +// owner: Owner; +// openGraphImageUrl: string; +// description: string; +// url: string; +// createdAt: Date; +// updatedAt: Date; +// stargazerCount: number; +// languages: Languages; +// collaborators: null; +// contributors: Contributors; +// }; -export type LanguageNode = { - name: string; -}; +// export type Contributors = { +// edges: ContributorsEdge[]; +// }; -export type Owner = { - id: string; - login: string; - avatarUrl: string; -}; +// export type ContributorsEdge = { +// node: ContributorNode; +// }; -export type Meta = { - link: string; -}; +// export type ContributorNode = { +// avatarUrl: string; +// login: string; +// }; + +// export type Languages = { +// edges: LanguagesEdge[]; +// }; + +// export type LanguagesEdge = { +// node: LanguageNode; +// }; + +// export type LanguageNode = { +// name: string; +// }; + +// export type Owner = { +// id: string; +// login: string; +// avatarUrl: string; +// }; + +// export type Meta = { +// link: string; +// }; From a29d913f6046dc86b813bc639177363907aba80c Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Mon, 27 May 2024 23:18:19 +0300 Subject: [PATCH 03/14] chore: Update page title in newbiesPage.spec.ts --- tests/newbiesPage.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/newbiesPage.spec.ts b/tests/newbiesPage.spec.ts index 0c9a791d..b168bbbf 100644 --- a/tests/newbiesPage.spec.ts +++ b/tests/newbiesPage.spec.ts @@ -11,7 +11,7 @@ test.describe('Test Newbies page', () => { await page.waitForNavigation(); const pageTitle = await page.title(); - expect(pageTitle).toContain('Newbies'); + expect(pageTitle).toContain('מצטרפים חדשים - Newbies | מעקף'); }); test('should render NEWBIES', async ({ page }) => { From 0ac36854d29065fca5684c36f86962e0ca8155a9 Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Tue, 28 May 2024 11:07:38 +0300 Subject: [PATCH 04/14] refactor: Remove console.log statement in fetchProjectsData.ts --- actions/fetchProjectsData.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/actions/fetchProjectsData.ts b/actions/fetchProjectsData.ts index 21207cd5..fc55e72b 100644 --- a/actions/fetchProjectsData.ts +++ b/actions/fetchProjectsData.ts @@ -36,9 +36,6 @@ async function fetchProjectsData({ throw new Error(`Failed to parse projects: ${parsedProjects.error}`); } - console.log(parsedProjects.data.map((p) => p.item.contributors)); - - const send = { projects: parsedProjects.data, total: data.total, From 3cfe4f52a93d851e35c67132db95f0d6551091b2 Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Tue, 28 May 2024 11:09:43 +0300 Subject: [PATCH 05/14] make --- actions/fetchProjectsData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/fetchProjectsData.ts b/actions/fetchProjectsData.ts index fc55e72b..a82fc05c 100644 --- a/actions/fetchProjectsData.ts +++ b/actions/fetchProjectsData.ts @@ -12,7 +12,7 @@ export type ProjectPaginationRequest = { filter?: ProjectPaginationFilter; }; -const PROJECT_API_ENDPOINT = "http://localhost:8080/projects"//'https://baas-data-provider.onrender.com/projects'; +const PROJECT_API_ENDPOINT = 'https://baas-data-provider.onrender.com/projects';//"http://localhost:8080/projects" async function fetchProjectsData({ page = 1, From 960cb99a19d28d13f23761c89c709664c3e5c08f Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Tue, 28 May 2024 11:24:25 +0300 Subject: [PATCH 06/14] refactor: Update fetchProjectsData.ts and page.tsx --- actions/fetchProjectsData.ts | 5 ++++- app/[locale]/projects/page.tsx | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/actions/fetchProjectsData.ts b/actions/fetchProjectsData.ts index a82fc05c..8b3ed2e0 100644 --- a/actions/fetchProjectsData.ts +++ b/actions/fetchProjectsData.ts @@ -12,7 +12,8 @@ export type ProjectPaginationRequest = { filter?: ProjectPaginationFilter; }; -const PROJECT_API_ENDPOINT = 'https://baas-data-provider.onrender.com/projects';//"http://localhost:8080/projects" +// const PROJECT_API_ENDPOINT = "http://localhost:8080/projects" +const PROJECT_API_ENDPOINT = 'https://baas-data-provider.onrender.com/projects'; async function fetchProjectsData({ page = 1, @@ -32,10 +33,12 @@ async function fetchProjectsData({ await response.json() as IProjectsDataResponse; const parsedProjects = SummaryProjectType.array().safeParse(data.projects); + if (!parsedProjects.success) { throw new Error(`Failed to parse projects: ${parsedProjects.error}`); } + const send = { projects: parsedProjects.data, total: data.total, diff --git a/app/[locale]/projects/page.tsx b/app/[locale]/projects/page.tsx index 3bd9b7be..08555a39 100644 --- a/app/[locale]/projects/page.tsx +++ b/app/[locale]/projects/page.tsx @@ -27,7 +27,6 @@ const ProjectsPage = () => { */ const projectIncludesActiveTags = useCallback( (project: Project) => { - console.log({project, tags}) return project.item.languages?.some(edge => tags.some(tag => tag.isActive && tag.name === edge) ); @@ -107,7 +106,6 @@ const ProjectsPage = () => { useEffect(() => { debouncedFetchProjectsData().then((data) => { if (!data) return; - console.log(data) setProjects(data.projecteFilterdByName); setTags(data.newTags); }).finally(() => { From 60cd0281709f374d62929e62d0beeddd4bc22272 Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Wed, 29 May 2024 08:57:41 +0300 Subject: [PATCH 07/14] refactor: Remove unused code in project.ts --- types/project.ts | 68 ------------------------------------------------ 1 file changed, 68 deletions(-) diff --git a/types/project.ts b/types/project.ts index 77bff42b..f1b766ac 100644 --- a/types/project.ts +++ b/types/project.ts @@ -17,7 +17,6 @@ export type IProjectsDataResponse = { const dateToString = z.coerce.date().or(z.string()); -// Define the summary schema using Zod const SummarySchema = z.object({ timestamp: z.string(), item: z.object({ @@ -59,72 +58,5 @@ const SummarySchema = z.object({ export const SummaryProjectType = SummarySchema; -// Infer the TypeScript type from the summary schema export type Project = z.infer; - -// export type Project = { -// _id: string; -// timestamp: Date; -// item: Item; -// error: null; -// meta: Meta; -// __v: number; -// }; - -// export type Item = { -// data: Data; -// }; - -// export type Data = { -// repository: Repository; -// }; - -// export type Repository = { -// name: string; -// owner: Owner; -// openGraphImageUrl: string; -// description: string; -// url: string; -// createdAt: Date; -// updatedAt: Date; -// stargazerCount: number; -// languages: Languages; -// collaborators: null; -// contributors: Contributors; -// }; - -// export type Contributors = { -// edges: ContributorsEdge[]; -// }; - -// export type ContributorsEdge = { -// node: ContributorNode; -// }; - -// export type ContributorNode = { -// avatarUrl: string; -// login: string; -// }; - -// export type Languages = { -// edges: LanguagesEdge[]; -// }; - -// export type LanguagesEdge = { -// node: LanguageNode; -// }; - -// export type LanguageNode = { -// name: string; -// }; - -// export type Owner = { -// id: string; -// login: string; -// avatarUrl: string; -// }; - -// export type Meta = { -// link: string; -// }; From 66fdfadf67b46daf4d32ff448aca0efc44b65e34 Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Wed, 29 May 2024 09:03:28 +0300 Subject: [PATCH 08/14] make --- app/[locale]/projects/page.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/[locale]/projects/page.tsx b/app/[locale]/projects/page.tsx index 08555a39..99ab909c 100644 --- a/app/[locale]/projects/page.tsx +++ b/app/[locale]/projects/page.tsx @@ -84,11 +84,12 @@ const ProjectsPage = () => { filter, }); - const projecteFilterdByName = projects.filter((p: Project) => - p.item?.name?.toLocaleLowerCase() + const projectsFilteredByName = projects.filter((p: Project) => + p.item?.name?.toLowerCase() .trim() - .includes(searchByProjectNameValue.toLocaleLowerCase().trim()) + .includes(searchByProjectNameValue.toLowerCase().trim()) ); + const newTags: ProjectFilter[] = []; pageLanguages.forEach((lang: string) => { newTags.push({ name: lang, isActive: true }); @@ -96,7 +97,7 @@ const ProjectsPage = () => { return { newTags, - projecteFilterdByName, + projectsFilteredByName, } } catch (error) { console.error('Failed to fetch projects:', error); @@ -106,7 +107,7 @@ const ProjectsPage = () => { useEffect(() => { debouncedFetchProjectsData().then((data) => { if (!data) return; - setProjects(data.projecteFilterdByName); + setProjects(data.projectsFilteredByName); setTags(data.newTags); }).finally(() => { setLoading(false); From e5c8b3ceff70d13641bcc1ca379b7c67ca91c294 Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Wed, 29 May 2024 09:12:01 +0300 Subject: [PATCH 09/14] Fix project name filtering and refactor code --- app/[locale]/projects/page.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/app/[locale]/projects/page.tsx b/app/[locale]/projects/page.tsx index 99ab909c..5d3f5306 100644 --- a/app/[locale]/projects/page.tsx +++ b/app/[locale]/projects/page.tsx @@ -156,4 +156,5 @@ const ProjectsPage = () => { ); }; + export default ProjectsPage; From ac4490911be8e0dade9bd4c4af8871827fc6b250 Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Wed, 29 May 2024 09:15:58 +0300 Subject: [PATCH 10/14] refactor: Update fetchProjectsData.ts to use destructuring for response data --- actions/fetchProjectsData.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/actions/fetchProjectsData.ts b/actions/fetchProjectsData.ts index 8b3ed2e0..7c8ce049 100644 --- a/actions/fetchProjectsData.ts +++ b/actions/fetchProjectsData.ts @@ -29,10 +29,16 @@ async function fetchProjectsData({ }); // fetch from endpoint POST with page, limit, filter as IProjectsDataResponse - const data = + const { + projects, + total, + languages, + pageLanguages, + timestamp, + } = await response.json() as IProjectsDataResponse; - const parsedProjects = SummaryProjectType.array().safeParse(data.projects); + const parsedProjects = SummaryProjectType.array().safeParse(projects); if (!parsedProjects.success) { throw new Error(`Failed to parse projects: ${parsedProjects.error}`); @@ -41,15 +47,12 @@ async function fetchProjectsData({ const send = { projects: parsedProjects.data, - total: data.total, - languages: data.languages, - pageLanguages: data.pageLanguages, - timestamp: new Date(data.timestamp), + total: total, + languages: languages, + pageLanguages: pageLanguages, + timestamp: new Date(timestamp), }; return send; } -export default fetchProjectsData; - - -// make interface for \ No newline at end of file +export default fetchProjectsData; \ No newline at end of file From 857f325826ac16ecda0155de9b597fe431976537 Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Wed, 29 May 2024 09:17:20 +0300 Subject: [PATCH 11/14] refactor: Update fetchProjectsData.ts to use destructuring for response data --- actions/fetchProjectsData.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/actions/fetchProjectsData.ts b/actions/fetchProjectsData.ts index 7c8ce049..a04946ba 100644 --- a/actions/fetchProjectsData.ts +++ b/actions/fetchProjectsData.ts @@ -12,7 +12,6 @@ export type ProjectPaginationRequest = { filter?: ProjectPaginationFilter; }; -// const PROJECT_API_ENDPOINT = "http://localhost:8080/projects" const PROJECT_API_ENDPOINT = 'https://baas-data-provider.onrender.com/projects'; async function fetchProjectsData({ From 242c3de355576d2ddc0b3b5b2f183cad9b332d8a Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Fri, 31 May 2024 22:47:12 +0300 Subject: [PATCH 12/14] fix picture project fetched currectly --- actions/fetchProjectsData.ts | 5 ++++- components/Projects/ProjectCard/ProjectCard.tsx | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/actions/fetchProjectsData.ts b/actions/fetchProjectsData.ts index a04946ba..35bae52e 100644 --- a/actions/fetchProjectsData.ts +++ b/actions/fetchProjectsData.ts @@ -13,13 +13,14 @@ export type ProjectPaginationRequest = { }; const PROJECT_API_ENDPOINT = 'https://baas-data-provider.onrender.com/projects'; +const PROJECT_API_LOCAL_ENDPOINT = 'http://localhost:8080/projects'; async function fetchProjectsData({ page = 1, limit = 100, filter = ProjectPaginationFilter.ALL, }: ProjectPaginationRequest): Promise { - const response = await fetch(PROJECT_API_ENDPOINT, { + const response = await fetch(PROJECT_API_LOCAL_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -39,9 +40,11 @@ async function fetchProjectsData({ const parsedProjects = SummaryProjectType.array().safeParse(projects); + if (!parsedProjects.success) { throw new Error(`Failed to parse projects: ${parsedProjects.error}`); } + console.log(parsedProjects.data[0]); const send = { diff --git a/components/Projects/ProjectCard/ProjectCard.tsx b/components/Projects/ProjectCard/ProjectCard.tsx index 2b63681d..cb852b1e 100644 --- a/components/Projects/ProjectCard/ProjectCard.tsx +++ b/components/Projects/ProjectCard/ProjectCard.tsx @@ -38,6 +38,8 @@ export default function ProjectCard({ const t = useTranslations('Projects'); + console.log(owner, name) + return (
From 90d42e9d65a5f4948381fd6ed42aaa6d00f62cc7 Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Fri, 31 May 2024 22:49:19 +0300 Subject: [PATCH 13/14] refactor: Update fetchProjectsData.ts to use production API endpoint --- actions/fetchProjectsData.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/actions/fetchProjectsData.ts b/actions/fetchProjectsData.ts index 35bae52e..a1fcb455 100644 --- a/actions/fetchProjectsData.ts +++ b/actions/fetchProjectsData.ts @@ -13,14 +13,13 @@ export type ProjectPaginationRequest = { }; const PROJECT_API_ENDPOINT = 'https://baas-data-provider.onrender.com/projects'; -const PROJECT_API_LOCAL_ENDPOINT = 'http://localhost:8080/projects'; async function fetchProjectsData({ page = 1, limit = 100, filter = ProjectPaginationFilter.ALL, }: ProjectPaginationRequest): Promise { - const response = await fetch(PROJECT_API_LOCAL_ENDPOINT, { + const response = await fetch(PROJECT_API_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json', From bc250f148c771396d312d76214cd683c9b1fdfa7 Mon Sep 17 00:00:00 2001 From: barel-mishal Date: Fri, 31 May 2024 23:57:35 +0300 Subject: [PATCH 14/14] fix projects photos --- actions/fetchProjectsData.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/actions/fetchProjectsData.ts b/actions/fetchProjectsData.ts index a1fcb455..e7b56cd3 100644 --- a/actions/fetchProjectsData.ts +++ b/actions/fetchProjectsData.ts @@ -13,13 +13,14 @@ export type ProjectPaginationRequest = { }; const PROJECT_API_ENDPOINT = 'https://baas-data-provider.onrender.com/projects'; +const localy = `http://localhost:8080/projects`; async function fetchProjectsData({ page = 1, limit = 100, filter = ProjectPaginationFilter.ALL, }: ProjectPaginationRequest): Promise { - const response = await fetch(PROJECT_API_ENDPOINT, { + const response = await fetch(localy, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -37,13 +38,13 @@ async function fetchProjectsData({ } = await response.json() as IProjectsDataResponse; + const parsedProjects = SummaryProjectType.array().safeParse(projects); if (!parsedProjects.success) { throw new Error(`Failed to parse projects: ${parsedProjects.error}`); } - console.log(parsedProjects.data[0]); const send = {