8000 feat: career post application and agreement modal by JasonNotJson · Pull Request #494 · wasedatime/wasedatime-web · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: career post application and agreement modal #494

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 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/career/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ const InnerApp = () => {
const fetchCareer = async () => {
const idToken = await getIdToken()

console.log("Triggered!")

try {
const res = await API.get("wasedatime-dev", "/career?type=internship", {
headers: {
Expand Down
104 changes: 104 additions & 0 deletions apps/career/src/components/common/AgreeModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import React from "react"
import Modal from "./Modal"
import postApplication from "@app/utils/postApplication"
import JobProps from "@app/types/job"
import UserProfile from "@app/types/userProfile"
import { getIdToken } from "wasedatime-ui"

type AgreeModalProps = {
onDisagree: () => void
onAgree: () => void
job: JobProps
profile: UserProfile
}

const AgreeModal: React.FC<AgreeModalProps> = ({
onDisagree,
onAgree,
job,
profile,
}) => {
const handleAgree = async () => {
try {
const idToken = await getIdToken() // Correctly awaiting the Promise
if (idToken) {
await postApplication(profile, job, idToken)
onAgree()
} else {
console.error("NO ID TOKEN")
}
} catch (error) {
console.error("Error submitting application:", error)
}
}

return (
<Modal>
<div className="standard-style flex items-center justify-between rounded-t border-b border-solid p-5">
<h3 className="text-3xl font-semibold">Terms and Policy Agreement</h3>
</div>

<div className="standard-style relative flex-auto p-6">
<p className="my-4 text-xl leading-relaxed">
Agreement for Submission of Profile Information
</p>
<p className="text-lg">
By clicking the "Agree" button below, you acknowledge and consent to
the following terms:
</p>
<ul className="list-inside list-disc text-lg">
<li>
The personal and professional information you have provided in your
profile, including but not limited to your name, email address,
professional history, and qualifications, will be shared with the
company associated with the job you are applying for.
</li>
<li>
This information will be used by the company solely for the purpose
of evaluating your job application and considering your suitability
for the position.
</li>
<li>
Your information will be treated in accordance with our Privacy
Policy, which outlines how we collect, use, and protect your
personal data.
</li>
<li>
You affirm that all information provided in your profile is
accurate, current, and complete, and does not violate any laws or
regulations.
</li>
<li>
You understand that providing false or misleading information may
lead to a rejection of your application or, if employed,
disciplinary action, up to and including termination.
</li>
</ul>
<p className="mt-4 text-lg">
Please review your profile information thoroughly before agreeing. By
submitting your application, you give us consent to process and
forward your profile data to the respective company for the current
job application.
</p>
{/* Additional content or legal disclaimers can be included here */}
</div>

<div className="standard-style flex items-center justify-end rounded-b border-t border-solid p-6">
<button
className="background-transparent mr-1 mb-1 px-6 py-2 text-sm font-bold uppercase text-red-500 outline-none hover:-translate-y-1.5 focus:outline-none"
>
>
Disagree
</button>
<button
className="mr-1 mb-1 rounded bg-green-500 px-6 py-3 text-sm font-bold uppercase text-white shadow outline-none hover:-translate-y-1.5 hover:shadow-lg focus:outline-none active:bg-green-600"
>
>
Agree
</button>
</div>
</Modal>
)
}

export default AgreeModal
5 changes: 4 additions & 1 deletion apps/career/src/components/common/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ const Header = ({
<MediaQuery maxWidth={sizes.tablet}>
{(matches: boolean) =>
matches ? (
<div style={logoWrapperStyle} => navigate("/home")}>
<div
style={logoWrapperStyle}
=> (window.location.href = "/home")}
>
<img
src={new URL(logo, import.meta.url).href}
alt="WasedaTime English Small Logo"
Expand Down
15 changes: 9 additions & 6 deletions apps/career/src/components/common/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import React, { useState } from "react";
import React, { useState } from "react"

type Props = {
children: any
}

const Modal = ({ children }: Props) => {
const preventParentClick = (e: React.MouseEvent<HTMLDivElement>) => {
e.preventDefault();
e.preventDefault()
}

return (
<div className="bg-light-bgMain dark:bg-dark-bgMain bg-opacity-70 dark:bg-opacity-50 flex justify-center items-center overflow-x-hidden overflow-y-auto fixed inset-0 z-50 outline-none focus:outline-none cursor-default" >
<div className="relative w-auto my-6 mx-auto max-w-3xl">
<div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none">
<div
className="fixed inset-0 z-50 flex cursor-default items-center justify-center overflow-y-auto overflow-x-hidden bg-light-bgMain bg-opacity-70 outline-none focus:outline-none dark:bg-dark-bgMain dark:bg-opacity-50"
>
>
<div className="relative my-6 mx-auto w-auto max-w-3xl">
<div className="relative flex w-full flex-col rounded-lg border shadow-lg outline-none focus:outline-none dark:border-white">
{children}
</div>
</div>
</div>
)
}

export default Modal;
export default Modal
39 changes: 32 additions & 7 deletions apps/career/src/components/jobdetail/JobContent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
import React from "react"
import React, { useSt 6D47 ate } from "react"
import JobProps from "@app/types/job"
import AgreeModal from "@app/components/common/AgreeModal"
import UserProfile from "@app/types/userProfile"

const JobContent = ({ job }: { job: JobProps }) => {
const JobContent = ({
job,
profile,
}: {
job: JobProps
profile: UserProfile
}) => {
const [isAgreeModalOpen, setIsAgreeModalOpen] = useState(false)

const handleApplyClick = () => {
setIsAgreeModalOpen(true)
}

const handleModalAgree = () => {
setIsAgreeModalOpen(false)
}

const handleModalDisagree = () => {
setIsAgreeModalOpen(false)
}
const jobContentSections = [
{
title: "Job Title",
Expand Down Expand Up @@ -64,17 +85,21 @@ const JobContent = ({ job }: { job: JobProps }) => {
<div className="col-span-4 col-start-9 mt-8 space-y-2 p-6">
<div
className="w-full cursor-pointer rounded-lg border-transparent bg-light-main p-2 text-center text-xl capitalize text-white hover:-translate-y-1.5 hover:bg-light-lighter dark:bg-dark-main dark:hover:bg-dark-lighter"
=> {
if (job && job.apply) {
window.open(job.apply, "_blank")
}
}}
>
>
apply now
</div>
</div>
</div>
</div>
{isAgreeModalOpen && (
<AgreeModal
>
>
job={job}
profile={profile}
/>
)}
</>
)
}
Expand Down
40 changes: 32 additions & 8 deletions apps/career/src/components/jobdetail/JobOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from "react"
import React, { useState } from "react"
import BadgeIcon from "@mui/icons-material/Badge"
import LocationOnIcon from "@mui/icons-material/LocationOn"
import HistoryIcon from "@mui/icons-material/History"
import PaidIcon from "@mui/icons-material/Paid"
import JobProps from "@app/types/job"
import { timeFormatter } from "@app/utils/timeFormatter"
import AgreeModal from "@app/components/common/AgreeModal"
import UserProfile from "@app/types/userProfile"

interface Details {
key: keyof JobProps
Expand Down Expand Up @@ -55,8 +57,26 @@ const jobDetailStructure: Details[] = [
},
]

const JobOverview = ({ job }: { job: JobProps }) => {
// If job doesn't exist, you can handle the null case by rendering something else
const JobOverview = ({
job,
profile,
}: {
job: JobProps
profile: UserProfile
}) => {
const [isAgreeModalOpen, setIsAgreeModalOpen] = useState(false)

const handleApplyClick = () => {
setIsAgreeModalOpen(true)
}

const handleModalAgree = () => {
setIsAgreeModalOpen(false)
}

const handleModalDisagree = () => {
setIsAgreeModalOpen(false)
}

return (
<>
Expand Down Expand Up @@ -88,17 +108,21 @@ const JobOverview = ({ job }: { job: JobProps }) => {
<div className="mt-8 space-y-2">
<div
className="w-full cursor-pointer rounded-lg border-transparent bg-light-main p-2 text-center text-xl capitalize text-white hover:-translate-y-1.5 hover:bg-light-lighter dark:bg-dark-main dark:hover:bg-dark-lighter"
=> {
if (job && job.apply) {
window.open(job.apply, "_blank")
}
}}
>
>
apply now
</div>
</div>
</div>
</div>
{isAgreeModalOpen && (
<AgreeModal
>
>
job={job}
profile={profile}
/>
)}
</>
)
}
Expand Down
9 changes: 5 additions & 4 deletions apps/career/src/components/jobdetail/Jobdetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SignInModal } from "wasedatime-ui"
import { useTranslation } from "react-i18next"

const Jobdetail: React.FC<CareerComponentProps> = ({
profile,
jobData,
isRegistered,
}) => {
Expand All @@ -23,7 +24,6 @@ const Jobdetail: React.FC<CareerComponentProps> = ({
job = jobData.find((j) => j.job_id === jobId)
} else {
const storedJobData = localStorage.getItem("jobs")
console.log(storedJobData)
if (storedJobData) {
const parsedJobData = JSON.parse(storedJobData) as JobProps[]
job = parsedJobData.find((j) => j.job_id === jobId)
Expand All @@ -34,7 +34,8 @@ const Jobdetail: React.FC<CareerComponentProps> = ({
return <div>Job not found</div>
}

console.log(jobData)
console.log("Job data state : ", job)
console.log("Profile data state : ", profile)

return (
<>
Expand All @@ -46,10 +47,10 @@ const Jobdetail: React.FC<CareerComponentProps> = ({
{isRegistered ? (
<>
<div className="col-span-12 lg:col-span-3">
<JobOverview job={job} />
<JobOverview job={job} profile={profile} />
</div>
<div className="col-span-12 lg:col-span-6">
<JobContent job={job} />
<JobContent job={job} profile={profile} />
</div>
<div className="col-span-12 lg:col-span-3">
<CompanyOverview job={job} />
Expand Down
2 changes: 1 addition & 1 deletion apps/career/src/components/joblist/JobCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const JobCard: React.FC<JobCardProps> = ({
</div>
{/* Date Posted Section */}
<div className="col-span-12 sm:col-span-2">
<div className="mb-0">
<div className="mb-2 sm:mb-0">
<h2 className="text-2xl font-bold text-light-text1 dark:text-dark-text1">
{formattedTime}
</h2>
Expand Down
2 changes: 1 addition & 1 deletion apps/career/src/components/joblist/Joblist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Joblist: React.FC<CareerComponentProps> = ({
{isLoggedIn ? (
<div className="grid grid-cols-12 gap-y-6 sm:gap-10 sm:gap-y-0">
<div className="col-span-12 sm:col-span-9">
<div className={`mt-14 pt-6`}>
<div className={`mt-14 py-6`}>
{jobData.map((job, index) => (
<JobCard
key={index}
Expand Down
2 changes: 1 addition & 1 deletion apps/career/src/components/joblist/ProfileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const ProfileModal: React.FC<ProfileModalProps> = ({
return (
<div className="fixed inset-0 z-50 h-full w-full overflow-y-auto bg-gray-600 bg-opacity-50">
<div className="flex h-full items-center justify-center">
<div className="standard-style mx-auto max-w-3xl space-y-6 rounded-lg p-6">
<div className="standard-style mx-auto max-w-xl space-y-6 rounded-lg p-6 sm:max-w-3xl">
<h2 className="text-center text-2xl font-bold">Register Profile</h2>
<div className="flex w-full items-center justify-center p-2">
<button
Expand Down
33 changes: 33 additions & 0 deletions apps/career/src/utils/postApplication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import API from "@aws-amplify/api"
import UserProfile from "@app/types/userProfile"
import JobProps from "@app/types/job"

export const postApplication = async (
profileData: UserProfile,
jobData: JobProps,
idToken: string
) => {
const applicationData = {
title: jobData.title,
job_id: jobData.job_id,
company: jobData.company,
email: profileData.email,
name: profileData.name,
agreed: true,
}
try {
const response = await API.post("wasedatime-dev", `/career`, {
body: { data: applicationData },
headers: {
"Content-Type": "application/json",
Authorization: idToken,
},
})

console.log(response)
} catch (error) {
console.error("An error occurred:", error)
}
}

export default postApplication
5 changes: 4 additions & 1 deletion apps/forum/src/components/common/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ const Header = ({
<MediaQuery maxWidth={sizes.tablet}>
{(matches: boolean) =>
matches ? (
<div style={logoWrapperStyle} => navigate("/home")}>
<div
style={logoWrapperStyle}
=> (window.location.href = "/home")}
> 49A1
<img
src={new URL(logo, import.meta.url).href}
alt="WasedaTime English Small Logo"
Expand Down
0