Skip to content

Commit

Permalink
make cover letter
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdavis committed Mar 7, 2024
1 parent 756a344 commit ddb4d9b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
8 changes: 3 additions & 5 deletions apps/registry/pages/api/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,16 @@ export default async function handler(req, res) {
);
}

const { data: documents, error } = await supabase.rpc('match_jobs_v5', {
const { data: documents } = await supabase.rpc('match_jobs_v5', {
query_embedding: embedding,
match_threshold: 0.18, // Choose an appropriate threshold for your data
match_count: 20, // Choose the number of matches
});
console.log({ documents, error });
const jobIds = documents ? documents.map((doc) => doc.id) : [];

// return documents created before two months ago
const jobIds = documents ? documents.map((doc) => doc.id) : [];

const { data: jobs } = await supabase.from('jobs').select().in('id', jobIds);
console.log({ jobs });

const filteredJobs = jobs.filter(
(job) =>
new Date(job.created_at) > new Date(Date.now() - 60 * 24 * 60 * 60 * 1000)
Expand Down
38 changes: 36 additions & 2 deletions apps/registry/pages/jobs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { useRouter } from 'next/router';
import Router, { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import styled from 'styled-components';
import Layout from '../src/ui/Layout';
Expand Down Expand Up @@ -60,6 +60,31 @@ export default function Jobs() {
fetchData();
}
}, [username, submitting]);
const makeCoverletter = async (job) => {
const gptJob = JSON.parse(job.gpt_content);
localStorage.setItem(
`job-${job.id}`,
`
${gptJob.title}
${gptJob.company}
${gptJob.description}
Skills:
${gptJob.skills?.map((skill) => skill.name).join(', ')}
Skill Keywords:
${gptJob.skills?.map((skill) => skill.keywords?.join(', ')).join(', ')}
Responsibilities:
${gptJob.responsibilities?.join(', ')}
`
);
Router.push(`/${username}/letter?job=${job.id}`);
};

const handleGenerate = () => {
setSubmitting(true);
Expand All @@ -86,7 +111,6 @@ export default function Jobs() {
{jobs &&
jobs.map((job) => {
const fullJob = JSON.parse(job.gpt_content);
console.log({ fullJob });
return (
<Message key={job.uuid}>
<br />
Expand Down Expand Up @@ -126,7 +150,17 @@ export default function Jobs() {
<Link href={job.url}>Source</Link>
<br />
<br />
<Button
onClick={() => {
makeCoverletter(job);
}}
>
Make Cover Letter
</Button>
<br />
<br />
<hr />
<br />
</Message>
);
})}
Expand Down
7 changes: 6 additions & 1 deletion apps/registry/pages/letter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ export default function Letter() {
const router = useRouter();
const parts = router.asPath.split('/');
const username = parts[1];
// get query param
const { job } = router.query;
console.log({ job });
const [submitting, setSubmitting] = useState(false);
const [jobDescription, setJobDescription] = useState(
typeof window !== 'undefined'
? window?.localStorage?.getItem('jobDescription')
? job
? window.localStorage.getItem(`job-${job}`)
: window?.localStorage?.getItem('jobDescription')
: ''
);

Expand Down
1 change: 0 additions & 1 deletion apps/registry/src/ui/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const Button = styled.button`
&:hover {
background: #ce2424;
border: 2px solid #ce2424;
color: #fff;
-webkit-transition: all 0.25s;
transition: all 0.25s;
Expand Down
1 change: 0 additions & 1 deletion apps/registry/src/ui/NavLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const NavLink = ({ href, children }) => {
const path = asPath.split('/')[2];
const slugPath = href.split('/')[2];
const ariaCurrent = slugPath === path ? 'page' : undefined;
console.log({ href, path, ariaCurrent });
return (
<Link href={href}>
<LinkElement aria-current={ariaCurrent}>{children}</LinkElement>
Expand Down

0 comments on commit ddb4d9b

Please sign in to comment.