8000 feat: career page user profile with api by JasonNotJson · Pull Request #490 · wasedatime/wasedatime-web · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: career page user profile with api #490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 13, 2023
Merged
120 changes: 108 additions & 12 deletions apps/career/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { useEffect, useContext } from "react"
import React, { useEffect, useState } from "react"
import { HashRouter, Routes, Route } from "react-router-dom"
import { ThemeContext } from "@app/utils/theme-context"
import Joblist from "@app/components/joblist/Joblist"
import Jobdetail from "@app/components/jobdetail/Jobdetail"
import { useTranslation } from "react-i18next"
import HeaderWithModal from "@app/components/common/HeaderWithModal"
import Header from "@app/components/common/Header"
import { jobData as job } from "./Data/JobData"
import JobPage from "@app/components/JobPage"

type Props = {}
import type UserProfile from "./types/userProfile"
import type CareerComponentProps from "./types/careerComponentProps"
import API from "@aws-amplify/api"
import { getIdToken } from "wasedatime-ui"

const App = () => {
return (
Expand All @@ -21,18 +21,107 @@ const App = () => {
)
}

const PageRoutes = () => {
const PageRoutes = ({
jobData,
profile,
setProfile,
isRegistered,
}: CareerComponentProps) => {
return (
<Routes>
<Route element={<JobPage />} path="/" />
<Route element={<Jobdetail />} path="/:jobId" />
<Route
element={
<Joblist
jobData={jobData}
profile={profile}
setProfile={setProfile}
isRegistered={isRegistered}
/>
}
path="/"
/>
<Route
element={
<Jobdetail
jobData={jobData}
profile={profile}
setProfile={setProfile}
isRegistered={isRegistered}
/>
}
path="/:jobId"
10000 />
</Routes>
)
}

const InnerApp = (props: Props) => {
const InnerApp = () => {
const { t, i18n } = useTranslation()
const { theme, setTheme } = React.useContext(ThemeContext)
const [isRegistered, setIsRegistered] = useState(false)
const [jobData, setJobData] = useState([])

const [profile, setProfile] = useState<UserProfile>({
name: "",
school: "",
email: "",
year: "",
class_of: "",
languages: [
{ language: "", level: "" },
{ language: "", level: "" },
],
interests: [],
})

const fetchUserProfile = async () => {
const idToken = await getIdToken()

try {
const res = await API.get("wasedatime-dev", "/profile", {
headers: {
"Content-Type": "application/json",
Authorization: idToken,
},
response: true,
})

const data = res.data.data

if (data) {
setProfile(data)
setIsRegistered(true)
} else {
setIsRegistered(false)
}
} catch (error) {
console.error(error)
}
}

const fetchCareer = async () => {
const idToken = await getIdToken()

try {
const res = await API.get("wasedatime-dev", "/career?type=internship", {
headers: {
"Content-Type": "application/json",
Authorization: idToken,
},
response: true,
})
const data = res.data.data.Items
setJobData(data)
localStorage.setItem("jobs", JSON.stringify(data))
} catch (error) {
console.error(error)
}
}

useEffect(() => {
fetchUserProfile()
fetchCareer()
}, [])

return (
<>
Expand All @@ -49,10 +138,17 @@ const InnerApp = (props: Props) => {
changeLang={(lng) => i18n.changeLanguage(lng)}
/>
</div>
<div className="container mx-auto h-[calc(100vh-127px)] overflow-y-auto px-2">
{/* md:w-3/5 */}
<div className="h-[calc(100vh-127px)] overflow-y-auto lg:h-full">
<div className="container mx-auto px-2">
{/* md:w-3/5 */}

<PageRoutes />
<PageRoutes
jobData={jobData}
profile={profile}
setProfile={setProfile}
isRegistered={isRegistered}
/>
</div>
</div>
</>
)
Expand Down
91 changes: 0 additions & 91 deletions apps/career/src/Data/JobData.tsx

This file was deleted.

Binary file added apps/career/src/assets/syllabus-icons/art.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/art_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/ase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/ase_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/cie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/cie_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/cjl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/cjl_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/cms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/cms_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/cse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/cse_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/edu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/edu_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/ehum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/ehum_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/fse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/fse_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/g_ase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/g_cse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/g_e.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/g_e_jp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/g_edu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/career/src/assets/syllabus-icons/g_fse.png
Binary file added apps/career/src/assets/syllabus-icons/g_hum.png
Binary file added apps/career/src/assets/syllabus-icons/g_ips.png
Binary file added apps/career/src/assets/syllabus-icons/g_its.png
Binary file added apps/career/src/assets/syllabus-icons/g_las.png
Binary file added apps/career/src/assets/syllabus-icons/g_law.png
Binary file added apps/career/src/assets/syllabus-icons/g_ps.png
Binary file added apps/career/src/assets/syllabus-icons/g_ps_jp.png
Binary file added apps/career/src/assets/syllabus-icons/g_sa.png
Binary file added apps/career/src/assets/syllabus-icons/g_sa_jp.png
Binary file added apps/career/src/assets/syllabus-icons/g_saps.png
Binary file added apps/career/src/assets/syllabus-icons/g_sc.png
Binary file added apps/career/src/assets/syllabus-icons/g_seee.png
Binary file added apps/career/src/assets/syllabus-icons/g_siccs.png
Binary file added apps/career/src/assets/syllabus-icons/g_sjal.png
Binary file added apps/career/src/assets/syllabus-icons/g_sps.png
Binary file added apps/career/src/assets/syllabus-icons/g_sss.png
Binary file added apps/career/src/assets/syllabus-icons/g_wbs.png
Binary file added apps/career/src/assets/syllabus-icons/g_wls.png
Binary file added apps/career/src/assets/syllabus-icons/gec.png
Binary file added apps/career/src/assets/syllabus-icons/gec_jp.png
< F438 div class="load-diff-retry text-center p-1" data-show-on-error hidden> Oops, something went wrong.
Binary file added apps/career/src/assets/syllabus-icons/hss.png
Binary file added apps/career/src/assets/syllabus-icons/hss_jp.png
Binary file added apps/career/src/assets/syllabus-icons/hum.png
Binary file added apps/career/src/assets/syllabus-icons/hum_jp.png
Binary file added apps/career/src/assets/syllabus-icons/law.png
Binary file added apps/career/src/assets/syllabus-icons/law_jp.png
Binary file added apps/career/src/assets/syllabus-icons/pse.png
Binary file added apps/career/src/assets/syllabus-icons/sils.png
Binary file added apps/career/src/assets/syllabus-icons/sils_jp.png
Binary file added apps/career/src/assets/syllabus-icons/soc.png
Binary file added apps/career/src/assets/syllabus-icons/soc_jp.png
Binary file added apps/career/src/assets/syllabus-icons/sps.png
Binary file added apps/career/src/assets/syllabus-icons/sps_jp.png
Binary file added apps/career/src/assets/syllabus-icons/sss.png
Binary file added apps/career/src/assets/syllabus-icons/sss_jp.png
7 changes: 0 additions & 7 deletions apps/career/src/components/DescriptionPage.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions apps/career/src/components/JobPage.tsx

This file was deleted.

10 changes: 2 additions & 8 deletions apps/career/src/components/common/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import JobProps from "@app/types/job"
import React from "react"
import { useLocation, Link } from "react-router-dom"

type props = {
job: {
jobID: string
title: string
}
}

const Breadcrumbs = ({ job }: props) => {
const Breadcrumbs = ({ job }: { job: JobProps }) => {
const location = useLocation()
const pathnames = location.pathname.split("/").filter((x) => x)

Expand Down
52 changes: 52 additions & 0 deletions apps/career/src/components/common/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from "react"

type DropdownProps = {
name: string
value: string | string[]
handleChange: (event: React.ChangeEvent<HTMLSelectElement>) => void
options: Array<{ label: string; value: string | number }>
placeholder: string
multiple?: boolean
styles?: string
}

const Dropdown: React.FC<DropdownProps> = ({
name,
value,
handleChange,
options,
placeholder,
styles = "w-full",
multiple = false,
}) => {
const handleMultipleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const selectedOptions = Array.from(
e.target.selectedOptions,
(option) => option.value
)
handleChange({ target: { name: e.target.name, value: selectedOptions } })
}
const formatValueForDisplay = (selectedValues: any | "") => {
return Array.isArray(selectedValues)
? selectedValues.join(", ")
: selectedValues
}
return (
<select
name={name}
value={multiple ? value : formatValueForDisplay(value)}
? handleMultipleChange : handleChange}
multiple={multiple}
className={`${styles} standard-style rounded border p-2`}
>
{!multiple && <option value="">{placeholder}</option>}
{options.map((option, index) => (
<option key={index} value={option.value}>
{option.label}
</option>
))}
</select>
)
}

export default Dropdown
27 changes: 27 additions & 0 deletions apps/career/src/components/common/IntersestGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react"

const InterestGrid = ({ options, selectedInterests, onInterestChange }) => {
const handleInterestClick = (interest) => {
onInterestChange(interest)
}

return (
<div className="standard-style relative grid grid-cols-6 items-center justify-items-center gap-4 border-b p-4">
{options.map((option) => (
<button
key={option.value}
className={`mb-2 inline-block w-24 overflow-hidden rounded-full px-2 py-1 font-sans ${
selectedInterests.includes(option.value)
? "bg-light-card3 dark:bg-dark-card2" // Selected style
: "bg-light-card2 dark:bg-dark-card1" // Unselected style
}`}
=> handleInterestClick(option.value)}
>
<div>{option.label}</div>
</button>
))}
</div>
)
}

export default InterestGrid
Loading
0