From 3825f1d72aa9cabbf79567c5c02aabc76bdfd3d4 Mon Sep 17 00:00:00 2001 From: Jim Macur Date: Mon, 6 Jan 2025 14:18:39 -0700 Subject: [PATCH 1/7] feat/add dynamic contacts for companies --- src/components/companies/CompanyShow.tsx | 50 +++++++++++++++--------- src/components/contacts/Contacts.tsx | 14 +++---- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/components/companies/CompanyShow.tsx b/src/components/companies/CompanyShow.tsx index d493883..5e8ccf9 100644 --- a/src/components/companies/CompanyShow.tsx +++ b/src/components/companies/CompanyShow.tsx @@ -3,6 +3,19 @@ import { useParams, Link } from "react-router-dom"; import { getACompany } from "../../trackerApiCalls"; import { useUserLoggedContext } from '../../context/UserLoggedContext'; +interface ContactData { + id: string; + type: string; + attributes: { + first_name: string; + last_name: string; + email: string; + phone_number: string; + notes: string; + user_id: number; + } +} + interface CompanyData { company: { data: { @@ -17,15 +30,11 @@ interface CompanyData { } } }, - contacts: any; // Update this when you want to use the contacts data + contacts: { + data: ContactData[]; + } } -const mockContacts = [ - { id: 1, name: "John Doe", userId: 101 }, - { id: 2, name: "Jane Smith", userId: 102 }, - { id: 3, name: "Alice Johnson", userId: 103 }, -]; - function CompanyShow() { const { id } = useParams<{ id: string }>(); const { token, userData} = useUserLoggedContext(); @@ -69,6 +78,7 @@ function CompanyShow() { } const companyAttributes = companyData.company.data.attributes; + const companyContacts = companyData.contacts.data; return (
@@ -109,17 +119,21 @@ function CompanyShow() { {/* Contacts Section */}

Contacts

-
- {mockContacts.map((contact) => ( - - {contact.name} - - ))} -
+ {companyContacts.length > 0 ? ( +
+ {companyContacts.map((contact) => ( + + {contact.attributes.first_name} {contact.attributes.last_name} + + ))} +
+ ) : ( +

No contacts found for this company

+ )}
diff --git a/src/components/contacts/Contacts.tsx b/src/components/contacts/Contacts.tsx index 6be5e29..3ab4962 100644 --- a/src/components/contacts/Contacts.tsx +++ b/src/components/contacts/Contacts.tsx @@ -100,13 +100,13 @@ function Contacts( {userData}: UserInformationProps ) { const contactData = contacts.map(data => { const companyName = data.attributes.company?.name || "N/A"; return ( - - {data.attributes.first_name} {data.attributes.last_name} - - {companyName} - - {data.attributes.notes} - + + {data.attributes.first_name} {data.attributes.last_name} + + {companyName} + + {data.attributes.notes} + ) }); From 454a5e314a1e279312325fdc6b2eb6517117df5b Mon Sep 17 00:00:00 2001 From: Jim Macur Date: Mon, 6 Jan 2025 14:56:08 -0700 Subject: [PATCH 2/7] feat/add dynamic application status --- src/Interfaces.tsx | 13 ++++++++++ .../JobApplications/JobApplications.tsx | 14 +---------- src/components/companies/Companies.tsx | 25 ++++++++++++++++--- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/Interfaces.tsx b/src/Interfaces.tsx index 644bc89..b9fe4d4 100644 --- a/src/Interfaces.tsx +++ b/src/Interfaces.tsx @@ -32,4 +32,17 @@ export interface Company { id: number; type: string; attributes: CompanyAttributes; +} + +export interface JobApplication { + id: string; + position_title: string; + date_applied: string; + status: number; + notes: string; + job_description: string; + application_url: string; + contact_information: string; + company_id: number; + company_name?: string; } \ No newline at end of file diff --git a/src/components/JobApplications/JobApplications.tsx b/src/components/JobApplications/JobApplications.tsx index aa9fe41..a3ce4e8 100644 --- a/src/components/JobApplications/JobApplications.tsx +++ b/src/components/JobApplications/JobApplications.tsx @@ -3,21 +3,9 @@ import { Link } from 'react-router-dom'; import { fetchApplicationsData } from '../../apiCalls'; import ClipLoader from "react-spinners/ClipLoader"; import { useUserLoggedContext } from '../../context/UserLoggedContext'; +import { JobApplication } from '../../Interfaces'; import useSWR from 'swr'; -interface JobApplication { - id: string; - position_title: string; - date_applied: string; - status: number; - notes: string; - job_description: string; - application_url: string; - contact_information: string; - company_id: number; - company_name?: string; -} - const statusMap: { [key: number]: string } = { 1: 'Submitted', 2: 'Interviewing', diff --git a/src/components/companies/Companies.tsx b/src/components/companies/Companies.tsx index 4e20da6..164c4f6 100644 --- a/src/components/companies/Companies.tsx +++ b/src/components/companies/Companies.tsx @@ -1,12 +1,21 @@ import { useEffect, useState } from "react" import { Link, useNavigate } from "react-router-dom"; -import { Company } from "../../Interfaces"; +import { Company, JobApplication } from "../../Interfaces"; import { useUserLoggedContext } from "../../context/UserLoggedContext"; import { fetchCompanies } from "../../trackerApiCalls"; +import { fetchApplicationsData } from "../../apiCalls"; +const statusMap: { [key: number]: string } = { + 1: "Submitted", + 2: "Interviewing", + 3: "Offer", + 4: "Rejected", + 5: "Phone Screen", +}; function Companies() { const [companies, setCompanies] = useState([]); + const [applications, setApplications] = useState>({}); const [searchTerm, setSearchTerm] = useState(""); const [filteredCompanies, setFilteredCompanies] = useState([]); const [isLoading, setIsLoading] = useState(true); @@ -18,8 +27,14 @@ function Companies() { const getCompanies = async () => { try { const companies = await fetchCompanies(userData.user.data.id, token!); - console.log("fetched companies", companies) + const fetchedApplications = await fetchApplicationsData(userData.user.data.id, token!); + + const applicationStatusMap: Record = {}; + fetchedApplications.forEach((app: JobApplication) => { + applicationStatusMap[app.company_id] = app.status; + }); setCompanies(companies); + setApplications(applicationStatusMap); setFilteredCompanies(companies); } catch (error) { console.error("Error fetching companies:", error); @@ -82,7 +97,11 @@ function Companies() { onClick={() => navigate(`/companies/${company.id}/contacts`)} > {company.attributes.name} - Not Applied Yet + + {applications[company.id] + ? statusMap[applications[company.id]] + : "Not Applied Yet"} + {company.attributes.notes} ))} From 697f4644466998c0a812776a1f9b773ee7d68a00 Mon Sep 17 00:00:00 2001 From: Jim Macur Date: Mon, 6 Jan 2025 15:03:59 -0700 Subject: [PATCH 3/7] feat/add placeholders to all fields in new company and remove required from all but company name --- src/components/companies/NewCompany.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/companies/NewCompany.tsx b/src/components/companies/NewCompany.tsx index 84fdbeb..c01fe8d 100644 --- a/src/components/companies/NewCompany.tsx +++ b/src/components/companies/NewCompany.tsx @@ -42,7 +42,6 @@ function NewCompany() { return; } - // Check for duplicate company name const isDuplicate = existingCompanies.some( (company) => company.attributes.name.toLowerCase() === name.trim().toLowerCase() ); @@ -99,6 +98,7 @@ function NewCompany() { type="text" id="companyName" value={name} + placeholder="Company Name" onChange={(e) => setName(e.target.value)} className="p-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" required @@ -112,6 +112,7 @@ function NewCompany() { type="text" id="website" value={website} + placeholder="https://example.com" onChange={(e) => setWebsite(e.target.value)} className="p-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" /> @@ -122,9 +123,9 @@ function NewCompany() { type="text" id="streetAddress" value={streetAddress} + placeholder="123 Main St" onChange={(e) => setStreetAddress(e.target.value)} className="p-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" - required />
@@ -133,9 +134,9 @@ function NewCompany() { type="text" id="city" value={city} + placeholder="City" onChange={(e) => setCity(e.target.value)} className="p-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" - required />
@@ -144,7 +145,6 @@ function NewCompany() { value={state} onChange={(e) => setState(e.target.value)} className="p-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" - required > @@ -205,15 +205,16 @@ function NewCompany() { type="text" id="zipCode" value={zipCode} + placeholder="12345" onChange={(e) => setZipCode(e.target.value)} className="p-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" - required />