From 6cd3ea16be64b559dcd186040524239f88793ce3 Mon Sep 17 00:00:00 2001 From: Kathy Cui Date: Thu, 8 Feb 2024 02:58:25 -0600 Subject: [PATCH 1/3] add .env for api access --- .env | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..97b70c6 --- /dev/null +++ b/.env @@ -0,0 +1,19 @@ +NEXT_PUBLIC_SERVER_URL = https://emerging-coders-website-api.onrender.com/contact +NEXT_PUBLIC_SUPABASE_URL = https://ltdsipoulfhkrveuchex.supabase.co/ +NEXT_PUBLIC_SUPABASE_API_KEY = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imx0ZHNpcG91bGZoa3J2ZXVjaGV4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTIzMjIzNjgsImV4cCI6MjAwNzg5ODM2OH0.KTrqdqO_loCS-BlIWdm8UY_khIRPHYJeWkxLoNHD0Sg + +# make new next public swe tracker url for using simplify repo instead +# - access in codebase by changing in fetchREADME line 24 +# postman app (research) +# - testing, only GET for our website + +# SimplifyJobs Repo +NEW_NEXT_PUBLIC_SWE_TRACKER_URL = https://api.github.com/repos/SimplifyJobs/Summer2024-Internships/contents/README.md + +NEXT_PUBLIC_SWE_TRACKER_URL = https://api.github.com/repos/AlanChen4/Summer-2024-SWE-Internships/contents/README.md +NEXT_PUBLIC_UNDERCLASSMEN_OPPORTUNITIES_URL = https://api.github.com/repos/codicate/underclassmen-internships/contents/README.md%60 + +GOOGLE_FORM_API_LINK = https://docs.google.com/forms/d/e/1FAIpQLSfJF60gFsGB3qwSpj8QjleByq9g8uHgyVZhwAM246WBse_bSw/formResponse +GOOGLE_FORM_EMAIL_FIELD = entry.1608977278 +GOOGLE_FORM_SUBJECT_FIELD = entry.1052446519 +GOOGLE_FORM_MESSAGE_FIELD = entry.1418903068 \ No newline at end of file From 3543f2108542dbcb699573827174eaf53ec430ab Mon Sep 17 00:00:00 2001 From: Kathy Cui Date: Thu, 8 Feb 2024 03:04:24 -0600 Subject: [PATCH 2/3] Delete .env --- .env | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 97b70c6..0000000 --- a/.env +++ /dev/null @@ -1,19 +0,0 @@ -NEXT_PUBLIC_SERVER_URL = https://emerging-coders-website-api.onrender.com/contact -NEXT_PUBLIC_SUPABASE_URL = https://ltdsipoulfhkrveuchex.supabase.co/ -NEXT_PUBLIC_SUPABASE_API_KEY = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imx0ZHNpcG91bGZoa3J2ZXVjaGV4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTIzMjIzNjgsImV4cCI6MjAwNzg5ODM2OH0.KTrqdqO_loCS-BlIWdm8UY_khIRPHYJeWkxLoNHD0Sg - -# make new next public swe tracker url for using simplify repo instead -# - access in codebase by changing in fetchREADME line 24 -# postman app (research) -# - testing, only GET for our website - -# SimplifyJobs Repo -NEW_NEXT_PUBLIC_SWE_TRACKER_URL = https://api.github.com/repos/SimplifyJobs/Summer2024-Internships/contents/README.md - -NEXT_PUBLIC_SWE_TRACKER_URL = https://api.github.com/repos/AlanChen4/Summer-2024-SWE-Internships/contents/README.md -NEXT_PUBLIC_UNDERCLASSMEN_OPPORTUNITIES_URL = https://api.github.com/repos/codicate/underclassmen-internships/contents/README.md%60 - -GOOGLE_FORM_API_LINK = https://docs.google.com/forms/d/e/1FAIpQLSfJF60gFsGB3qwSpj8QjleByq9g8uHgyVZhwAM246WBse_bSw/formResponse -GOOGLE_FORM_EMAIL_FIELD = entry.1608977278 -GOOGLE_FORM_SUBJECT_FIELD = entry.1052446519 -GOOGLE_FORM_MESSAGE_FIELD = entry.1418903068 \ No newline at end of file From e139c422178e858b48d79a4985e90ef2332aa38c Mon Sep 17 00:00:00 2001 From: katcui Date: Thu, 8 Feb 2024 16:09:33 -0600 Subject: [PATCH 3/3] non-working swe-opp changes --- .../SWEOpportunitiesComponent.jsx | 94 +++++++++++++------ 1 file changed, 65 insertions(+), 29 deletions(-) diff --git a/src/app/Components/SWEOpportunitiesComponent/SWEOpportunitiesComponent.jsx b/src/app/Components/SWEOpportunitiesComponent/SWEOpportunitiesComponent.jsx index 22587f6..d9e7ba1 100644 --- a/src/app/Components/SWEOpportunitiesComponent/SWEOpportunitiesComponent.jsx +++ b/src/app/Components/SWEOpportunitiesComponent/SWEOpportunitiesComponent.jsx @@ -3,6 +3,7 @@ import axios from "axios"; import { useState, useEffect, useMemo } from "react"; import { Progress, Tab } from "@nextui-org/react"; import { Table as NextTable, TableHeader, TableColumn, TableBody, TableRow, TableCell, Pagination, } from "@nextui-org/react"; +import { Cottage } from "@mui/icons-material"; export default function OpportunitiesComponent() { @@ -21,7 +22,8 @@ export default function OpportunitiesComponent() { // Fetch README.md file from SWE Tracker const fetchREADME = async () => { - const readmeURL = process.env.NEXT_PUBLIC_SWE_TRACKER_URL; + // change "next pub.." to new named api + const readmeURL = process.env.NEW_NEXT_PUBLIC_SWE_TRACKER_URL; try { const response = await axios.get(readmeURL); @@ -33,7 +35,7 @@ export default function OpportunitiesComponent() { const content = await readme.content; const decodedContent = atob(content); setReadmeData(decodedContent); - decodeREADME(decodedContent); + decodeREADME(decodedContent); // Fetch error occurs in decodeREADME } catch (error) { console.log("Error fetching README.md file: ", error); setFetchingError(true); @@ -42,31 +44,61 @@ export default function OpportunitiesComponent() { // The README is encoded in base64 so this function decodes it and parses it into a list of jobs const decodeREADME = async (content) => { - // regex to parse the README.md file into a list of jobs - const regex = /\| ([^\|]+) \| ([^\|]+) \| \[([^\]]+)\]\(([^)]+)\) \| ([^\|]+) \| ([^\|]+) \|\n/g; + // initial regex to parse the README.md file into a list of jobs + // const regex = /\| ([^\|]+) \| ([^\|]+) \| \[([^\]]+)\]\(([^)]+)\) \| ([^\|]+) \| ([^\|]+) \|\n/g; + + // regex for company name exists + const regex1 = /\| \*\*\[([^\]]+)\]\(([^)]+)\)\*\* \| ([^\|]+) \| ([^\|]+) \| [^<\/a> [^<\/a> \| ([^\|]+) \|\n/g; + + // regex for '↳': ↳, role, location, applylink, simplifylink, date posted + const regex2 = /\| ([^\|]+) \| ([^\|]+) \| ([^\|]+) \| [^<\/a> [^<\/a> \| ([^\|]+) \|\n/g; + let match; const jobList = []; - while ((match = regex.exec(content))) { - const company = match[1].trim(); - const investors = match[2].trim(); - const title = match[3].trim(); - const link = match[4].trim(); - const status = match[5].trim(); - const addedOn = match[6].trim(); - jobList.push({ - company, - investors, - title, - link, - status, - addedOn, - }); - } + + // + while ((match = regex1.exec(content)||(match = regex2.exec(content)))) { + if ((match = regex1.exec(content))) { + const companyLinkText = match[1].trim(); // Extract company link text + const companyLinkUrl = match[2].trim(); // Extract company link URL + const role = match[3].trim(); // Extract role + const location = match[4].trim(); // Extract location + const applyLink = match[5].trim(); // Extract application link URL + const simplifyLink = match[6].trim(); // Extract Simplify link URL + const datePosted = match[7].trim(); // Extract date posted + + jobList.push({ + company: { text: companyLinkText, url: companyLinkUrl }, // Storing company link text and URL in an object + role, + location, + application: { apply: applyLink, url: simplifyLink }, // Storing application link text and URL in an object + datePosted + }); + } else { + match = regex2.exec(content) + const companyLinkText = match[1].trim(); // Extract company link text + const role = match[2].trim(); // Extract role + const location = match[3].trim(); // Extract location + const applyLink = match[4].trim(); // Extract application link URL + const simplifyLink = match[5].trim(); // Extract simplify link URL + const datePosted = match[6].trim(); // Extract date posted + + jobList.push({ + company: { text: companyLinkText, url: null}, // Storing company link text and URL in an object + role, + location, + application: { apply: applyLink, simplify: simplifyLink }, // Storing application link text and URL in an object + datePosted + }); + }; + }; const jobsListLength = await jobList.length; setPages(Math.ceil(jobsListLength / rowsPerPage)) setJobsList(jobList); setIsFetching(false); }; + + const handleSearch = (event) => { // changing the value of search @@ -81,8 +113,8 @@ export default function OpportunitiesComponent() { } return jobsList.filter((job) => { return ( - job.title.toLowerCase().includes(lowerSearch) || - job.company.toLowerCase().includes(lowerSearch) + job.role.toLowerCase().includes(lowerSearch) || + job.company.text.toLowerCase().includes(lowerSearch) // may be an issue because company names as arrows won't show up ); }); }, [jobsList, search]); @@ -179,17 +211,21 @@ export default function OpportunitiesComponent() { > COMPANY - TITLE - LINK - ADDED ON + ROLE + LOCATION + APPLICATION + SIMPLIFY + DATE POSTED {filteredJobs.slice((page - 1) * rowsPerPage, page * rowsPerPage).map((job, index) => ( - {job.company} - {job.title} - Apply - {job.addedOn} + {job.company.text} + {job.role} + {job.location} + {'Apply Here'} + {'Apply through Simplify'} + {job.datePosted} ))}