Merge branch 'main' into questions/ui-fixes

pull/514/head
Jeff Sieu 3 years ago
commit 9bdcd31e45

@ -0,0 +1,16 @@
/*
Warnings:
- You are about to drop the column `companyId` on the `OffersAnalysisUnit` table. All the data in the column will be lost.
- Added the required column `analysedOfferId` to the `OffersAnalysisUnit` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "OffersAnalysisUnit" DROP CONSTRAINT "OffersAnalysisUnit_companyId_fkey";
-- AlterTable
ALTER TABLE "OffersAnalysisUnit" DROP COLUMN "companyId",
ADD COLUMN "analysedOfferId" TEXT NOT NULL;
-- AddForeignKey
ALTER TABLE "OffersAnalysisUnit" ADD CONSTRAINT "OffersAnalysisUnit_analysedOfferId_fkey" FOREIGN KEY ("analysedOfferId") REFERENCES "OffersOffer"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

@ -104,7 +104,6 @@ model Company {
questionsQuestionEncounter QuestionsQuestionEncounter[] questionsQuestionEncounter QuestionsQuestionEncounter[]
OffersExperience OffersExperience[] OffersExperience OffersExperience[]
OffersOffer OffersOffer[] OffersOffer OffersOffer[]
OffersAnalysisUnit OffersAnalysisUnit[]
} }
model Country { model Country {
@ -368,6 +367,7 @@ model OffersOffer {
offersAnalysis OffersAnalysis? @relation("HighestOverallOffer") offersAnalysis OffersAnalysis? @relation("HighestOverallOffer")
offersAnalysisUnit OffersAnalysisUnit[] offersAnalysisUnit OffersAnalysisUnit[]
OffersAnalysisUnit OffersAnalysisUnit[] @relation("Analysed Offer")
} }
model OffersIntern { model OffersIntern {
@ -419,8 +419,8 @@ model OffersAnalysis {
model OffersAnalysisUnit { model OffersAnalysisUnit {
id String @id @default(cuid()) id String @id @default(cuid())
company Company @relation(fields: [companyId], references: [id]) analysedOffer OffersOffer @relation("Analysed Offer", fields: [analysedOfferId], references: [id])
companyId String analysedOfferId String
percentile Float percentile Float
noOfSimilarOffers Int noOfSimilarOffers Int

@ -0,0 +1,16 @@
import { emptyOption } from './constants';
export const EducationFieldLabels = [
'Business Analytics',
'Computer Science',
'Data Science and Analytics',
'Information Security',
'Information Systems',
];
export const EducationFieldOptions = [emptyOption].concat(
EducationFieldLabels.map((label) => ({
label,
value: label.replace(/\s+/g, '-').toLowerCase(),
})),
);

@ -0,0 +1,18 @@
import { emptyOption } from './constants';
export const EducationLevelLabels = [
'Bachelor',
'Diploma',
'Masters',
'PhD',
'Professional',
'Secondary',
'Self-taught',
];
export const EducationLevelOptions = [emptyOption].concat(
EducationLevelLabels.map((label) => ({
label,
value: label.replace(/\s+/g, '-').toLowerCase(),
})),
);

@ -0,0 +1,18 @@
import { emptyOption } from './constants';
export const InternshipCycleLabels = [
'Spring',
'Summer',
'Fall',
'Winter',
'Half year',
'Full year',
'Others',
];
export const InternshipCycleOptions = [emptyOption].concat(
InternshipCycleLabels.map((label) => ({
label,
value: label.replace(/\s+/g, '-').toLowerCase(),
})),
);

@ -1,7 +1,7 @@
import clsx from 'clsx'; import clsx from 'clsx';
import { JobType } from '@prisma/client'; import { JobType } from '@prisma/client';
import { JobTypeLabel } from './types'; import { JobTypeLabel } from '~/components/offers/constants';
type Props = Readonly<{ type Props = Readonly<{
onChange: (jobType: JobType) => void; onChange: (jobType: JobType) => void;

@ -0,0 +1,8 @@
const NUM_YEARS = 5;
export const FutureYearsOptions = Array.from({ length: NUM_YEARS }, (_, i) => {
const year = new Date().getFullYear() + i;
return {
label: String(year),
value: year,
};
});

@ -1,78 +1,14 @@
import { EducationBackgroundType } from './types'; export const HOME_URL = '/offers';
export const emptyOption = '----'; export const JobTypeLabel = {
FULLTIME: 'Full-time',
INTERN: 'Internship',
};
export const internshipCycleOptions = [ export const emptyOption = {
{ label: '',
label: 'Summer', value: '',
value: 'Summer', };
},
{
label: 'Winter',
value: 'Winter',
},
{
label: 'Spring',
value: 'Spring',
},
{
label: 'Fall',
value: 'Fall',
},
{
label: 'Full year',
value: 'Full year',
},
];
export const yearOptions = [
{
label: '2021',
value: 2021,
},
{
label: '2022',
value: 2022,
},
{
label: '2023',
value: 2023,
},
{
label: '2024',
value: 2024,
},
];
export const educationLevelOptions = Object.entries(
EducationBackgroundType,
).map(([, value]) => ({
label: value,
value,
}));
export const educationFieldOptions = [
{
label: 'Computer Science',
value: 'Computer Science',
},
{
label: 'Information Security',
value: 'Information Security',
},
{
label: 'Information Systems',
value: 'Information Systems',
},
{
label: 'Business Analytics',
value: 'Business Analytics',
},
{
label: 'Data Science and Analytics',
value: 'Data Science and Analytics',
},
];
export enum FieldError { export enum FieldError {
NON_NEGATIVE_NUMBER = 'Please fill in a non-negative number in this field.', NON_NEGATIVE_NUMBER = 'Please fill in a non-negative number in this field.',

@ -5,6 +5,7 @@ import {
} from '@heroicons/react/20/solid'; } from '@heroicons/react/20/solid';
import { JobType } from '@prisma/client'; import { JobType } from '@prisma/client';
import { JobTypeLabel } from '~/components/offers/constants';
import type { JobTitleType } from '~/components/shared/JobTitles'; import type { JobTitleType } from '~/components/shared/JobTitles';
import { getLabelForJobTitleType } from '~/components/shared/JobTitles'; import { getLabelForJobTitleType } from '~/components/shared/JobTitles';
@ -33,32 +34,33 @@ export default function DashboardProfileCard({
<div className="flex items-end justify-between"> <div className="flex items-end justify-between">
<div className="col-span-1 row-span-3"> <div className="col-span-1 row-span-3">
<h4 className="font-medium"> <h4 className="font-medium">
{getLabelForJobTitleType(title as JobTitleType)} {getLabelForJobTitleType(title as JobTitleType)}{' '}
{jobType && <>({JobTypeLabel[jobType]})</>}
</h4> </h4>
<div className="mt-1 flex flex-col sm:mt-0 sm:flex-row sm:flex-wrap sm:space-x-4"> <div className="mt-1 flex flex-col sm:mt-0 sm:flex-row sm:flex-wrap sm:space-x-4">
{company?.name && ( {company?.name && (
<div className="mt-2 flex items-center text-sm text-gray-500"> <div className="mt-2 flex items-center text-sm text-slate-500">
<BuildingOfficeIcon <BuildingOfficeIcon
aria-hidden="true" aria-hidden="true"
className="mr-1.5 h-5 w-5 flex-shrink-0 text-gray-400" className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400"
/> />
{company.name} {company.name}
</div> </div>
)} )}
{location && ( {location && (
<div className="mt-2 flex items-center text-sm text-gray-500"> <div className="mt-2 flex items-center text-sm text-slate-500">
<MapPinIcon <MapPinIcon
aria-hidden="true" aria-hidden="true"
className="mr-1.5 h-5 w-5 flex-shrink-0 text-gray-400" className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400"
/> />
{location.cityName} {location.cityName}
</div> </div>
)} )}
{level && ( {level && (
<div className="mt-2 flex items-center text-sm text-gray-500"> <div className="mt-2 flex items-center text-sm text-slate-500">
<ArrowTrendingUpIcon <ArrowTrendingUpIcon
aria-hidden="true" aria-hidden="true"
className="mr-1.5 h-5 w-5 flex-shrink-0 text-gray-400" className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400"
/> />
{level} {level}
</div> </div>

@ -2,7 +2,7 @@ import type { StaticImageData } from 'next/image';
import Image from 'next/image'; import Image from 'next/image';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { HOME_URL } from '~/components/offers/types'; import { HOME_URL } from '../constants';
type LeftTextCardProps = Readonly<{ type LeftTextCardProps = Readonly<{
description: string; description: string;

@ -2,7 +2,7 @@ import type { StaticImageData } from 'next/image';
import Image from 'next/image'; import Image from 'next/image';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { HOME_URL } from '~/components/offers/types'; import { HOME_URL } from '../constants';
type RightTextCarddProps = Readonly<{ type RightTextCarddProps = Readonly<{
description: string; description: string;

@ -109,13 +109,13 @@ export default function OfferAnalysis({
return ( return (
<div> <div>
{isError && ( {isError ? (
<p className="m-10 text-center"> <p className="m-10 text-center">
An error occurred while generating profile analysis. An error occurred while generating profile analysis.
</p> </p>
)} ) : isLoading ? (
{isLoading && <Spinner className="m-10" display="block" size="lg" />} <Spinner className="m-10" display="block" size="lg" />
{!isError && !isLoading && ( ) : (
<div> <div>
<Tabs <Tabs
label="Result Navigation" label="Result Navigation"

@ -9,10 +9,11 @@ import { getLabelForJobTitleType } from '~/components/shared/JobTitles';
import { HorizontalDivider } from '~/../../../packages/ui/dist'; import { HorizontalDivider } from '~/../../../packages/ui/dist';
import { convertMoneyToString } from '~/utils/offers/currency'; import { convertMoneyToString } from '~/utils/offers/currency';
import { getCompanyDisplayText } from '~/utils/offers/string';
import { formatDate } from '~/utils/offers/time'; import { formatDate } from '~/utils/offers/time';
import { JobTypeLabel } from '../constants';
import ProfilePhotoHolder from '../profile/ProfilePhotoHolder'; import ProfilePhotoHolder from '../profile/ProfilePhotoHolder';
import { JobTypeLabel } from '../types';
import type { AnalysisOffer } from '~/types/offers'; import type { AnalysisOffer } from '~/types/offers';
@ -32,15 +33,15 @@ export default function OfferProfileCard({
location, location,
title, title,
previousCompanies, previousCompanies,
profileId,
}, },
}: OfferProfileCardProps) { }: OfferProfileCardProps) {
return ( return (
// <a <a
// className="my-5 block rounded-lg bg-white p-4 px-8 shadow-md" className="my-5 block rounded-lg border bg-white p-4 px-8 shadow-md"
// href={`/offers/profile/${id}`} href={`/offers/profile/${profileId}`}
// rel="noreferrer" rel="noreferrer"
// target="_blank"> target="_blank">
<div className="my-5 block rounded-lg bg-white p-4 px-8 shadow-lg">
<div className="flex items-center gap-x-5"> <div className="flex items-center gap-x-5">
<div> <div>
<ProfilePhotoHolder size="sm" /> <ProfilePhotoHolder size="sm" />
@ -69,7 +70,7 @@ export default function OfferProfileCard({
{getLabelForJobTitleType(title as JobTitleType)}{' '} {getLabelForJobTitleType(title as JobTitleType)}{' '}
{`(${JobTypeLabel[jobType]})`} {`(${JobTypeLabel[jobType]})`}
</p> </p>
<p>{`Company: ${company.name}, ${location}`}</p> <p>{`Company: ${getCompanyDisplayText(company.name, location)}`}</p>
{level && <p>Level: {level}</p>} {level && <p>Level: {level}</p>}
</div> </div>
<div className="col-span-1 row-span-3"> <div className="col-span-1 row-span-3">
@ -81,6 +82,6 @@ export default function OfferProfileCard({
</p> </p>
</div> </div>
</div> </div>
</div> </a>
); );
} }

@ -1,5 +1,5 @@
import { signIn, useSession } from 'next-auth/react'; import { signIn, useSession } from 'next-auth/react';
import { useState } from 'react'; import type { UseQueryResult } from 'react-query';
import { DocumentDuplicateIcon } from '@heroicons/react/20/solid'; import { DocumentDuplicateIcon } from '@heroicons/react/20/solid';
import { BookmarkIcon as BookmarkOutlineIcon } from '@heroicons/react/24/outline'; import { BookmarkIcon as BookmarkOutlineIcon } from '@heroicons/react/24/outline';
import { BookmarkIcon as BookmarkSolidIcon } from '@heroicons/react/24/solid'; import { BookmarkIcon as BookmarkSolidIcon } from '@heroicons/react/24/solid';
@ -11,6 +11,7 @@ import { copyProfileLink, getProfileLink } from '~/utils/offers/link';
import { trpc } from '~/utils/trpc'; import { trpc } from '~/utils/trpc';
type OfferProfileSaveProps = Readonly<{ type OfferProfileSaveProps = Readonly<{
isSavedQuery: UseQueryResult<boolean>;
profileId: string; profileId: string;
token?: string; token?: string;
}>; }>;
@ -18,10 +19,10 @@ type OfferProfileSaveProps = Readonly<{
export default function OffersProfileSave({ export default function OffersProfileSave({
profileId, profileId,
token, token,
isSavedQuery: { data: isSaved, isLoading },
}: OfferProfileSaveProps) { }: OfferProfileSaveProps) {
const { showToast } = useToast(); const { showToast } = useToast();
const { event: gaEvent } = useGoogleAnalytics(); const { event: gaEvent } = useGoogleAnalytics();
const [isSaved, setSaved] = useState(false);
const { data: session, status } = useSession(); const { data: session, status } = useSession();
const saveMutation = trpc.useMutation( const saveMutation = trpc.useMutation(
@ -47,15 +48,6 @@ export default function OffersProfileSave({
}, },
); );
const isSavedQuery = trpc.useQuery(
[`offers.profile.isSaved`, { profileId, userId: session?.user?.id }],
{
onSuccess: (res) => {
setSaved(res);
},
},
);
const trpcContext = trpc.useContext(); const trpcContext = trpc.useContext();
const handleSave = () => { const handleSave = () => {
if (status === 'unauthenticated') { if (status === 'unauthenticated') {
@ -93,7 +85,6 @@ export default function OffersProfileSave({
<div className="mt-4 flex gap-4"> <div className="mt-4 flex gap-4">
<div className="grow"> <div className="grow">
<TextInput <TextInput
disabled={true}
isLabelHidden={true} isLabelHidden={true}
label="Edit link" label="Edit link"
value={getProfileLink(profileId, token)} value={getProfileLink(profileId, token)}
@ -126,9 +117,9 @@ export default function OffersProfileSave({
</p> </p>
<div className="mt-6"> <div className="mt-6">
<Button <Button
disabled={isSavedQuery.isLoading || isSaved} disabled={isLoading || isSaved}
icon={isSaved ? BookmarkSolidIcon : BookmarkOutlineIcon} icon={isSaved ? BookmarkSolidIcon : BookmarkOutlineIcon}
isLoading={saveMutation.isLoading || isSavedQuery.isLoading} isLoading={saveMutation.isLoading}
label={isSaved ? 'Added to account' : 'Add to your account'} label={isSaved ? 'Added to account' : 'Add to your account'}
size="sm" size="sm"
variant="secondary" variant="secondary"

@ -28,6 +28,7 @@ export default function OffersSubmissionAnalysis({
allAnalysis={analysis} allAnalysis={analysis}
isError={isError} isError={isError}
isLoading={isLoading} isLoading={isLoading}
isSubmission={true}
/> />
)} )}
</div> </div>

@ -4,11 +4,11 @@ import type { SubmitHandler } from 'react-hook-form';
import { FormProvider, useForm } from 'react-hook-form'; import { FormProvider, useForm } from 'react-hook-form';
import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/20/solid'; import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/20/solid';
import { JobType } from '@prisma/client'; import { JobType } from '@prisma/client';
import { Button } from '@tih/ui'; import { Button, Spinner, useToast } from '@tih/ui';
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
import type { BreadcrumbStep } from '~/components/offers/Breadcrumb'; import type { BreadcrumbStep } from '~/components/offers/Breadcrumbs';
import { Breadcrumbs } from '~/components/offers/Breadcrumb'; import { Breadcrumbs } from '~/components/offers/Breadcrumbs';
import BackgroundForm from '~/components/offers/offersSubmission/submissionForm/BackgroundForm'; import BackgroundForm from '~/components/offers/offersSubmission/submissionForm/BackgroundForm';
import OfferDetailsForm from '~/components/offers/offersSubmission/submissionForm/OfferDetailsForm'; import OfferDetailsForm from '~/components/offers/offersSubmission/submissionForm/OfferDetailsForm';
import type { import type {
@ -102,8 +102,9 @@ export default function OffersSubmissionForm({
token: editToken, token: editToken,
}); });
const [isSubmitted, setIsSubmitted] = useState(false); const [isSubmitted, setIsSubmitted] = useState(false);
const { event: gaEvent } = useGoogleAnalytics();
const { event: gaEvent } = useGoogleAnalytics();
const { showToast } = useToast();
const router = useRouter(); const router = useRouter();
const pageRef = useRef<HTMLDivElement>(null); const pageRef = useRef<HTMLDivElement>(null);
const scrollToTop = () => const scrollToTop = () =>
@ -115,7 +116,7 @@ export default function OffersSubmissionForm({
const { const {
handleSubmit, handleSubmit,
trigger, trigger,
formState: { isSubmitting, isSubmitSuccessful }, formState: { isSubmitting },
} = formMethods; } = formMethods;
const generateAnalysisMutation = trpc.useMutation( const generateAnalysisMutation = trpc.useMutation(
@ -123,6 +124,10 @@ export default function OffersSubmissionForm({
{ {
onError(error) { onError(error) {
console.error(error.message); console.error(error.message);
showToast({
title: 'Error generating analysis.',
variant: 'failure',
});
}, },
onSuccess() { onSuccess() {
router.push( router.push(
@ -132,13 +137,7 @@ export default function OffersSubmissionForm({
}, },
); );
const steps = [ const steps = [<OfferDetailsForm key={0} />, <BackgroundForm key={1} />];
<OfferDetailsForm
key={0}
defaultJobType={initialOfferProfileValues.offers[0].jobType}
/>,
<BackgroundForm key={1} />,
];
const breadcrumbSteps: Array<BreadcrumbStep> = [ const breadcrumbSteps: Array<BreadcrumbStep> = [
{ {
@ -157,14 +156,14 @@ export default function OffersSubmissionForm({
}, },
]; ];
const goToNextStep = async (currStep: number) => { const setStepWithValidation = async (nextStep: number) => {
if (currStep === 0) { if (nextStep === 1) {
const result = await trigger('offers'); const result = await trigger('offers');
if (!result) { if (!result) {
return; return;
} }
} }
setStep(step + 1); setStep(nextStep);
}; };
const mutationpath = const mutationpath =
@ -175,16 +174,30 @@ export default function OffersSubmissionForm({
const createOrUpdateMutation = trpc.useMutation([mutationpath], { const createOrUpdateMutation = trpc.useMutation([mutationpath], {
onError(error) { onError(error) {
console.error(error.message); console.error(error.message);
showToast({
title:
editProfileId && editToken
? 'Error updating offer profile.'
: 'Error creating offer profile.',
variant: 'failure',
});
}, },
onSuccess(data) { onSuccess(data) {
setParams({ profileId: data.id, token: data.token }); setParams({ profileId: data.id, token: data.token });
setIsSubmitted(true); setIsSubmitted(true);
showToast({
title:
editProfileId && editToken
? 'Offer profile updated successfully!'
: 'Offer profile created successfully!',
variant: 'success',
});
}, },
}); });
const onSubmit: SubmitHandler<OffersProfileFormData> = async (data) => { const onSubmit: SubmitHandler<OffersProfileFormData> = async (data) => {
const result = await trigger(); const result = await trigger();
if (!result || isSubmitting || isSubmitSuccessful) { if (!result || isSubmitting || createOrUpdateMutation.isLoading) {
return; return;
} }
@ -263,14 +276,16 @@ export default function OffersSubmissionForm({
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
return ( return generateAnalysisMutation.isLoading ? (
<Spinner className="m-10" display="block" size="lg" />
) : (
<div ref={pageRef} className="w-full"> <div ref={pageRef} className="w-full">
<div className="flex justify-center"> <div className="flex justify-center">
<div className="block w-full max-w-screen-md overflow-hidden rounded-lg sm:shadow-lg md:my-10"> <div className="block w-full max-w-screen-md overflow-hidden rounded-lg sm:shadow-lg md:my-10">
<div className="flex justify-center bg-slate-100 px-4 py-4 sm:px-6 lg:px-8"> <div className="flex justify-center bg-slate-100 px-4 py-4 sm:px-6 lg:px-8">
<Breadcrumbs <Breadcrumbs
currentStep={step} currentStep={step}
setStep={setStep} setStep={setStepWithValidation}
steps={breadcrumbSteps} steps={breadcrumbSteps}
/> />
</div> </div>
@ -288,7 +303,7 @@ export default function OffersSubmissionForm({
label="Next" label="Next"
variant="primary" variant="primary"
onClick={() => { onClick={() => {
goToNextStep(step); setStepWithValidation(step + 1);
gaEvent({ gaEvent({
action: 'offers.profile_submission_navigate_next', action: 'offers.profile_submission_navigate_next',
category: 'submission', category: 'submission',
@ -315,9 +330,16 @@ export default function OffersSubmissionForm({
}} }}
/> />
<Button <Button
disabled={isSubmitting || isSubmitSuccessful} disabled={
isSubmitting ||
createOrUpdateMutation.isLoading ||
generateAnalysisMutation.isLoading ||
generateAnalysisMutation.isSuccess
}
icon={ArrowRightIcon} icon={ArrowRightIcon}
isLoading={isSubmitting || isSubmitSuccessful} isLoading={
isSubmitting || createOrUpdateMutation.isLoading
}
label="Submit" label="Submit"
type="submit" type="submit"
variant="primary" variant="primary"

@ -2,12 +2,7 @@ import { useFormContext, useWatch } from 'react-hook-form';
import { JobType } from '@prisma/client'; import { JobType } from '@prisma/client';
import { Collapsible, RadioList } from '@tih/ui'; import { Collapsible, RadioList } from '@tih/ui';
import { import { FieldError } from '~/components/offers/constants';
educationFieldOptions,
educationLevelOptions,
emptyOption,
FieldError,
} from '~/components/offers/constants';
import type { BackgroundPostData } from '~/components/offers/types'; import type { BackgroundPostData } from '~/components/offers/types';
import CitiesTypeahead from '~/components/shared/CitiesTypeahead'; import CitiesTypeahead from '~/components/shared/CitiesTypeahead';
import CompaniesTypeahead from '~/components/shared/CompaniesTypeahead'; import CompaniesTypeahead from '~/components/shared/CompaniesTypeahead';
@ -20,6 +15,8 @@ import {
CURRENCY_OPTIONS, CURRENCY_OPTIONS,
} from '~/utils/offers/currency/CurrencyEnum'; } from '~/utils/offers/currency/CurrencyEnum';
import { EducationFieldOptions } from '../../EducationFields';
import { EducationLevelOptions } from '../../EducationLevels';
import FormRadioList from '../../forms/FormRadioList'; import FormRadioList from '../../forms/FormRadioList';
import FormSection from '../../forms/FormSection'; import FormSection from '../../forms/FormSection';
import FormSelect from '../../forms/FormSelect'; import FormSelect from '../../forms/FormSelect';
@ -134,6 +131,9 @@ function FullTimeJobFields() {
if (option) { if (option) {
setValue('background.experiences.0.companyId', option.value); setValue('background.experiences.0.companyId', option.value);
setValue('background.experiences.0.companyName', option.label); setValue('background.experiences.0.companyName', option.label);
} else {
setValue('background.experiences.0.companyId', '');
setValue('background.experiences.0.companyName', '');
} }
}} }}
/> />
@ -279,23 +279,34 @@ function InternshipJobFields() {
})} })}
/> />
<Collapsible label="Add more details"> <Collapsible label="Add more details">
<CitiesTypeahead <div className="grid grid-cols-1 gap-6 sm:grid-cols-2">
label="Location" <CitiesTypeahead
value={{ label="Location"
id: watchCityId, value={{
label: watchCityName, id: watchCityId,
value: watchCityId, label: watchCityName,
}} value: watchCityId,
onSelect={(option) => { }}
if (option) { onSelect={(option) => {
setValue('background.experiences.0.cityId', option.value); if (option) {
setValue('background.experiences.0.cityName', option.label); setValue('background.experiences.0.cityId', option.value);
} else { setValue('background.experiences.0.cityName', option.label);
setValue('background.experiences.0.cityId', ''); } else {
setValue('background.experiences.0.cityName', ''); setValue('background.experiences.0.cityId', '');
} setValue('background.experiences.0.cityName', '');
}} }
/> }}
/>
<FormTextInput
errorMessage={experiencesField?.durationInMonths?.message}
label="Duration (months)"
type="number"
{...register(`background.experiences.0.durationInMonths`, {
min: { message: FieldError.NON_NEGATIVE_NUMBER, value: 0 },
valueAsNumber: true,
})}
/>
</div>
</Collapsible> </Collapsible>
</> </>
); );
@ -343,15 +354,13 @@ function EducationSection() {
<FormSelect <FormSelect
display="block" display="block"
label="Education Level" label="Education Level"
options={educationLevelOptions} options={EducationLevelOptions}
placeholder={emptyOption}
{...register(`background.educations.0.type`)} {...register(`background.educations.0.type`)}
/> />
<FormSelect <FormSelect
display="block" display="block"
label="Field" label="Field"
options={educationFieldOptions} options={EducationFieldOptions}
placeholder={emptyOption}
{...register(`background.educations.0.field`)} {...register(`background.educations.0.field`)}
/> />
</div> </div>

@ -22,20 +22,16 @@ import {
defaultFullTimeOfferValues, defaultFullTimeOfferValues,
defaultInternshipOfferValues, defaultInternshipOfferValues,
} from '../OffersSubmissionForm'; } from '../OffersSubmissionForm';
import { import { FieldError, JobTypeLabel } from '../../constants';
emptyOption,
FieldError,
internshipCycleOptions,
yearOptions,
} from '../../constants';
import FormMonthYearPicker from '../../forms/FormMonthYearPicker'; import FormMonthYearPicker from '../../forms/FormMonthYearPicker';
import FormSection from '../../forms/FormSection'; import FormSection from '../../forms/FormSection';
import FormSelect from '../../forms/FormSelect'; import FormSelect from '../../forms/FormSelect';
import FormTextArea from '../../forms/FormTextArea'; import FormTextArea from '../../forms/FormTextArea';
import FormTextInput from '../../forms/FormTextInput'; import FormTextInput from '../../forms/FormTextInput';
import { InternshipCycleOptions } from '../../InternshipCycles';
import JobTypeTabs from '../../JobTypeTabs'; import JobTypeTabs from '../../JobTypeTabs';
import type { OfferFormData } from '../../types'; import type { OfferFormData } from '../../types';
import { JobTypeLabel } from '../../types'; import { FutureYearsOptions } from '../../Years';
import { import {
Currency, Currency,
CURRENCY_OPTIONS, CURRENCY_OPTIONS,
@ -384,8 +380,7 @@ function InternshipOfferDetailsForm({
display="block" display="block"
errorMessage={offerFields?.offersIntern?.internshipCycle?.message} errorMessage={offerFields?.offersIntern?.internshipCycle?.message}
label="Internship Cycle" label="Internship Cycle"
options={internshipCycleOptions} options={InternshipCycleOptions}
placeholder={emptyOption}
required={true} required={true}
{...register(`offers.${index}.offersIntern.internshipCycle`, { {...register(`offers.${index}.offersIntern.internshipCycle`, {
required: FieldError.REQUIRED, required: FieldError.REQUIRED,
@ -395,8 +390,7 @@ function InternshipOfferDetailsForm({
display="block" display="block"
errorMessage={offerFields?.offersIntern?.startYear?.message} errorMessage={offerFields?.offersIntern?.startYear?.message}
label="Internship Year" label="Internship Year"
options={yearOptions} options={FutureYearsOptions}
placeholder={emptyOption}
required={true} required={true}
{...register(`offers.${index}.offersIntern.startYear`, { {...register(`offers.${index}.offersIntern.startYear`, {
required: FieldError.REQUIRED, required: FieldError.REQUIRED,
@ -522,14 +516,11 @@ function OfferDetailsFormArray({
); );
} }
type OfferDetailsFormProps = Readonly<{ export default function OfferDetailsForm() {
defaultJobType?: JobType; const watchJobType = useWatch({
}>; name: `offers.0.jobType`,
});
export default function OfferDetailsForm({ const [jobType, setJobType] = useState(watchJobType as JobType);
defaultJobType = JobType.FULLTIME,
}: OfferDetailsFormProps) {
const [jobType, setJobType] = useState(defaultJobType);
const [isDialogOpen, setDialogOpen] = useState(false); const [isDialogOpen, setDialogOpen] = useState(false);
const { control } = useFormContext(); const { control } = useFormContext();
const fieldArrayValues = useFieldArray({ control, name: 'offers' }); const fieldArrayValues = useFieldArray({ control, name: 'offers' });
@ -576,8 +567,8 @@ export default function OfferDetailsForm({
label="Switch" label="Switch"
variant="primary" variant="primary"
onClick={() => { onClick={() => {
toggleJobType();
setDialogOpen(false); setDialogOpen(false);
toggleJobType();
}} }}
/> />
} }

@ -13,12 +13,12 @@ export default function EducationCard({
education: { type, field, startDate, endDate, school }, education: { type, field, startDate, endDate, school },
}: Props) { }: Props) {
return ( return (
<div className="mx-8 my-4 block rounded-lg bg-white py-4 shadow-md"> <div className="block rounded-lg border border-slate-200 bg-white p-4 text-sm ">
<div className="flex justify-between px-8"> <div className="flex justify-between">
<div className="flex flex-col"> <div>
<div className="flex flex-row"> <div className="flex items-center">
<LightBulbIcon className="mr-1 h-5" /> <LightBulbIcon className="mr-1 h-5" />
<span className="ml-1 font-bold"> <span className="text-semibold ml-1">
{field ? `${type ?? 'N/A'}, ${field}` : type ?? `N/A`} {field ? `${type ?? 'N/A'}, ${field}` : type ?? `N/A`}
</span> </span>
</div> </div>

@ -1,13 +1,15 @@
import { import {
BuildingOffice2Icon, ArrowTrendingUpIcon,
ChatBubbleBottomCenterTextIcon, BuildingOfficeIcon,
CurrencyDollarIcon, MapPinIcon,
ScaleIcon, } from '@heroicons/react/20/solid';
} from '@heroicons/react/24/outline'; import { JobType } from '@prisma/client';
import { HorizontalDivider } from '@tih/ui';
import { JobTypeLabel } from '~/components/offers/constants';
import type { OfferDisplayData } from '~/components/offers/types'; import type { OfferDisplayData } from '~/components/offers/types';
import { JobTypeLabel } from '~/components/offers/types';
import { getLocationDisplayText } from '~/utils/offers/string';
import { getDurationDisplayText } from '~/utils/offers/time';
type Props = Readonly<{ type Props = Readonly<{
offer: OfferDisplayData; offer: OfferDisplayData;
@ -33,33 +35,55 @@ export default function OfferCard({
}: Props) { }: Props) {
function UpperSection() { function UpperSection() {
return ( return (
<div className="flex justify-between px-8"> <div className="px-4 py-5 sm:px-6">
<div className="flex flex-col"> <div className="flex justify-between">
<div className="flex flex-row"> <div>
<span> <h3 className="text-lg font-medium leading-6 text-slate-900">
<BuildingOffice2Icon className="mr-3 h-5" /> {jobTitle} {jobType && <>({JobTypeLabel[jobType]})</>}
</span> </h3>
<span className="font-bold"> <div className="mt-1 flex flex-row flex-wrap space-x-4 sm:mt-0">
{location ? `${companyName}, ${location.cityName}` : companyName} {companyName && (
</span> <div className="mt-2 flex items-center text-sm text-slate-500">
<BuildingOfficeIcon
aria-hidden="true"
className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400"
/>
{companyName}
</div>
)}
{location && (
<div className="mt-2 flex items-center text-sm text-slate-500">
<MapPinIcon
aria-hidden="true"
className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400"
/>
{getLocationDisplayText(location)}
</div>
)}
{jobLevel && (
<div className="mt-2 flex items-center text-sm text-slate-500">
<ArrowTrendingUpIcon
aria-hidden="true"
className="mr-1.5 h-5 w-5 flex-shrink-0 text-slate-400"
/>
{jobLevel}
</div>
)}
</div>
</div> </div>
<div className="ml-8 flex flex-row"> <div className="space-y-2">
<p> {!duration && receivedMonth && (
{jobLevel ? `${jobTitle}, ${jobLevel}` : jobTitle}{' '} <div className="text-sm text-slate-500">
{jobType && `(${JobTypeLabel[jobType]})`} <p>{receivedMonth}</p>
</p> </div>
)}
{!!duration && (
<div className="text-sm text-slate-500">
<p>{getDurationDisplayText(duration)}</p>
</div>
)}
</div> </div>
</div> </div>
{!duration && receivedMonth && (
<div className="font-light text-slate-400">
<p>{receivedMonth}</p>
</div>
)}
{duration && (
<div className="font-light text-slate-400">
<p>{`${duration} months`}</p>
</div>
)}
</div> </div>
); );
} }
@ -75,60 +99,72 @@ export default function OfferCard({
} }
return ( return (
<> <div className="border-t border-slate-200 px-4 py-5 sm:px-6">
<HorizontalDivider /> <dl className="grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-4">
<div className="px-8"> {jobType === JobType.FULLTIME
<div className="flex flex-col py-2"> ? totalCompensation && (
{(totalCompensation || monthlySalary) && ( <div className="col-span-1">
<div className="flex flex-row"> <dt className="text-sm font-medium text-slate-500">
<span> Total Compensation
<CurrencyDollarIcon className="mr-3 h-5" /> </dt>
</span> <dd className="mt-1 text-sm text-slate-900">
<span> {totalCompensation}
<p> </dd>
{totalCompensation && `TC: ${totalCompensation}`} </div>
{monthlySalary && `Monthly Salary: ${monthlySalary}`} )
</p> : monthlySalary && (
</span> <div className="col-span-1">
</div> <dt className="text-sm font-medium text-slate-500">
)} Monthly Salary
{(base || stocks || bonus) && totalCompensation && ( </dt>
<div className="ml-8 flex flex-row font-light"> <dd className="mt-1 text-sm text-slate-900">
<p> {monthlySalary}
Base / year: {base ?? 'N/A'} Stocks / year:{' '} </dd>
{stocks ?? 'N/A'} Bonus / year: {bonus ?? 'N/A'} </div>
</p> )}
</div> {base && (
)} <div className="col-span-1">
</div> <dt className="text-sm font-medium text-slate-500">
Base Salary
</dt>
<dd className="mt-1 text-sm text-slate-900">{base}</dd>
</div>
)}
{stocks && (
<div className="col-span-1">
<dt className="text-sm font-medium text-slate-500">Stocks</dt>
<dd className="mt-1 text-sm text-slate-900">{stocks}</dd>
</div>
)}
{bonus && (
<div className="col-span-1">
<dt className="text-sm font-medium text-slate-500">Bonus</dt>
<dd className="mt-1 text-sm text-slate-900">{bonus}</dd>
</div>
)}
{negotiationStrategy && ( {negotiationStrategy && (
<div className="flex flex-col py-2"> <div className="col-span-2">
<div className="flex flex-row"> <dt className="text-sm font-medium text-slate-500">
<span> Negotiation Strategy
<ScaleIcon className="h-5 w-5" /> </dt>
</span> <dd className="mt-1 text-sm text-slate-900">
<span className="overflow-wrap ml-2"> {negotiationStrategy}
"{negotiationStrategy}" </dd>
</span>
</div>
</div> </div>
)} )}
{otherComment && ( {otherComment && (
<div className="flex flex-col py-2"> <div className="col-span-2">
<div className="flex flex-row"> <dt className="text-sm font-medium text-slate-500">Others</dt>
<span> <dd className="mt-1 text-sm text-slate-900">{otherComment}</dd>
<ChatBubbleBottomCenterTextIcon className="h-5 w-5" />
</span>
<span className="overflow-wrap ml-2">"{otherComment}"</span>
</div>
</div> </div>
)} )}
</div> </dl>
</> </div>
); );
} }
return ( return (
<div className="mx-8 my-4 block rounded-md border-b border-gray-300 bg-white py-4"> <div className="block rounded-lg border border-slate-200 bg-white">
<UpperSection /> <UpperSection />
<BottomSection /> <BottomSection />
</div> </div>

@ -1,13 +1,7 @@
import { signIn, useSession } from 'next-auth/react'; import { signIn, useSession } from 'next-auth/react';
import { useState } from 'react'; import { useState } from 'react';
import { ClipboardDocumentIcon, ShareIcon } from '@heroicons/react/24/outline'; import { ClipboardDocumentIcon, ShareIcon } from '@heroicons/react/24/outline';
import { import { Button, Spinner, TextArea, useToast } from '@tih/ui';
Button,
HorizontalDivider,
Spinner,
TextArea,
useToast,
} from '@tih/ui';
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
import ExpandableCommentCard from '~/components/offers/profile/comments/ExpandableCommentCard'; import ExpandableCommentCard from '~/components/offers/profile/comments/ExpandableCommentCard';
@ -110,10 +104,10 @@ export default function ProfileComments({
); );
} }
return ( return (
<div className="bh-white h-fit px-4 lg:h-[calc(100vh-4.5rem)] lg:overflow-y-auto"> <div className="bh-white h-fit lg:h-[calc(100vh-4.5rem)] lg:overflow-y-auto">
<div className="bg-white pt-4 lg:sticky lg:top-0"> <div className="border-b border-slate-200 bg-white p-4 lg:sticky lg:top-0">
<div className="flex justify-end"> <div className="flex justify-end">
<div className="grid w-fit grid-cols-1 space-y-2 md:grid-cols-2 md:grid-cols-2 md:space-y-0 md:space-x-4"> <div className="grid w-fit grid-cols-1 space-y-2 md:grid-cols-2 md:space-y-0 md:space-x-4">
<div className="col-span-1 flex justify-end"> <div className="col-span-1 flex justify-end">
{isEditable && ( {isEditable && (
<Tooltip tooltipContent="Copy this link to edit your profile later"> <Tooltip tooltipContent="Copy this link to edit your profile later">
@ -169,57 +163,60 @@ export default function ProfileComments({
</div> </div>
</div> </div>
<h2 className="mt-2 mb-6 text-2xl font-bold">Discussions</h2> <div className="space-y-4">
{isEditable || session?.user?.name ? ( <h2 className="text-2xl font-bold">Discussions</h2>
<div> {isEditable || session?.user?.name ? (
<TextArea <div>
label={`Comment as ${ <TextArea
isEditable ? profileName : session?.user?.name ?? 'anonymous' label={`Comment as ${
}`} isEditable ? profileName : session?.user?.name ?? 'anonymous'
placeholder="Type your comment here" }`}
value={currentReply} placeholder="Type your comment here"
onChange={(value) => setCurrentReply(value)} value={currentReply}
/> onChange={(value) => setCurrentReply(value)}
<div className="mt-2 flex w-full justify-end"> />
<div className="w-fit"> <div className="mt-2 flex w-full justify-end">
<Button <div className="w-fit">
disabled={ <Button
commentsQuery.isLoading || disabled={
!currentReply.length || commentsQuery.isLoading ||
createCommentMutation.isLoading !currentReply.length ||
} createCommentMutation.isLoading
display="block" }
isLabelHidden={false} display="block"
isLoading={createCommentMutation.isLoading} isLabelHidden={false}
label="Comment" isLoading={createCommentMutation.isLoading}
size="sm" label="Comment"
variant="primary" size="sm"
onClick={() => handleComment(currentReply)} variant="primary"
/> onClick={() => handleComment(currentReply)}
/>
</div>
</div> </div>
</div> </div>
<HorizontalDivider /> ) : (
</div> <Button
) : ( display="block"
<Button href={loginPageHref()}
className="mb-5" label="Sign in to join discussion"
display="block" variant="tertiary"
href={loginPageHref()} />
label="Sign in to join discussion" )}
variant="tertiary" </div>
/>
)}
</div>
<div className="w-full">
{replies?.map((reply: Reply) => (
<ExpandableCommentCard
key={reply.id}
comment={reply}
profileId={profileId}
token={isEditable ? token : undefined}
/>
))}
</div> </div>
<section className="w-full px-4">
<ul className="divide-y divide-slate-200" role="list">
{replies?.map((reply: Reply) => (
<li key={reply.id} className="py-6">
<ExpandableCommentCard
comment={reply}
profileId={profileId}
token={isEditable ? token : undefined}
/>
</li>
))}
</ul>
</section>
</div> </div>
); );
} }

@ -25,19 +25,19 @@ type ProfileOffersProps = Readonly<{
}>; }>;
function ProfileOffers({ offers }: ProfileOffersProps) { function ProfileOffers({ offers }: ProfileOffersProps) {
if (offers.length !== 0) { if (offers.length === 0) {
return ( return (
<> <div className="p-4">
{offers.map((offer) => ( <p className="font-semibold">No offers are attached.</p>
<OfferCard key={offer.id} offer={offer} /> </div>
))}
</>
); );
} }
return ( return (
<div className="mx-8 my-4 flex flex-row"> <div className="space-y-4 p-4">
<BriefcaseIcon className="mr-1 h-5" /> {offers.map((offer) => (
<span className="font-bold">No offer is attached.</span> <OfferCard key={offer.id} offer={offer} />
))}
</div> </div>
); );
} }
@ -49,33 +49,37 @@ type ProfileBackgroundProps = Readonly<{
function ProfileBackground({ background }: ProfileBackgroundProps) { function ProfileBackground({ background }: ProfileBackgroundProps) {
if (!background?.experiences?.length && !background?.educations?.length) { if (!background?.experiences?.length && !background?.educations?.length) {
return ( return (
<div className="mx-8 my-4"> <div className="p-4">
<p>No background information available.</p> <p>No background information available.</p>
</div> </div>
); );
} }
return ( return (
<> <div className="space-y-8 p-4">
{background?.experiences?.length > 0 && ( {background?.experiences?.length > 0 && (
<> <div className="space-y-2">
<div className="mx-8 my-4 flex flex-row"> <div className="flex items-center space-x-2 text-slate-500">
<BriefcaseIcon className="mr-1 h-5" /> <BriefcaseIcon className="h-5" />
<span className="font-bold">Work Experience</span> <h3 className="text-sm font-semibold uppercase tracking-wide">
Work Experience
</h3>
</div> </div>
<OfferCard offer={background.experiences[0]} /> <OfferCard offer={background.experiences[0]} />
</> </div>
)} )}
{background?.educations?.length > 0 && ( {background?.educations?.length > 0 && (
<> <div className="space-y-2">
<div className="mx-8 my-4 flex flex-row"> <div className="flex items-center space-x-2 text-slate-500">
<AcademicCapIcon className="mr-1 h-5" /> <AcademicCapIcon className="h-5" />
<span className="font-bold">Education</span> <h3 className="text-sm font-semibold uppercase tracking-wide">
Education
</h3>
</div> </div>
<EducationCard education={background.educations[0]} /> <EducationCard education={background.educations[0]} />
</> </div>
)} )}
</> </div>
); );
} }
@ -114,7 +118,7 @@ function ProfileAnalysis({
} }
return ( return (
<div className="mx-8 my-4"> <div className="space-y-4 p-4">
{!analysis ? ( {!analysis ? (
<p>No analysis available.</p> <p>No analysis available.</p>
) : ( ) : (
@ -165,12 +169,15 @@ export default function ProfileDetails({
</div> </div>
); );
} }
if (selectedTab === ProfileDetailTab.OFFERS) { if (selectedTab === ProfileDetailTab.OFFERS) {
return <ProfileOffers offers={offers} />; return <ProfileOffers offers={offers} />;
} }
if (selectedTab === ProfileDetailTab.BACKGROUND) { if (selectedTab === ProfileDetailTab.BACKGROUND) {
return <ProfileBackground background={background} />; return <ProfileBackground background={background} />;
} }
if (selectedTab === ProfileDetailTab.ANALYSIS) { if (selectedTab === ProfileDetailTab.ANALYSIS) {
return ( return (
<ProfileAnalysis <ProfileAnalysis

@ -13,10 +13,10 @@ import { Button, Dialog, Spinner, Tabs, useToast } from '@tih/ui';
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
import type { ProfileDetailTab } from '~/components/offers/constants'; import type { ProfileDetailTab } from '~/components/offers/constants';
import { JobTypeLabel } from '~/components/offers/constants';
import { profileDetailTabs } from '~/components/offers/constants'; import { profileDetailTabs } from '~/components/offers/constants';
import ProfilePhotoHolder from '~/components/offers/profile/ProfilePhotoHolder'; import ProfilePhotoHolder from '~/components/offers/profile/ProfilePhotoHolder';
import type { BackgroundDisplayData } from '~/components/offers/types'; import type { BackgroundDisplayData } from '~/components/offers/types';
import { JobTypeLabel } from '~/components/offers/types';
import Tooltip from '~/components/offers/util/Tooltip'; import Tooltip from '~/components/offers/util/Tooltip';
import { getProfileEditPath } from '~/utils/offers/link'; import { getProfileEditPath } from '~/utils/offers/link';
@ -233,20 +233,20 @@ export default function ProfileHeader({
const { experiences, totalYoe, specificYoes, profileName } = background; const { experiences, totalYoe, specificYoes, profileName } = background;
return ( return (
<div className="grid-rows-2 bg-white p-4"> <div className="grid-rows-2 bg-white">
<div className="flex grid grid-cols-5 md:grid-cols-7"> <div className="grid grid-cols-5 p-4 md:grid-cols-7">
<div className="jsutify-start col-span-5 flex"> <div className="col-span-5 flex justify-start space-x-4">
<div className="ml-0 mr-2 mt-2 h-16 w-16 md:mx-4"> <div className="mt-2 h-16 w-16">
<ProfilePhotoHolder /> <ProfilePhotoHolder />
</div> </div>
<div> <div className="space-y-1">
<h2 className="flex text-2xl font-bold"> <h2 className="flex text-2xl font-bold">
{profileName ?? 'anonymous'} {profileName ?? 'anonymous'}
</h2> </h2>
{(experiences[0]?.companyName || {(experiences[0]?.companyName ||
experiences[0]?.jobLevel || experiences[0]?.jobLevel ||
experiences[0]?.jobTitle) && ( experiences[0]?.jobTitle) && (
<div className="flex flex-row text-slate-600"> <div className="flex items-center text-sm text-slate-600">
<span> <span>
<BuildingOffice2Icon className="mr-2.5 h-5 w-5" /> <BuildingOffice2Icon className="mr-2.5 h-5 w-5" />
</span> </span>
@ -262,7 +262,7 @@ export default function ProfileHeader({
</p> </p>
</div> </div>
)} )}
<div className="flex flex-row text-slate-600"> <div className="flex items-center text-sm text-slate-600">
<CalendarDaysIcon className="mr-2.5 h-5" /> <CalendarDaysIcon className="mr-2.5 h-5" />
<p> <p>
<span className="mr-2 font-bold">YOE:</span> <span className="mr-2 font-bold">YOE:</span>
@ -286,7 +286,7 @@ export default function ProfileHeader({
</div> </div>
)} )}
</div> </div>
<div className="mt-4"> <div className="border-t border-slate-200 p-4">
<Tabs <Tabs
label="Profile Detail Navigation" label="Profile Detail Navigation"
tabs={profileDetailTabs} tabs={profileDetailTabs}

@ -1,11 +1,11 @@
type ProfilePhotoHolderProps = Readonly<{ type ProfilePhotoHolderProps = Readonly<{
size?: 'lg' | 'sm'; size?: 'lg' | 'sm' | 'xs';
}>; }>;
export default function ProfilePhotoHolder({ export default function ProfilePhotoHolder({
size = 'lg', size = 'lg',
}: ProfilePhotoHolderProps) { }: ProfilePhotoHolderProps) {
const sizeMap = { lg: '16', sm: '12' }; const sizeMap = { lg: '16', sm: '12', xs: '10' };
return ( return (
<span <span
className={`inline-block h-${sizeMap[size]} w-${sizeMap[size]} overflow-hidden rounded-full bg-slate-100`}> className={`inline-block h-${sizeMap[size]} w-${sizeMap[size]} overflow-hidden rounded-full bg-slate-100`}>

@ -1,14 +1,11 @@
import { signIn, useSession } from 'next-auth/react'; import { signIn, useSession } from 'next-auth/react';
import { useState } from 'react'; import { useState } from 'react';
import { import { Button, Dialog, TextArea, useToast } from '@tih/ui';
ChatBubbleBottomCenterIcon,
TrashIcon,
} from '@heroicons/react/24/outline';
import { Button, Dialog, HorizontalDivider, TextArea, useToast } from '@tih/ui';
import { timeSinceNow } from '~/utils/offers/time'; import ProfilePhotoHolder from '~/components/offers/profile/ProfilePhotoHolder';
import { trpc } from '../../../../utils/trpc'; import { timeSinceNow } from '~/utils/offers/time';
import { trpc } from '~/utils/trpc';
import type { Reply } from '~/types/offers'; import type { Reply } from '~/types/offers';
@ -125,83 +122,105 @@ export default function CommentCard({
} }
return ( return (
<> <div className="flex space-x-3">
<div className="flex pl-2"> <div className="flex-shrink-0">
<div className="flex w-full flex-col"> {user?.image ? (
<div className="flex flex-row font-bold"> <img
alt={user?.name ?? user?.email ?? 'Unknown user'}
className="h-10 w-10 rounded-full"
src={user?.image}
/>
) : (
<ProfilePhotoHolder size="xs" />
)}
</div>
<div className="w-full">
<div className="text-sm">
<p className="font-medium text-slate-900">
{user?.name ?? 'unknown user'} {user?.name ?? 'unknown user'}
</div> </p>
<div className="mt-2 mb-2 flex flex-row ">{message}</div> </div>
<div className="flex flex-row items-center justify-start space-x-4 "> <div className="mt-1 text-sm text-slate-700">
<div className="flex flex-col text-sm font-light text-slate-400">{`${timeSinceNow( <p className="break-all">{message}</p>
createdAt, </div>
)} ago`}</div> <div className="mt-2 space-x-2 text-xs">
{replyLength > 0 && ( <span className="font-medium text-slate-500">
<div {timeSinceNow(createdAt)} ago
className="text-primary-600 flex cursor-pointer flex-col text-sm hover:underline" </span>{' '}
{replyLength > 0 && (
<>
<span className="font-medium text-slate-500">&middot;</span>{' '}
<button
className="font-medium text-slate-900"
type="button"
onClick={handleExpanded}> onClick={handleExpanded}>
{isExpanded ? `Hide replies` : `View replies (${replyLength})`} {isExpanded ? `Hide replies` : `View replies (${replyLength})`}
</div> </button>
)} </>
{!disableReply && ( )}
<div className="flex flex-col"> {!disableReply && (
<Button <>
icon={ChatBubbleBottomCenterIcon} <span className="font-medium text-slate-500">&middot;</span>{' '}
isLabelHidden={true} <button
label="Reply" className="font-medium text-slate-900"
size="sm" type="button"
variant="tertiary" onClick={() => setIsReplying(!isReplying)}>
onClick={() => setIsReplying(!isReplying)} Reply
/> </button>
</div> </>
)} )}
{deletable && ( {deletable && (
<> <>
<Button <span className="font-medium text-slate-500">&middot;</span>{' '}
disabled={deleteCommentMutation.isLoading} <button
icon={TrashIcon} className="font-medium text-slate-900"
isLabelHidden={true} disabled={deleteCommentMutation.isLoading}
isLoading={deleteCommentMutation.isLoading} type="button"
label="Delete" onClick={() => setIsDialogOpen(true)}>
size="sm" {deleteCommentMutation.isLoading ? 'Deleting...' : 'Delete'}
variant="tertiary" </button>
onClick={() => setIsDialogOpen(true)} {isDialogOpen && (
/> <Dialog
{isDialogOpen && ( isShown={isDialogOpen}
<Dialog primaryButton={
isShown={isDialogOpen} <Button
primaryButton={ display="block"
<Button label="Delete"
display="block" variant="primary"
label="Delete" onClick={() => {
variant="primary" setIsDialogOpen(false);
onClick={() => { handleDelete();
setIsDialogOpen(false); }}
handleDelete(); />
}} }
/> secondaryButton={
} <Button
secondaryButton={ display="block"
<Button label="Cancel"
display="block" variant="tertiary"
label="Cancel" onClick={() => setIsDialogOpen(false)}
variant="tertiary" />
onClick={() => setIsDialogOpen(false)} }
/> title="Are you sure you want to delete this comment?"
} onClose={() => setIsDialogOpen(false)}>
title="Are you sure you want to delete this comment?" <div>You cannot undo this operation.</div>
onClose={() => setIsDialogOpen(false)}> </Dialog>
<div>You cannot undo this operation.</div> )}
</Dialog> </>
)} )}
</> </div>
)} {!disableReply && isReplying && (
</div> <div className="mt-4 mr-2">
{!disableReply && isReplying && ( <form
<div className="mt-2 mr-2"> onSubmit={(event) => {
event.preventDefault();
event.stopPropagation();
handleReply();
}}>
<TextArea <TextArea
autoFocus={true}
isLabelHidden={true} isLabelHidden={true}
label="Comment" label="Reply to comment"
placeholder="Type your reply here" placeholder="Type your reply here"
resize="none" resize="none"
value={currentReply} value={currentReply}
@ -225,11 +244,10 @@ export default function CommentCard({
/> />
</div> </div>
</div> </div>
</div> </form>
)} </div>
</div> )}
</div> </div>
<HorizontalDivider /> </div>
</>
); );
} }

@ -26,18 +26,20 @@ export default function ExpandableCommentCard({
replyLength={comment.replies?.length ?? 0} replyLength={comment.replies?.length ?? 0}
token={token} token={token}
/> />
{comment.replies && ( {comment.replies && comment.replies.length > 0 && isExpanded && (
<div className="pl-8"> <div className="pt-4">
{isExpanded && <ul className="space-y-4 pl-14" role="list">
comment.replies.map((reply) => ( {comment.replies.map((reply) => (
<CommentCard <li key={reply.id}>
key={reply.id} <CommentCard
comment={reply} comment={reply}
disableReply={true} disableReply={true}
profileId={profileId} profileId={profileId}
token={token} token={token}
/> />
</li>
))} ))}
</ul>
</div> </div>
)} )}
</div> </div>

@ -1,14 +1,14 @@
import clsx from 'clsx'; import clsx from 'clsx';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { useEffect, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { JobType } from '@prisma/client'; import { JobType } from '@prisma/client';
import { DropdownMenu, Spinner } from '@tih/ui'; import { DropdownMenu, Spinner, useToast } from '@tih/ui';
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
import OffersTablePagination from '~/components/offers/table/OffersTablePagination'; import OffersTablePagination from '~/components/offers/table/OffersTablePagination';
import type { OfferTableSortByType } from '~/components/offers/table/types';
import { import {
OfferTableFilterOptions, OfferTableFilterOptions,
OfferTableSortBy,
OfferTableYoeOptions, OfferTableYoeOptions,
YOE_CATEGORY, YOE_CATEGORY,
YOE_CATEGORY_PARAM, YOE_CATEGORY_PARAM,
@ -16,6 +16,7 @@ import {
import { Currency } from '~/utils/offers/currency/CurrencyEnum'; import { Currency } from '~/utils/offers/currency/CurrencyEnum';
import CurrencySelector from '~/utils/offers/currency/CurrencySelector'; import CurrencySelector from '~/utils/offers/currency/CurrencySelector';
import { useSearchParamSingle } from '~/utils/offers/useSearchParam';
import { trpc } from '~/utils/trpc'; import { trpc } from '~/utils/trpc';
import OffersRow from './OffersRow'; import OffersRow from './OffersRow';
@ -25,16 +26,17 @@ import type { DashboardOffer, GetOffersResponse, Paging } from '~/types/offers';
const NUMBER_OF_OFFERS_IN_PAGE = 10; const NUMBER_OF_OFFERS_IN_PAGE = 10;
export type OffersTableProps = Readonly<{ export type OffersTableProps = Readonly<{
companyFilter: string; companyFilter: string;
companyName?: string;
countryFilter: string; countryFilter: string;
jobTitleFilter: string; jobTitleFilter: string;
}>; }>;
export default function OffersTable({ export default function OffersTable({
countryFilter, countryFilter,
companyName,
companyFilter, companyFilter,
jobTitleFilter, jobTitleFilter,
}: OffersTableProps) { }: OffersTableProps) {
const [currency, setCurrency] = useState(Currency.SGD.toString()); // TODO: Detect location const [currency, setCurrency] = useState(Currency.SGD.toString()); // TODO: Detect location
const [selectedYoe, setSelectedYoe] = useState('');
const [jobType, setJobType] = useState<JobType>(JobType.FULLTIME); const [jobType, setJobType] = useState<JobType>(JobType.FULLTIME);
const [pagination, setPagination] = useState<Paging>({ const [pagination, setPagination] = useState<Paging>({
currentPage: 0, currentPage: 0,
@ -42,30 +44,64 @@ export default function OffersTable({
numOfPages: 0, numOfPages: 0,
totalItems: 0, totalItems: 0,
}); });
const [offers, setOffers] = useState<Array<DashboardOffer>>([]); const [offers, setOffers] = useState<Array<DashboardOffer>>([]);
const [selectedFilter, setSelectedFilter] = useState(
OfferTableFilterOptions[0].value,
);
const { event: gaEvent } = useGoogleAnalytics(); const { event: gaEvent } = useGoogleAnalytics();
const router = useRouter(); const router = useRouter();
const { yoeCategory = '' } = router.query;
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
useEffect(() => { const [
setPagination({ selectedYoeCategory,
currentPage: 0, setSelectedYoeCategory,
numOfItems: 0, isYoeCategoryInitialized,
numOfPages: 0, ] = useSearchParamSingle<keyof typeof YOE_CATEGORY_PARAM>('yoeCategory');
totalItems: 0,
}); const [selectedSortBy, setSelectedSortBy, isSortByInitialized] =
setIsLoading(true); useSearchParamSingle<OfferTableSortByType>('sortBy');
}, [selectedYoe, currency, countryFilter, companyFilter, jobTitleFilter]);
const areFilterParamsInitialized = useMemo(() => {
return isYoeCategoryInitialized && isSortByInitialized;
}, [isYoeCategoryInitialized, isSortByInitialized]);
const { pathname } = router;
useEffect(() => { useEffect(() => {
setSelectedYoe(yoeCategory as YOE_CATEGORY); if (areFilterParamsInitialized) {
event?.preventDefault(); router.replace(
}, [yoeCategory]); {
pathname,
query: {
companyId: companyFilter,
companyName,
jobTitleId: jobTitleFilter,
sortBy: selectedSortBy,
yoeCategory: selectedYoeCategory,
},
},
undefined,
{ shallow: true },
);
setPagination({
currentPage: 0,
numOfItems: 0,
numOfPages: 0,
totalItems: 0,
});
setIsLoading(true);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
areFilterParamsInitialized,
currency,
countryFilter,
companyFilter,
jobTitleFilter,
selectedSortBy,
selectedYoeCategory,
pathname,
]);
const { showToast } = useToast();
trpc.useQuery( trpc.useQuery(
[ [
'offers.list', 'offers.list',
@ -75,14 +111,19 @@ export default function OffersTable({
currency, currency,
limit: NUMBER_OF_OFFERS_IN_PAGE, limit: NUMBER_OF_OFFERS_IN_PAGE,
offset: pagination.currentPage, offset: pagination.currentPage,
sortBy: OfferTableSortBy[selectedFilter] ?? '-monthYearReceived', sortBy: selectedSortBy ?? '-monthYearReceived',
title: jobTitleFilter, title: jobTitleFilter,
yoeCategory: YOE_CATEGORY_PARAM[yoeCategory as string] ?? undefined, yoeCategory: selectedYoeCategory
? YOE_CATEGORY_PARAM[selectedYoeCategory as string]
: undefined,
}, },
], ],
{ {
onError: (err) => { onError: () => {
alert(err); showToast({
title: 'Error loading the page.',
variant: 'failure',
});
}, },
onSuccess: (response: GetOffersResponse) => { onSuccess: (response: GetOffersResponse) => {
setOffers(response.data); setOffers(response.data);
@ -95,44 +136,26 @@ export default function OffersTable({
function renderFilters() { function renderFilters() {
return ( return (
<div className="flex items-center justify-between p-4 text-sm sm:grid-cols-4 md:text-base"> <div className="flex items-center justify-between p-4 text-xs text-slate-700 sm:grid-cols-4 sm:text-sm md:text-base">
<DropdownMenu <DropdownMenu
align="start" align="start"
label={ label={
OfferTableYoeOptions.filter( OfferTableYoeOptions.filter(
({ value: itemValue }) => itemValue === selectedYoe, ({ value: itemValue }) => itemValue === selectedYoeCategory,
)[0].label ).length > 0
? OfferTableYoeOptions.filter(
({ value: itemValue }) => itemValue === selectedYoeCategory,
)[0].label
: OfferTableYoeOptions[0].label
} }
size="inherit"> size="inherit">
{OfferTableYoeOptions.map(({ label: itemLabel, value }) => ( {OfferTableYoeOptions.map(({ label: itemLabel, value }) => (
<DropdownMenu.Item <DropdownMenu.Item
key={value} key={value}
isSelected={value === selectedYoe} isSelected={value === selectedYoeCategory}
label={itemLabel} label={itemLabel}
onClick={() => { onClick={() => {
if (value === '') { setSelectedYoeCategory(value);
router.replace(
{
pathname: router.pathname,
query: undefined,
},
undefined,
// Do not refresh the page
{ shallow: true },
);
} else {
const params = new URLSearchParams({
['yoeCategory']: value,
});
router.replace(
{
pathname: location.pathname,
search: params.toString(),
},
undefined,
{ shallow: true },
);
}
gaEvent({ gaEvent({
action: `offers.table_filter_yoe_category_${value}`, action: `offers.table_filter_yoe_category_${value}`,
category: 'engagement', category: 'engagement',
@ -157,17 +180,21 @@ export default function OffersTable({
align="end" align="end"
label={ label={
OfferTableFilterOptions.filter( OfferTableFilterOptions.filter(
({ value: itemValue }) => itemValue === selectedFilter, ({ value: itemValue }) => itemValue === selectedSortBy,
)[0].label ).length > 0
? OfferTableFilterOptions.filter(
({ value: itemValue }) => itemValue === selectedSortBy,
)[0].label
: OfferTableFilterOptions[0].label
} }
size="inherit"> size="inherit">
{OfferTableFilterOptions.map(({ label: itemLabel, value }) => ( {OfferTableFilterOptions.map(({ label: itemLabel, value }) => (
<DropdownMenu.Item <DropdownMenu.Item
key={value} key={value}
isSelected={value === selectedFilter} isSelected={value === selectedSortBy}
label={itemLabel} label={itemLabel}
onClick={() => { onClick={() => {
setSelectedFilter(value); setSelectedSortBy(value as OfferTableSortByType);
}} }}
/> />
))} ))}
@ -183,7 +210,9 @@ export default function OffersTable({
'Company', 'Company',
'Title', 'Title',
'YOE', 'YOE',
selectedYoe === YOE_CATEGORY.INTERN ? 'Monthly Salary' : 'Annual TC', selectedYoeCategory === YOE_CATEGORY.INTERN
? 'Monthly Salary'
: 'Annual TC',
'Date Offered', 'Date Offered',
'Actions', 'Actions',
]; ];
@ -200,13 +229,13 @@ export default function OffersTable({
} }
return ( return (
<thead className="text-slate-700"> <thead className="font-semibold">
<tr className="divide-x divide-slate-200"> <tr className="divide-x divide-slate-200">
{columns.map((header, index) => ( {columns.map((header, index) => (
<th <th
key={header} key={header}
className={clsx( className={clsx(
'bg-slate-100 py-3 px-4', 'whitespace-nowrap bg-slate-100 py-3 px-4',
// Make last column sticky. // Make last column sticky.
index === columns.length - 1 && index === columns.length - 1 &&
'sticky right-0 drop-shadow md:drop-shadow-none', 'sticky right-0 drop-shadow md:drop-shadow-none',
@ -235,7 +264,7 @@ export default function OffersTable({
</div> </div>
) : ( ) : (
<div className="overflow-x-auto text-slate-600"> <div className="overflow-x-auto text-slate-600">
<table className="w-full divide-y divide-slate-200 border-y border-slate-200 text-left"> <table className="w-full divide-y divide-slate-200 border-y border-slate-200 text-left text-xs text-slate-700 sm:text-sm md:text-base">
{renderHeader()} {renderHeader()}
<tbody> <tbody>
{offers.map((offer) => ( {offers.map((offer) => (

@ -26,7 +26,7 @@ export default function OffersTablePagination({
<div className="mb-2 text-sm font-normal text-slate-500 md:mb-0"> <div className="mb-2 text-sm font-normal text-slate-500 md:mb-0">
Showing Showing
<span className="font-semibold text-slate-900"> <span className="font-semibold text-slate-900">
{` ${startNumber} - ${endNumber} `} {` ${endNumber > 0 ? startNumber : 0} - ${endNumber} `}
</span> </span>
{`of `} {`of `}
<span className="font-semibold text-slate-900"> <span className="font-semibold text-slate-900">

@ -36,25 +36,24 @@ export const OfferTableYoeOptions = [
export const OfferTableFilterOptions = [ export const OfferTableFilterOptions = [
{ {
label: 'Latest Submitted', label: 'Latest Submitted',
value: 'latest-submitted', value: '-monthYearReceived',
}, },
{ {
label: 'Highest Salary', label: 'Highest Salary',
value: 'highest-salary', value: '-totalCompensation',
}, },
{ {
label: 'Highest YOE first', label: 'Highest YOE first',
value: 'highest-yoe-first', value: '-totalYoe',
}, },
{ {
label: 'Lowest YOE first', label: 'Lowest YOE first',
value: 'lowest-yoe-first', value: '+totalYoe',
}, },
]; ];
export const OfferTableSortBy: Record<string, string> = { export type OfferTableSortByType =
'highest-salary': '-totalCompensation', | '-monthYearReceived'
'highest-yoe-first': '-totalYoe', | '-totalCompensation'
'latest-submitted': '-monthYearReceived', | '-totalYoe'
'lowest-yoe-first': '+totalYoe', | '+totalYoe';
};

@ -4,27 +4,6 @@ import type { MonthYear } from '~/components/shared/MonthYearPicker';
import type { Location } from '~/types/offers'; import type { Location } from '~/types/offers';
export const HOME_URL = '/offers';
/*
* Offer Profile
*/
export const JobTypeLabel = {
FULLTIME: 'Full-time',
INTERN: 'Internship',
};
export enum EducationBackgroundType {
Bachelor = 'Bachelor',
Diploma = 'Diploma',
Masters = 'Masters',
PhD = 'PhD',
Professional = 'Professional',
Secondary = 'Secondary',
SelfTaught = 'Self-taught',
}
export type OffersProfilePostData = { export type OffersProfilePostData = {
background: BackgroundPostData; background: BackgroundPostData;
id?: string; id?: string;

@ -0,0 +1,29 @@
export default function ResumeSubmissionGuidelines() {
return (
<div className="rounded-lg border border-slate-200 bg-slate-50 p-5">
<div className="prose text-sm">
<h2 className="mt-0 text-xl font-medium">Submission Guidelines</h2>
<p>
Before submitting your resume for review, please review and
acknowledge our{' '}
<span className="font-medium">submission guidelines</span> stated
below.
</p>
<ul>
<li>
Ensure that you do not divulge any of your{' '}
<span className="font-medium">personal particulars</span>.
</li>
<li>
Ensure that you do not divulge any{' '}
<span className="font-medium">
company's proprietary and confidential information
</span>
.
</li>
<li>Proofread your resumes for grammatical/spelling errors.</li>
</ul>
</div>
</div>
);
}

@ -1,29 +0,0 @@
export default function SubmissionGuidelines() {
return (
<div className="text-left text-sm text-slate-700">
<h2 className="mb-2 text-xl font-medium">Submission Guidelines</h2>
<p>
Before you submit, please review and acknowledge our
<span className="font-bold"> submission guidelines </span>
stated below.
</p>
<p>
<span className="text-lg font-bold"> </span>
Ensure that you do not divulge any of your{' '}
<span className="font-bold">personal particulars</span>.
</p>
<p>
<span className="text-lg font-bold"> </span>
Ensure that you do not divulge any{' '}
<span className="font-bold">
company's proprietary and confidential information
</span>
.
</p>
<p>
<span className="text-lg font-bold"> </span>
Proof-read your resumes to look for grammatical/spelling errors.
</p>
</div>
);
}

@ -87,6 +87,7 @@ const analysisOfferDtoMapper = (
background?.experiences background?.experiences
?.filter((exp) => exp.company != null) ?.filter((exp) => exp.company != null)
.map((exp) => exp.company?.name ?? '') ?? [], .map((exp) => exp.company?.name ?? '') ?? [],
profileId: offer.profileId,
profileName, profileName,
title: title:
offer.jobType === JobType.FULLTIME offer.jobType === JobType.FULLTIME
@ -95,7 +96,10 @@ const analysisOfferDtoMapper = (
totalYoe: background?.totalYoe ?? -1, totalYoe: background?.totalYoe ?? -1,
}; };
if (offer.offersFullTime?.totalCompensation) { if (
offer.offersFullTime?.totalCompensation &&
offer.jobType === JobType.FULLTIME
) {
analysisOfferDto.income.value = analysisOfferDto.income.value =
offer.offersFullTime.totalCompensation.value; offer.offersFullTime.totalCompensation.value;
analysisOfferDto.income.currency = analysisOfferDto.income.currency =
@ -105,7 +109,10 @@ const analysisOfferDtoMapper = (
offer.offersFullTime.totalCompensation.baseValue; offer.offersFullTime.totalCompensation.baseValue;
analysisOfferDto.income.baseCurrency = analysisOfferDto.income.baseCurrency =
offer.offersFullTime.totalCompensation.baseCurrency; offer.offersFullTime.totalCompensation.baseCurrency;
} else if (offer.offersIntern?.monthlySalary) { } else if (
offer.offersIntern?.monthlySalary &&
offer.jobType === JobType.INTERN
) {
analysisOfferDto.income.value = offer.offersIntern.monthlySalary.value; analysisOfferDto.income.value = offer.offersIntern.monthlySalary.value;
analysisOfferDto.income.currency = analysisOfferDto.income.currency =
offer.offersIntern.monthlySalary.currency; offer.offersIntern.monthlySalary.currency;
@ -126,7 +133,14 @@ const analysisOfferDtoMapper = (
const analysisUnitDtoMapper = ( const analysisUnitDtoMapper = (
analysisUnit: OffersAnalysisUnit & { analysisUnit: OffersAnalysisUnit & {
company: Company; analysedOffer: OffersOffer & {
company: Company;
offersFullTime:
| (OffersFullTime & { totalCompensation: OffersCurrency })
| null;
offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null;
profile: OffersProfile & { background: OffersBackground | null };
};
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -153,15 +167,51 @@ const analysisUnitDtoMapper = (
>; >;
}, },
) => { ) => {
const analysisDto: AnalysisUnit = { const { analysedOffer } = analysisUnit;
companyName: analysisUnit.company.name, const { jobType } = analysedOffer;
const analysisUnitDto: AnalysisUnit = {
companyId: analysedOffer.companyId,
companyName: analysedOffer.company.name,
income: valuationDtoMapper({
baseCurrency: '',
baseValue: -1,
currency: '',
id: '',
value: -1,
}),
jobType,
noOfOffers: analysisUnit.noOfSimilarOffers, noOfOffers: analysisUnit.noOfSimilarOffers,
percentile: analysisUnit.percentile, percentile: analysisUnit.percentile,
title:
jobType === JobType.FULLTIME && analysedOffer.offersFullTime != null
? analysedOffer.offersFullTime.title
: jobType === JobType.INTERN && analysedOffer.offersIntern != null
? analysedOffer.offersIntern.title
: '',
topPercentileOffers: analysisUnit.topSimilarOffers.map((offer) => topPercentileOffers: analysisUnit.topSimilarOffers.map((offer) =>
analysisOfferDtoMapper(offer), analysisOfferDtoMapper(offer),
), ),
totalYoe: analysisUnit.analysedOffer.profile.background?.totalYoe ?? 0,
}; };
return analysisDto;
if (
analysedOffer.offersFullTime &&
analysedOffer.jobType === JobType.FULLTIME
) {
analysisUnitDto.income = valuationDtoMapper(
analysedOffer.offersFullTime.totalCompensation,
);
} else if (
analysedOffer.offersIntern &&
analysedOffer.jobType === JobType.INTERN
) {
analysisUnitDto.income = valuationDtoMapper(
analysedOffer.offersIntern.monthlySalary,
);
}
return analysisUnitDto;
}; };
const analysisHighestOfferDtoMapper = ( const analysisHighestOfferDtoMapper = (
@ -190,7 +240,16 @@ export const profileAnalysisDtoMapper = (
| (OffersAnalysis & { | (OffersAnalysis & {
companyAnalysis: Array< companyAnalysis: Array<
OffersAnalysisUnit & { OffersAnalysisUnit & {
company: Company; analysedOffer: OffersOffer & {
company: Company;
offersFullTime:
| (OffersFullTime & { totalCompensation: OffersCurrency })
| null;
offersIntern:
| (OffersIntern & { monthlySalary: OffersCurrency })
| null;
profile: OffersProfile & { background: OffersBackground | null };
};
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -220,7 +279,16 @@ export const profileAnalysisDtoMapper = (
} }
>; >;
overallAnalysis: OffersAnalysisUnit & { overallAnalysis: OffersAnalysisUnit & {
company: Company; analysedOffer: OffersOffer & {
company: Company;
offersFullTime:
| (OffersFullTime & { totalCompensation: OffersCurrency })
| null;
offersIntern:
| (OffersIntern & { monthlySalary: OffersCurrency })
| null;
profile: OffersProfile & { background: OffersBackground | null };
};
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -369,13 +437,15 @@ export const experienceDtoMapper = (
experience.location != null experience.location != null
? locationDtoMapper(experience.location) ? locationDtoMapper(experience.location)
: null, : null,
monthlySalary: experience.monthlySalary monthlySalary:
? valuationDtoMapper(experience.monthlySalary) experience.monthlySalary && experience.jobType === JobType.INTERN
: null, ? valuationDtoMapper(experience.monthlySalary)
: null,
title: experience.title, title: experience.title,
totalCompensation: experience.totalCompensation totalCompensation:
? valuationDtoMapper(experience.totalCompensation) experience.totalCompensation && experience.jobType === JobType.FULLTIME
: null, ? valuationDtoMapper(experience.totalCompensation)
: null,
}; };
return experienceDto; return experienceDto;
}; };
@ -460,11 +530,11 @@ export const profileOfferDtoMapper = (
location: locationDtoMapper(offer.location), location: locationDtoMapper(offer.location),
monthYearReceived: offer.monthYearReceived, monthYearReceived: offer.monthYearReceived,
negotiationStrategy: offer.negotiationStrategy, negotiationStrategy: offer.negotiationStrategy,
offersFullTime: offer.offersFullTime, offersFullTime: null,
offersIntern: offer.offersIntern, offersIntern: null,
}; };
if (offer.offersFullTime) { if (offer.offersFullTime && offer.jobType === JobType.FULLTIME) {
profileOfferDto.offersFullTime = { profileOfferDto.offersFullTime = {
baseSalary: baseSalary:
offer.offersFullTime?.baseSalary != null offer.offersFullTime?.baseSalary != null
@ -485,7 +555,7 @@ export const profileOfferDtoMapper = (
offer.offersFullTime.totalCompensation, offer.offersFullTime.totalCompensation,
), ),
}; };
} else if (offer.offersIntern) { } else if (offer.offersIntern && offer.jobType === JobType.INTERN) {
profileOfferDto.offersIntern = { profileOfferDto.offersIntern = {
id: offer.offersIntern.id, id: offer.offersIntern.id,
internshipCycle: offer.offersIntern.internshipCycle, internshipCycle: offer.offersIntern.internshipCycle,
@ -504,7 +574,18 @@ export const profileDtoMapper = (
| (OffersAnalysis & { | (OffersAnalysis & {
companyAnalysis: Array< companyAnalysis: Array<
OffersAnalysisUnit & { OffersAnalysisUnit & {
company: Company; analysedOffer: OffersOffer & {
company: Company;
offersFullTime:
| (OffersFullTime & { totalCompensation: OffersCurrency })
| null;
offersIntern:
| (OffersIntern & { monthlySalary: OffersCurrency })
| null;
profile: OffersProfile & {
background: OffersBackground | null;
};
};
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -536,7 +617,16 @@ export const profileDtoMapper = (
} }
>; >;
overallAnalysis: OffersAnalysisUnit & { overallAnalysis: OffersAnalysisUnit & {
company: Company; analysedOffer: OffersOffer & {
company: Company;
offersFullTime:
| (OffersFullTime & { totalCompensation: OffersCurrency })
| null;
offersIntern:
| (OffersIntern & { monthlySalary: OffersCurrency })
| null;
profile: OffersProfile & { background: OffersBackground | null };
};
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -701,30 +791,27 @@ export const dashboardOfferDtoMapper = (
totalYoe: offer.profile.background?.totalYoe ?? -1, totalYoe: offer.profile.background?.totalYoe ?? -1,
}; };
if (offer.offersFullTime) { if (offer.offersFullTime && offer.jobType === JobType.FULLTIME) {
dashboardOfferDto.income = valuationDtoMapper( dashboardOfferDto.income = valuationDtoMapper(
offer.offersFullTime.totalCompensation, offer.offersFullTime.totalCompensation,
); );
if (offer.offersFullTime.baseSalary) { if (offer.offersFullTime.baseSalary) {
dashboardOfferDto.baseSalary = valuationDtoMapper( dashboardOfferDto.baseSalary = valuationDtoMapper(
offer.offersFullTime.baseSalary offer.offersFullTime.baseSalary,
); );
} }
if (offer.offersFullTime.bonus) { if (offer.offersFullTime.bonus) {
dashboardOfferDto.bonus = valuationDtoMapper( dashboardOfferDto.bonus = valuationDtoMapper(offer.offersFullTime.bonus);
offer.offersFullTime.bonus
);
} }
if (offer.offersFullTime.stocks) { if (offer.offersFullTime.stocks) {
dashboardOfferDto.stocks = valuationDtoMapper( dashboardOfferDto.stocks = valuationDtoMapper(
offer.offersFullTime.stocks offer.offersFullTime.stocks,
); );
} }
} else if (offer.offersIntern) { } else if (offer.offersIntern && offer.jobType === JobType.INTERN) {
dashboardOfferDto.income = valuationDtoMapper( dashboardOfferDto.income = valuationDtoMapper(
offer.offersIntern.monthlySalary, offer.offersIntern.monthlySalary,
); );
@ -736,12 +823,12 @@ export const dashboardOfferDtoMapper = (
export const getOffersResponseMapper = ( export const getOffersResponseMapper = (
data: Array<DashboardOffer>, data: Array<DashboardOffer>,
paging: Paging, paging: Paging,
jobType: JobType jobType: JobType,
) => { ) => {
const getOffersResponse: GetOffersResponse = { const getOffersResponse: GetOffersResponse = {
data, data,
jobType, jobType,
paging paging,
}; };
return getOffersResponse; return getOffersResponse;
}; };
@ -817,7 +904,10 @@ const userProfileOfferDtoMapper = (
: offer.offersIntern?.title ?? '', : offer.offersIntern?.title ?? '',
}; };
if (offer.offersFullTime?.totalCompensation) { if (
offer.offersFullTime?.totalCompensation &&
offer.jobType === JobType.FULLTIME
) {
mappedOffer.income.value = offer.offersFullTime.totalCompensation.value; mappedOffer.income.value = offer.offersFullTime.totalCompensation.value;
mappedOffer.income.currency = mappedOffer.income.currency =
offer.offersFullTime.totalCompensation.currency; offer.offersFullTime.totalCompensation.currency;
@ -826,7 +916,10 @@ const userProfileOfferDtoMapper = (
offer.offersFullTime.totalCompensation.baseValue; offer.offersFullTime.totalCompensation.baseValue;
mappedOffer.income.baseCurrency = mappedOffer.income.baseCurrency =
offer.offersFullTime.totalCompensation.baseCurrency; offer.offersFullTime.totalCompensation.baseCurrency;
} else if (offer.offersIntern?.monthlySalary) { } else if (
offer.offersIntern?.monthlySalary &&
offer.jobType === JobType.INTERN
) {
mappedOffer.income.value = offer.offersIntern.monthlySalary.value; mappedOffer.income.value = offer.offersIntern.monthlySalary.value;
mappedOffer.income.currency = offer.offersIntern.monthlySalary.currency; mappedOffer.income.currency = offer.offersIntern.monthlySalary.currency;
mappedOffer.income.id = offer.offersIntern.monthlySalary.id; mappedOffer.income.id = offer.offersIntern.monthlySalary.id;

@ -8,12 +8,12 @@ import {
UsersIcon, UsersIcon,
} from '@heroicons/react/24/outline'; } from '@heroicons/react/24/outline';
import { HOME_URL } from '~/components/offers/constants';
import offersAnalysis from '~/components/offers/features/images/offers-analysis.png'; import offersAnalysis from '~/components/offers/features/images/offers-analysis.png';
import offersBrowse from '~/components/offers/features/images/offers-browse.png'; import offersBrowse from '~/components/offers/features/images/offers-browse.png';
import offersProfile from '~/components/offers/features/images/offers-profile.png'; import offersProfile from '~/components/offers/features/images/offers-profile.png';
import LeftTextCard from '~/components/offers/features/LeftTextCard'; import LeftTextCard from '~/components/offers/features/LeftTextCard';
import RightTextCard from '~/components/offers/features/RightTextCard'; import RightTextCard from '~/components/offers/features/RightTextCard';
import { HOME_URL } from '~/components/offers/types';
const features = [ const features = [
{ {

@ -9,14 +9,23 @@ import CompaniesTypeahead from '~/components/shared/CompaniesTypeahead';
import Container from '~/components/shared/Container'; import Container from '~/components/shared/Container';
import CountriesTypeahead from '~/components/shared/CountriesTypeahead'; import CountriesTypeahead from '~/components/shared/CountriesTypeahead';
import type { JobTitleType } from '~/components/shared/JobTitles'; import type { JobTitleType } from '~/components/shared/JobTitles';
import { JobTitleLabels } from '~/components/shared/JobTitles';
import JobTitlesTypeahead from '~/components/shared/JobTitlesTypahead'; import JobTitlesTypeahead from '~/components/shared/JobTitlesTypahead';
import { useSearchParamSingle } from '~/utils/offers/useSearchParam';
export default function OffersHomePage() { export default function OffersHomePage() {
const [jobTitleFilter, setJobTitleFilter] = useState<JobTitleType | ''>('');
const [companyFilter, setCompanyFilter] = useState('');
const [countryFilter, setCountryFilter] = useState(''); const [countryFilter, setCountryFilter] = useState('');
const { event: gaEvent } = useGoogleAnalytics(); const { event: gaEvent } = useGoogleAnalytics();
const [selectedCompanyName, setSelectedCompanyName] =
useSearchParamSingle('companyName');
const [selectedCompanyId, setSelectedCompanyId] =
useSearchParamSingle('companyId');
const [selectedJobTitleId, setSelectedJobTitleId] =
useSearchParamSingle<JobTitleType | null>('jobTitleId');
return ( return (
<main className="flex-1 overflow-y-auto"> <main className="flex-1 overflow-y-auto">
<Banner size="sm"> <Banner size="sm">
@ -59,23 +68,32 @@ export default function OffersHomePage() {
offers. offers.
</div> </div>
</div> </div>
<div className="mt-6 flex flex-col items-center justify-center space-y-2 text-base text-slate-700 sm:mt-10 sm:flex-row sm:space-y-0 sm:space-x-4 sm:text-lg"> <div className="mt-6 flex flex-col items-center justify-center space-y-2 text-sm text-slate-700 sm:mt-10 sm:flex-row sm:space-y-0 sm:space-x-4 sm:text-lg">
<span>Viewing offers for</span> <span>Viewing offers for</span>
<div className="flex items-center space-x-4"> <div className="flex items-center space-x-4">
<JobTitlesTypeahead <JobTitlesTypeahead
isLabelHidden={true} isLabelHidden={true}
placeholder="All Job Titles" placeholder="All Job Titles"
textSize="inherit" textSize="inherit"
value={
selectedJobTitleId
? {
id: selectedJobTitleId,
label: JobTitleLabels[selectedJobTitleId as JobTitleType],
value: selectedJobTitleId,
}
: null
}
onSelect={(option) => { onSelect={(option) => {
if (option) { if (option) {
setJobTitleFilter(option.value as JobTitleType); setSelectedJobTitleId(option.id as JobTitleType);
gaEvent({ gaEvent({
action: `offers.table_filter_job_title_${option.value}`, action: `offers.table_filter_job_title_${option.value}`,
category: 'engagement', category: 'engagement',
label: 'Filter by job title', label: 'Filter by job title',
}); });
} else { } else {
setJobTitleFilter(''); setSelectedJobTitleId(null);
} }
}} }}
/> />
@ -84,16 +102,27 @@ export default function OffersHomePage() {
isLabelHidden={true} isLabelHidden={true}
placeholder="All Companies" placeholder="All Companies"
textSize="inherit" textSize="inherit"
value={
selectedCompanyName
? {
id: selectedCompanyId,
label: selectedCompanyName,
value: selectedCompanyId,
}
: null
}
onSelect={(option) => { onSelect={(option) => {
if (option) { if (option) {
setCompanyFilter(option.value); setSelectedCompanyId(option.id);
setSelectedCompanyName(option.label);
gaEvent({ gaEvent({
action: `offers.table_filter_company_${option.value}`, action: `offers.table_filter_company_${option.value}`,
category: 'engagement', category: 'engagement',
label: 'Filter by company', label: 'Filter by company',
}); });
} else { } else {
setCompanyFilter(''); setSelectedCompanyId('');
setSelectedCompanyName('');
} }
}} }}
/> />
@ -102,9 +131,10 @@ export default function OffersHomePage() {
</div> </div>
<Container className="pb-20 pt-10"> <Container className="pb-20 pt-10">
<OffersTable <OffersTable
companyFilter={companyFilter} companyFilter={selectedCompanyId}
companyName={selectedCompanyName}
countryFilter={countryFilter} countryFilter={countryFilter}
jobTitleFilter={jobTitleFilter} jobTitleFilter={selectedJobTitleId ?? ''}
/> />
</Container> </Container>
</main> </main>

@ -6,6 +6,7 @@ import { Spinner, useToast } from '@tih/ui';
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
import { ProfileDetailTab } from '~/components/offers/constants'; import { ProfileDetailTab } from '~/components/offers/constants';
import { HOME_URL } from '~/components/offers/constants';
import ProfileComments from '~/components/offers/profile/ProfileComments'; import ProfileComments from '~/components/offers/profile/ProfileComments';
import ProfileDetails from '~/components/offers/profile/ProfileDetails'; import ProfileDetails from '~/components/offers/profile/ProfileDetails';
import ProfileHeader from '~/components/offers/profile/ProfileHeader'; import ProfileHeader from '~/components/offers/profile/ProfileHeader';
@ -13,7 +14,6 @@ import type {
BackgroundDisplayData, BackgroundDisplayData,
OfferDisplayData, OfferDisplayData,
} from '~/components/offers/types'; } from '~/components/offers/types';
import { HOME_URL } from '~/components/offers/types';
import type { JobTitleType } from '~/components/shared/JobTitles'; import type { JobTitleType } from '~/components/shared/JobTitles';
import { getLabelForJobTitleType } from '~/components/shared/JobTitles'; import { getLabelForJobTitleType } from '~/components/shared/JobTitles';
@ -79,6 +79,7 @@ export default function OfferProfile() {
jobTitle: getLabelForJobTitleType( jobTitle: getLabelForJobTitleType(
res.offersFullTime.title as JobTitleType, res.offersFullTime.title as JobTitleType,
), ),
jobType: res.jobType,
location: res.location, location: res.location,
negotiationStrategy: res.negotiationStrategy, negotiationStrategy: res.negotiationStrategy,
otherComment: res.comments, otherComment: res.comments,
@ -99,6 +100,7 @@ export default function OfferProfile() {
jobTitle: getLabelForJobTitleType( jobTitle: getLabelForJobTitleType(
res.offersIntern!.title as JobTitleType, res.offersIntern!.title as JobTitleType,
), ),
jobType: res.jobType,
location: res.location, location: res.location,
monthlySalary: convertMoneyToString( monthlySalary: convertMoneyToString(
res.offersIntern!.monthlySalary, res.offersIntern!.monthlySalary,
@ -187,60 +189,54 @@ export default function OfferProfile() {
} }
} }
return ( return getProfileQuery.isError ? (
<> <div className="flex w-full justify-center">
{getProfileQuery.isError && ( <Error statusCode={404} title="Requested profile does not exist." />
<div className="flex w-full justify-center"> </div>
<Error statusCode={404} title="Requested profile does not exist" /> ) : getProfileQuery.isLoading ? (
<div className="flex h-screen w-screen">
<div className="m-auto mx-auto w-screen justify-center font-medium text-slate-500">
<Spinner display="block" size="lg" />
<div className="text-center">Loading...</div>
</div>
</div>
) : (
<div className="w-full divide-x lg:flex">
<div className="divide-y lg:w-2/3">
<div className="h-fit">
<ProfileHeader
background={background}
handleDelete={handleDelete}
isEditable={isEditable}
isLoading={getProfileQuery.isLoading}
selectedTab={selectedTab}
setSelectedTab={setSelectedTab}
/>
</div> </div>
)} <div>
{getProfileQuery.isLoading && ( <ProfileDetails
<div className="flex h-screen w-screen"> analysis={analysis}
<div className="m-auto mx-auto w-screen justify-center font-medium text-slate-500"> background={background}
<Spinner display="block" size="lg" /> isEditable={isEditable}
<div className="text-center">Loading...</div> isLoading={getProfileQuery.isLoading}
</div> offers={offers}
profileId={offerProfileId as string}
selectedTab={selectedTab}
/>
</div> </div>
)} </div>
{!getProfileQuery.isLoading && !getProfileQuery.isError && ( <div
<div className="w-full divide-x lg:flex"> className="bg-white lg:fixed lg:right-0 lg:bottom-0 lg:w-1/3"
<div className="divide-y lg:w-2/3"> style={{ top: 64 }}>
<div className="h-fit"> <ProfileComments
<ProfileHeader isDisabled={deleteMutation.isLoading}
background={background} isEditable={isEditable}
handleDelete={handleDelete} isLoading={getProfileQuery.isLoading}
isEditable={isEditable} profileId={offerProfileId as string}
isLoading={getProfileQuery.isLoading} profileName={background?.profileName}
selectedTab={selectedTab} token={token as string}
setSelectedTab={setSelectedTab} />
/> </div>
</div> </div>
<div className="pb-4">
<ProfileDetails
analysis={analysis}
background={background}
isEditable={isEditable}
isLoading={getProfileQuery.isLoading}
offers={offers}
profileId={offerProfileId as string}
selectedTab={selectedTab}
/>
</div>
</div>
<div
className="bg-white lg:fixed lg:right-0 lg:bottom-0 lg:w-1/3"
style={{ top: 64 }}>
<ProfileComments
isDisabled={deleteMutation.isLoading}
isEditable={isEditable}
isLoading={getProfileQuery.isLoading}
profileId={offerProfileId as string}
profileName={background?.profileName}
token={token as string}
/>
</div>
</div>
)}
</>
); );
} }

@ -1,46 +1,56 @@
import Error from 'next/error';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { useSession } from 'next-auth/react';
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/20/solid'; import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/20/solid';
import { EyeIcon } from '@heroicons/react/24/outline'; import { EyeIcon } from '@heroicons/react/24/outline';
import { Button, Spinner } from '@tih/ui'; import { Button, Spinner } from '@tih/ui';
import type { BreadcrumbStep } from '~/components/offers/Breadcrumb'; import type { BreadcrumbStep } from '~/components/offers/Breadcrumbs';
import { Breadcrumbs } from '~/components/offers/Breadcrumb'; import { Breadcrumbs } from '~/components/offers/Breadcrumbs';
import OffersProfileSave from '~/components/offers/offersSubmission/OffersProfileSave'; import OffersProfileSave from '~/components/offers/offersSubmission/OffersProfileSave';
import OffersSubmissionAnalysis from '~/components/offers/offersSubmission/OffersSubmissionAnalysis'; import OffersSubmissionAnalysis from '~/components/offers/offersSubmission/OffersSubmissionAnalysis';
import { getProfilePath } from '~/utils/offers/link'; import { getProfilePath } from '~/utils/offers/link';
import { trpc } from '~/utils/trpc'; import { trpc } from '~/utils/trpc';
import type { ProfileAnalysis } from '~/types/offers';
export default function OffersSubmissionResult() { export default function OffersSubmissionResult() {
const router = useRouter(); const router = useRouter();
let { offerProfileId, token = '' } = router.query; let { offerProfileId, token = '' } = router.query;
offerProfileId = offerProfileId as string; offerProfileId = offerProfileId as string;
token = token as string; token = token as string;
const [step, setStep] = useState(0); const [step, setStep] = useState(0);
const [analysis, setAnalysis] = useState<ProfileAnalysis | null>(null); const { data: session } = useSession();
const pageRef = useRef<HTMLDivElement>(null); const pageRef = useRef<HTMLDivElement>(null);
const scrollToTop = () => const scrollToTop = () =>
pageRef.current?.scrollTo({ behavior: 'smooth', top: 0 }); pageRef.current?.scrollTo({ behavior: 'smooth', top: 0 });
// TODO: Check if the token is valid before showing this page const checkToken = trpc.useQuery([
const getAnalysis = trpc.useQuery( 'offers.profile.isValidToken',
['offers.analysis.get', { profileId: offerProfileId }], { profileId: offerProfileId, token },
{ ]);
onSuccess(data) {
setAnalysis(data); const getAnalysis = trpc.useQuery([
}, 'offers.analysis.get',
}, { profileId: offerProfileId },
); ]);
const isSavedQuery = trpc.useQuery([
`offers.profile.isSaved`,
{ profileId: offerProfileId, userId: session?.user?.id },
]);
const steps = [ const steps = [
<OffersProfileSave key={0} profileId={offerProfileId} token={token} />, <OffersProfileSave
key={0}
isSavedQuery={isSavedQuery}
profileId={offerProfileId}
token={token}
/>,
<OffersSubmissionAnalysis <OffersSubmissionAnalysis
key={1} key={1}
analysis={analysis} analysis={getAnalysis.data}
isError={getAnalysis.isError} isError={getAnalysis.isError}
isLoading={getAnalysis.isLoading} isLoading={getAnalysis.isLoading}
/>, />,
@ -67,65 +77,67 @@ export default function OffersSubmissionResult() {
scrollToTop(); scrollToTop();
}, [step]); }, [step]);
return ( return checkToken.isLoading || getAnalysis.isLoading ? (
<> <div className="flex h-screen w-screen">
{getAnalysis.isLoading && ( <div className="m-auto mx-auto w-screen justify-center font-medium text-slate-500">
<div className="flex h-screen w-screen"> <Spinner display="block" size="lg" />
<div className="m-auto mx-auto w-screen justify-center font-medium text-slate-500"> <div className="text-center">Loading...</div>
<Spinner display="block" size="lg" /> </div>
<div className="text-center">Loading...</div> </div>
) : checkToken.isError || getAnalysis.isError ? (
<Error statusCode={404} title="Error loading page" />
) : checkToken.isSuccess && !checkToken.data ? (
<Error
statusCode={403}
title="You do not have permissions to access this page"
/>
) : (
<div ref={pageRef} className="w-full">
<div className="flex justify-center">
<div className="block w-full max-w-screen-md overflow-hidden rounded-lg sm:shadow-lg md:my-10">
<div className="flex justify-center bg-slate-100 px-4 py-4 sm:px-6 lg:px-8">
<Breadcrumbs
currentStep={step}
setStep={setStep}
steps={breadcrumbSteps}
/>
</div> </div>
</div> <div className="bg-white p-6 sm:p-10">
)} {steps[step]}
{!getAnalysis.isLoading && ( {step === 0 && (
<div ref={pageRef} className="w-full"> <div className="flex justify-end">
<div className="flex justify-center"> <Button
<div className="block w-full max-w-screen-md overflow-hidden rounded-lg sm:shadow-lg md:my-10"> disabled={false}
<div className="flex justify-center bg-slate-100 px-4 py-4 sm:px-6 lg:px-8"> icon={ArrowRightIcon}
<Breadcrumbs label="Next"
currentStep={step} variant="primary"
setStep={setStep} onClick={() => setStep(step + 1)}
steps={breadcrumbSteps}
/> />
</div> </div>
<div className="bg-white p-6 sm:p-10"> )}
{steps[step]} {step === 1 && (
{step === 0 && ( <div className="flex items-center justify-between">
<div className="flex justify-end"> <Button
<Button addonPosition="start"
disabled={false} icon={ArrowLeftIcon}
icon={ArrowRightIcon} label="Previous"
label="Next" variant="secondary"
variant="primary" onClick={() => setStep(step - 1)}
onClick={() => setStep(step + 1)} />
/> <Button
</div> href={getProfilePath(
)} offerProfileId as string,
{step === 1 && ( token as string,
<div className="flex items-center justify-between"> )}
<Button icon={EyeIcon}
addonPosition="start" label="View your profile"
icon={ArrowLeftIcon} variant="primary"
label="Previous" />
variant="secondary"
onClick={() => setStep(step - 1)}
/>
<Button
href={getProfilePath(
offerProfileId as string,
token as string,
)}
icon={EyeIcon}
label="View your profile"
variant="primary"
/>
</div>
)}
</div> </div>
</div> )}
</div> </div>
</div> </div>
)} </div>
</> </div>
); );
} }

@ -20,7 +20,8 @@ import {
} from '@tih/ui'; } from '@tih/ui';
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
import SubmissionGuidelines from '~/components/resumes/submit-form/SubmissionGuidelines'; import ResumeSubmissionGuidelines from '~/components/resumes/submit-form/ResumeSubmissionGuidelines';
import Container from '~/components/shared/Container';
import loginPageHref from '~/components/shared/loginPageHref'; import loginPageHref from '~/components/shared/loginPageHref';
import { RESUME_STORAGE_KEY } from '~/constants/file-storage-keys'; import { RESUME_STORAGE_KEY } from '~/constants/file-storage-keys';
@ -239,203 +240,206 @@ export default function SubmitResumeForm({
<Head> <Head>
<title>Upload a Resume</title> <title>Upload a Resume</title>
</Head> </Head>
{status === 'loading' && ( <Container variant="xs">
<div className="w-full pt-4"> {status === 'loading' && (
{' '} <div className="w-full pt-4">
<Spinner display="block" size="lg" />{' '} <Spinner display="block" size="lg" />
</div> </div>
)} )}
{status === 'authenticated' && ( {status === 'authenticated' && (
<main className="flex-1"> <main className="flex-1">
<section <section
aria-labelledby="primary-heading" aria-labelledby="primary-heading"
className="flex h-full min-w-0 flex-1 flex-col lg:order-last"> className="flex h-full min-w-0 flex-1 flex-col lg:order-last">
{/* Reset Dialog component */} {/* Reset Dialog component */}
<Dialog <Dialog
isShown={isDialogShown} isShown={isDialogShown}
primaryButton={ primaryButton={
<Button <Button
display="block" display="block"
label="OK" label="OK"
variant="primary" variant="primary"
onClick={onClickResetDialog} onClick={onClickResetDialog}
/> />
}
secondaryButton={
<Button
display="block"
label="Cancel"
variant="tertiary"
onClick={() => setIsDialogShown(false)}
/>
}
title={
isNewForm
? 'Are you sure you want to clear?'
: 'Are you sure you want to leave?'
}
onClose={() => setIsDialogShown(false)}>
Note that your current input will not be saved!
</Dialog>
<form
className="mt-8 w-full max-w-screen-lg space-y-6 self-center rounded-lg bg-white p-10 shadow-lg"
onSubmit={handleSubmit(onSubmit)}>
<h1 className="mb-4 text-center text-2xl font-semibold">
{isNewForm ? 'Upload a resume' : 'Update details'}
</h1>
{/* Title Section */}
<TextInput
{...(register('title', { required: true }), {})}
defaultValue={initFormDetails?.title}
disabled={isLoading}
errorMessage={
errors.title?.message != null
? 'Title cannot be empty'
: undefined
} }
label="Title" secondaryButton={
placeholder={TITLE_PLACEHOLDER} <Button
required={true} display="block"
onChange={(val) => onValueChange('title', val)} label="Cancel"
/> variant="tertiary"
<div className="flex flex-wrap gap-6"> onClick={() => setIsDialogShown(false)}
<Select />
{...register('role', { required: true })} }
defaultValue={undefined} title={
isNewForm
? 'Are you sure you want to clear?'
: 'Are you sure you want to leave?'
}
onClose={() => setIsDialogShown(false)}>
Note that your current input will not be saved!
</Dialog>
<form
className="w-full space-y-6 self-center bg-white p-10 md:my-8 md:rounded-lg md:shadow-lg"
onSubmit={handleSubmit(onSubmit)}>
<h1 className="mb-8 text-2xl font-bold text-slate-900 sm:text-center sm:text-4xl">
{isNewForm ? 'Upload a resume' : 'Update details'}
</h1>
{/* Title Section */}
<TextInput
{...(register('title', { required: true }), {})}
defaultValue={initFormDetails?.title}
disabled={isLoading} disabled={isLoading}
label="Role" errorMessage={
options={ROLES} errors.title?.message != null
placeholder=" " ? 'Title cannot be empty'
: undefined
}
label="Title"
placeholder={TITLE_PLACEHOLDER}
required={true} required={true}
onChange={(val) => onValueChange('role', val)} onChange={(val) => onValueChange('title', val)}
/> />
<div className="flex flex-wrap gap-6">
<Select
{...register('role', { required: true })}
defaultValue={undefined}
disabled={isLoading}
label="Role"
options={ROLES}
placeholder=" "
required={true}
onChange={(val) => onValueChange('role', val)}
/>
<Select
{...register('experience', { required: true })}
disabled={isLoading}
label="Experience Level"
options={EXPERIENCES}
placeholder=" "
required={true}
onChange={(val) => onValueChange('experience', val)}
/>
</div>
<Select <Select
{...register('experience', { required: true })} {...register('location', { required: true })}
disabled={isLoading} disabled={isLoading}
label="Experience Level" label="Location"
options={EXPERIENCES} options={LOCATIONS}
placeholder=" " placeholder=" "
required={true} required={true}
onChange={(val) => onValueChange('experience', val)} onChange={(val) => onValueChange('location', val)}
/> />
</div> {/* Upload resume form */}
<Select {isNewForm && (
{...register('location', { required: true })} <div className="space-y-2">
disabled={isLoading} <p className="text-sm font-medium text-slate-700">
label="Location" Upload resume (PDF format)
options={LOCATIONS} <span aria-hidden="true" className="text-danger-500">
placeholder=" " {' '}
required={true} *
onChange={(val) => onValueChange('location', val)}
/>
{/* Upload resume form */}
{isNewForm && (
<div className="space-y-2">
<p className="text-sm font-medium text-slate-700">
Upload resume (PDF format)
<span aria-hidden="true" className="text-danger-500">
{' '}
*
</span>
</p>
<div
{...getRootProps()}
className={clsx(
fileUploadError
? 'border-danger-600'
: 'border-slate-300',
'cursor-pointer flex-col items-center space-y-1 rounded-md border-2 border-dashed bg-slate-100 py-4 px-4 text-center',
)}>
<input
{...register('file', { required: true })}
{...getInputProps()}
accept="application/pdf"
className="sr-only"
disabled={isLoading}
id="file-upload"
name="file-upload"
type="file"
/>
{resumeFile == null ? (
<ArrowUpCircleIcon className="text-primary-500 m-auto h-10 w-10" />
) : (
<p
className="hover:text-primary-600 cursor-pointer underline underline-offset-1"
onClick={onClickDownload}>
{resumeFile.name}
</p>
)}
<label
className="focus-within:ring-primary-500 cursor-pointer text-sm focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2"
htmlFor="file-upload">
<span className="font-medium">Drop file here</span>
<span className="mr-1 ml-1 font-light">or</span>
<span className="text-primary-600 hover:text-primary-400 font-medium">
{resumeFile == null ? 'Select file' : 'Replace file'}
</span> </span>
</label>
<p className="text-xs text-slate-500">
PDF up to {FILE_SIZE_LIMIT_MB}MB
</p> </p>
<div
{...getRootProps()}
className={clsx(
fileUploadError
? 'border-danger-600'
: 'border-slate-300',
'cursor-pointer flex-col items-center space-y-1 rounded-md border-2 border-dashed bg-slate-50 py-4 px-4 text-center',
)}>
<input
{...register('file', { required: true })}
{...getInputProps()}
accept="application/pdf"
className="sr-only"
disabled={isLoading}
id="file-upload"
name="file-upload"
type="file"
/>
{resumeFile == null ? (
<ArrowUpCircleIcon className="text-primary-500 m-auto h-10 w-10" />
) : (
<p
className="hover:text-primary-600 cursor-pointer underline underline-offset-1"
onClick={onClickDownload}>
{resumeFile.name}
</p>
)}
<label
className="focus-within:ring-primary-500 cursor-pointer text-sm focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2"
htmlFor="file-upload">
<span className="font-medium">Drop file here</span>
<span className="mr-1 ml-1 font-light">or</span>
<span className="text-primary-600 hover:text-primary-400 font-medium">
{resumeFile == null ? 'Select file' : 'Replace file'}
</span>
</label>
<p className="text-xs text-slate-500">
PDF up to {FILE_SIZE_LIMIT_MB}MB
</p>
</div>
{fileUploadError && (
<p className="text-danger-600 text-sm">
{fileUploadError}
</p>
)}
</div> </div>
{fileUploadError && ( )}
<p className="text-danger-600 text-sm">{fileUploadError}</p> {/* Additional Info Section */}
)} <TextArea
</div> {...(register('additionalInfo'),
)} { defaultValue: initFormDetails?.additionalInfo })}
{/* Additional Info Section */}
<TextArea
{...(register('additionalInfo'),
{ defaultValue: initFormDetails?.additionalInfo })}
disabled={isLoading}
label="Additional Information"
placeholder={ADDITIONAL_INFO_PLACEHOLDER}
onChange={(val) => onValueChange('additionalInfo', val)}
/>
{/* Submission Guidelines */}
{isNewForm && (
<>
<SubmissionGuidelines />
<CheckboxInput
{...register('isChecked', { required: true })}
disabled={isLoading}
errorMessage={
!errors.file && errors.isChecked
? 'Please tick the checkbox after reading through the guidelines.'
: undefined
}
label="I have read and will follow the guidelines stated."
onChange={(val) => {
if (val) {
clearErrors('isChecked');
}
setValue('isChecked', val);
}}
/>
</>
)}
{/* Clear and Submit Buttons */}
<div className="flex justify-end gap-4">
<Button
addonPosition="start"
disabled={isLoading}
label={isNewForm ? 'Clear' : 'Cancel'}
variant="tertiary"
onClick={onClickClear}
/>
<Button
addonPosition="start"
disabled={isLoading} disabled={isLoading}
isLoading={isLoading} label="Additional Information"
label="Submit" placeholder={ADDITIONAL_INFO_PLACEHOLDER}
type="submit" onChange={(val) => onValueChange('additionalInfo', val)}
variant="primary"
/> />
</div> {/* Submission Guidelines */}
</form> {isNewForm && (
</section> <div className="space-y-4">
</main> <ResumeSubmissionGuidelines />
)} <CheckboxInput
{...register('isChecked', { required: true })}
disabled={isLoading}
errorMessage={
!errors.file && errors.isChecked
? 'Please tick the checkbox after reading through the guidelines.'
: undefined
}
label="I have read and followed the above guidelines."
onChange={(val) => {
if (val) {
clearErrors('isChecked');
}
setValue('isChecked', val);
}}
/>
</div>
)}
{/* Clear and Submit Buttons */}
<div className="flex justify-end gap-4">
<Button
addonPosition="start"
disabled={isLoading}
label={isNewForm ? 'Clear' : 'Cancel'}
variant="tertiary"
onClick={onClickClear}
/>
<Button
addonPosition="start"
disabled={isLoading}
isLoading={isLoading}
label="Submit"
type="submit"
variant="primary"
/>
</div>
</form>
</section>
</main>
)}
</Container>
</> </>
); );
} }

@ -2,9 +2,10 @@ import { z } from 'zod';
import { TRPCError } from '@trpc/server'; import { TRPCError } from '@trpc/server';
import { profileAnalysisDtoMapper } from '~/mappers/offers-mappers'; import { profileAnalysisDtoMapper } from '~/mappers/offers-mappers';
import { analysisInclusion } from '~/utils/offers/analysis/analysisInclusion';
import { createRouter } from '../context'; import { createRouter } from '../context';
import { generateAnalysis } from '../../../utils/offers/analysisGeneration'; import { generateAnalysis } from '../../../utils/offers/analysis/analysisGeneration';
export const offersAnalysisRouter = createRouter() export const offersAnalysisRouter = createRouter()
.query('get', { .query('get', {
@ -13,139 +14,7 @@ export const offersAnalysisRouter = createRouter()
}), }),
async resolve({ ctx, input }) { async resolve({ ctx, input }) {
const analysis = await ctx.prisma.offersAnalysis.findFirst({ const analysis = await ctx.prisma.offersAnalysis.findFirst({
include: { include: analysisInclusion,
companyAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallHighestOffer: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
},
where: { where: {
profileId: input.profileId, profileId: input.profileId,
}, },

@ -8,6 +8,7 @@ import {
createOfferProfileResponseMapper, createOfferProfileResponseMapper,
profileDtoMapper, profileDtoMapper,
} from '~/mappers/offers-mappers'; } from '~/mappers/offers-mappers';
import { analysisInclusion } from '~/utils/offers/analysis/analysisInclusion';
import { baseCurrencyString } from '~/utils/offers/currency'; import { baseCurrencyString } from '~/utils/offers/currency';
import { convert } from '~/utils/offers/currency/currencyExchange'; import { convert } from '~/utils/offers/currency/currencyExchange';
import { import {
@ -165,139 +166,7 @@ export const offersProfileRouter = createRouter()
const result = await ctx.prisma.offersProfile.findFirst({ const result = await ctx.prisma.offersProfile.findFirst({
include: { include: {
analysis: { analysis: {
include: { include: analysisInclusion,
companyAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallHighestOffer: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
},
}, },
background: { background: {
include: { include: {
@ -972,7 +841,19 @@ export const offersProfileRouter = createRouter()
for (const exp of input.background.experiences) { for (const exp of input.background.experiences) {
if (exp.id) { if (exp.id) {
// Update existing experience const currentExp = await ctx.prisma.offersExperience.findFirst({
where: {
id: exp.id,
},
});
if (!currentExp) {
throw new trpc.TRPCError({
code: 'NOT_FOUND',
message: 'Experience does not exist',
});
}
await ctx.prisma.offersExperience.update({ await ctx.prisma.offersExperience.update({
data: { data: {
companyId: exp.companyId, // TODO: check if can change with connect or whether there is a difference companyId: exp.companyId, // TODO: check if can change with connect or whether there is a difference
@ -984,68 +865,159 @@ export const offersProfileRouter = createRouter()
id: exp.id, id: exp.id,
}, },
}); });
if (currentExp.jobType === exp.jobType) {
// Update existing experience
if (exp.monthlySalary) {
await ctx.prisma.offersExperience.update({
data: {
monthlySalary: {
upsert: {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
exp.monthlySalary.value,
exp.monthlySalary.currency,
baseCurrencyString,
),
currency: exp.monthlySalary.currency,
value: exp.monthlySalary.value,
},
update: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
exp.monthlySalary.value,
exp.monthlySalary.currency,
baseCurrencyString,
),
currency: exp.monthlySalary.currency,
value: exp.monthlySalary.value,
},
},
},
},
where: {
id: exp.id,
},
});
}
if (exp.monthlySalary) { if (exp.totalCompensation) {
await ctx.prisma.offersExperience.update({ await ctx.prisma.offersExperience.update({
data: { data: {
monthlySalary: { totalCompensation: {
upsert: { upsert: {
create: { create: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
exp.monthlySalary.value, exp.totalCompensation.value,
exp.monthlySalary.currency, exp.totalCompensation.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: exp.monthlySalary.currency, currency: exp.totalCompensation.currency,
value: exp.monthlySalary.value, value: exp.totalCompensation.value,
},
update: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
exp.totalCompensation.value,
exp.totalCompensation.currency,
baseCurrencyString,
),
currency: exp.totalCompensation.currency,
value: exp.totalCompensation.value,
},
}, },
update: { },
baseCurrency: baseCurrencyString, },
baseValue: await convert( where: {
exp.monthlySalary.value, id: exp.id,
exp.monthlySalary.currency, },
baseCurrencyString, });
), }
currency: exp.monthlySalary.currency, } else if (exp.jobType === JobType.INTERN) {
value: exp.monthlySalary.value, // Add 1 remove the other
if (exp.monthlySalary) {
await ctx.prisma.offersExperience.update({
data: {
monthlySalary: {
upsert: {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
exp.monthlySalary.value,
exp.monthlySalary.currency,
baseCurrencyString,
),
currency: exp.monthlySalary.currency,
value: exp.monthlySalary.value,
},
update: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
exp.monthlySalary.value,
exp.monthlySalary.currency,
baseCurrencyString,
),
currency: exp.monthlySalary.currency,
value: exp.monthlySalary.value,
},
}, },
}, },
}, },
where: {
id: exp.id,
},
});
}
await ctx.prisma.offersExperience.update({
data: {
totalCompensation: undefined,
totalCompensationId: null,
}, },
where: { where: {
id: exp.id, id: exp.id,
}, },
}); });
} } else if (exp.jobType === JobType.FULLTIME) {
if (exp.totalCompensation) {
if (exp.totalCompensation) { await ctx.prisma.offersExperience.update({
await ctx.prisma.offersExperience.update({ data: {
data: { totalCompensation: {
totalCompensation: { upsert: {
upsert: { create: {
create: { baseCurrency: baseCurrencyString,
baseCurrency: baseCurrencyString, baseValue: await convert(
baseValue: await convert( exp.totalCompensation.value,
exp.totalCompensation.value, exp.totalCompensation.currency,
exp.totalCompensation.currency, baseCurrencyString,
baseCurrencyString, ),
), currency: exp.totalCompensation.currency,
currency: exp.totalCompensation.currency, value: exp.totalCompensation.value,
value: exp.totalCompensation.value, },
}, update: {
update: { baseCurrency: baseCurrencyString,
baseCurrency: baseCurrencyString, baseValue: await convert(
baseValue: await convert( exp.totalCompensation.value,
exp.totalCompensation.value, exp.totalCompensation.currency,
exp.totalCompensation.currency, baseCurrencyString,
baseCurrencyString, ),
), currency: exp.totalCompensation.currency,
currency: exp.totalCompensation.currency, value: exp.totalCompensation.value,
value: exp.totalCompensation.value, },
}, },
}, },
}, },
where: {
id: exp.id,
},
});
}
await ctx.prisma.offersExperience.update({
data: {
monthlySalary: undefined,
monthlySalaryId: null,
}, },
where: { where: {
id: exp.id, id: exp.id,
@ -1581,6 +1553,18 @@ export const offersProfileRouter = createRouter()
for (const offerToUpdate of input.offers) { for (const offerToUpdate of input.offers) {
if (offerToUpdate.id) { if (offerToUpdate.id) {
// Update existing offer // Update existing offer
const currentOffer = await ctx.prisma.offersOffer.findFirst({
where: {
id: offerToUpdate.id,
},
});
if (!currentOffer) {
throw new trpc.TRPCError({
code: 'NOT_FOUND',
message: 'Offer to update does not exist',
});
}
await ctx.prisma.offersOffer.update({ await ctx.prisma.offersOffer.update({
data: { data: {
comments: offerToUpdate.comments, comments: offerToUpdate.comments,
@ -1606,82 +1590,200 @@ export const offersProfileRouter = createRouter()
}, },
}); });
if (offerToUpdate.offersIntern?.monthlySalary != null) { if (currentOffer.jobType === offerToUpdate.jobType) {
await ctx.prisma.offersIntern.update({ if (offerToUpdate.offersIntern?.monthlySalary != null) {
data: { await ctx.prisma.offersIntern.update({
internshipCycle: data: {
offerToUpdate.offersIntern.internshipCycle ?? undefined, internshipCycle:
monthlySalary: { offerToUpdate.offersIntern.internshipCycle ?? undefined,
upsert: { monthlySalary: {
create: { upsert: {
baseCurrency: baseCurrencyString, create: {
baseValue: await convert( baseCurrency: baseCurrencyString,
offerToUpdate.offersIntern.monthlySalary.value, baseValue: await convert(
offerToUpdate.offersIntern.monthlySalary.currency, offerToUpdate.offersIntern.monthlySalary.value,
baseCurrencyString, offerToUpdate.offersIntern.monthlySalary.currency,
), baseCurrencyString,
currency: ),
offerToUpdate.offersIntern.monthlySalary.currency, currency:
value: offerToUpdate.offersIntern.monthlySalary.value, offerToUpdate.offersIntern.monthlySalary.currency,
}, value: offerToUpdate.offersIntern.monthlySalary.value,
update: { },
baseCurrency: baseCurrencyString, update: {
baseValue: await convert( baseCurrency: baseCurrencyString,
offerToUpdate.offersIntern.monthlySalary.value, baseValue: await convert(
offerToUpdate.offersIntern.monthlySalary.currency, offerToUpdate.offersIntern.monthlySalary.value,
baseCurrencyString, offerToUpdate.offersIntern.monthlySalary.currency,
), baseCurrencyString,
currency: ),
offerToUpdate.offersIntern.monthlySalary.currency, currency:
value: offerToUpdate.offersIntern.monthlySalary.value, offerToUpdate.offersIntern.monthlySalary.currency,
value: offerToUpdate.offersIntern.monthlySalary.value,
},
}, },
}, },
startYear:
offerToUpdate.offersIntern.startYear ?? undefined,
title: offerToUpdate.offersIntern.title,
}, },
startYear: offerToUpdate.offersIntern.startYear ?? undefined, where: {
title: offerToUpdate.offersIntern.title, id: offerToUpdate.offersIntern.id,
}, },
where: { });
id: offerToUpdate.offersIntern.id, }
},
});
}
if (offerToUpdate.offersFullTime?.totalCompensation != null) { if (offerToUpdate.offersFullTime?.totalCompensation != null) {
await ctx.prisma.offersFullTime.update({ await ctx.prisma.offersFullTime.update({
data: { data: {
level: offerToUpdate.offersFullTime.level ?? undefined, level: offerToUpdate.offersFullTime.level ?? undefined,
title: offerToUpdate.offersFullTime.title, title: offerToUpdate.offersFullTime.title,
}, },
where: { where: {
id: offerToUpdate.offersFullTime.id, id: offerToUpdate.offersFullTime.id,
}, },
}); });
if (offerToUpdate.offersFullTime.baseSalary != null) { if (offerToUpdate.offersFullTime.baseSalary != null) {
await ctx.prisma.offersFullTime.update({
data: {
baseSalary: {
upsert: {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.baseSalary.value,
offerToUpdate.offersFullTime.baseSalary.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.baseSalary.currency,
value:
offerToUpdate.offersFullTime.baseSalary.value,
},
update: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.baseSalary.value,
offerToUpdate.offersFullTime.baseSalary.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.baseSalary.currency,
value:
offerToUpdate.offersFullTime.baseSalary.value,
},
},
},
},
where: {
id: offerToUpdate.offersFullTime.id,
},
});
}
if (offerToUpdate.offersFullTime.bonus != null) {
await ctx.prisma.offersFullTime.update({
data: {
bonus: {
upsert: {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.bonus.value,
offerToUpdate.offersFullTime.bonus.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.bonus.currency,
value: offerToUpdate.offersFullTime.bonus.value,
},
update: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.bonus.value,
offerToUpdate.offersFullTime.bonus.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.bonus.currency,
value: offerToUpdate.offersFullTime.bonus.value,
},
},
},
},
where: {
id: offerToUpdate.offersFullTime.id,
},
});
}
if (offerToUpdate.offersFullTime.stocks != null) {
await ctx.prisma.offersFullTime.update({
data: {
stocks: {
upsert: {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.stocks.value,
offerToUpdate.offersFullTime.stocks.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.stocks.currency,
value: offerToUpdate.offersFullTime.stocks.value,
},
update: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.stocks.value,
offerToUpdate.offersFullTime.stocks.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.stocks.currency,
value: offerToUpdate.offersFullTime.stocks.value,
},
},
},
},
where: {
id: offerToUpdate.offersFullTime.id,
},
});
}
await ctx.prisma.offersFullTime.update({ await ctx.prisma.offersFullTime.update({
data: { data: {
baseSalary: { totalCompensation: {
upsert: { upsert: {
create: { create: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.baseSalary.value, offerToUpdate.offersFullTime.totalCompensation
offerToUpdate.offersFullTime.baseSalary.currency, .value,
offerToUpdate.offersFullTime.totalCompensation
.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: currency:
offerToUpdate.offersFullTime.baseSalary.currency, offerToUpdate.offersFullTime.totalCompensation
value: offerToUpdate.offersFullTime.baseSalary.value, .currency,
value:
offerToUpdate.offersFullTime.totalCompensation
.value,
}, },
update: { update: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.baseSalary.value, offerToUpdate.offersFullTime.totalCompensation
offerToUpdate.offersFullTime.baseSalary.currency, .value,
offerToUpdate.offersFullTime.totalCompensation
.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: currency:
offerToUpdate.offersFullTime.baseSalary.currency, offerToUpdate.offersFullTime.totalCompensation
value: offerToUpdate.offersFullTime.baseSalary.value, .currency,
value:
offerToUpdate.offersFullTime.totalCompensation
.value,
}, },
}, },
}, },
@ -1691,30 +1793,159 @@ export const offersProfileRouter = createRouter()
}, },
}); });
} }
if (offerToUpdate.offersFullTime.bonus != null) { } else if (currentOffer.jobType === JobType.FULLTIME) {
if (offerToUpdate.offersFullTime?.totalCompensation != null) {
await ctx.prisma.offersFullTime.update({ await ctx.prisma.offersFullTime.update({
data: { data: {
bonus: { level: offerToUpdate.offersFullTime.level ?? undefined,
title: offerToUpdate.offersFullTime.title,
},
where: {
id: offerToUpdate.offersFullTime.id,
},
});
if (offerToUpdate.offersFullTime.baseSalary != null) {
await ctx.prisma.offersFullTime.update({
data: {
baseSalary: {
upsert: {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.baseSalary.value,
offerToUpdate.offersFullTime.baseSalary.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.baseSalary.currency,
value:
offerToUpdate.offersFullTime.baseSalary.value,
},
update: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.baseSalary.value,
offerToUpdate.offersFullTime.baseSalary.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.baseSalary.currency,
value:
offerToUpdate.offersFullTime.baseSalary.value,
},
},
},
},
where: {
id: offerToUpdate.offersFullTime.id,
},
});
}
if (offerToUpdate.offersFullTime.bonus != null) {
await ctx.prisma.offersFullTime.update({
data: {
bonus: {
upsert: {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.bonus.value,
offerToUpdate.offersFullTime.bonus.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.bonus.currency,
value: offerToUpdate.offersFullTime.bonus.value,
},
update: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.bonus.value,
offerToUpdate.offersFullTime.bonus.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.bonus.currency,
value: offerToUpdate.offersFullTime.bonus.value,
},
},
},
},
where: {
id: offerToUpdate.offersFullTime.id,
},
});
}
if (offerToUpdate.offersFullTime.stocks != null) {
await ctx.prisma.offersFullTime.update({
data: {
stocks: {
upsert: {
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.stocks.value,
offerToUpdate.offersFullTime.stocks.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.stocks.currency,
value: offerToUpdate.offersFullTime.stocks.value,
},
update: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.stocks.value,
offerToUpdate.offersFullTime.stocks.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.stocks.currency,
value: offerToUpdate.offersFullTime.stocks.value,
},
},
},
},
where: {
id: offerToUpdate.offersFullTime.id,
},
});
}
await ctx.prisma.offersFullTime.update({
data: {
totalCompensation: {
upsert: { upsert: {
create: { create: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.bonus.value, offerToUpdate.offersFullTime.totalCompensation
offerToUpdate.offersFullTime.bonus.currency, .value,
offerToUpdate.offersFullTime.totalCompensation
.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.bonus.currency, currency:
value: offerToUpdate.offersFullTime.bonus.value, offerToUpdate.offersFullTime.totalCompensation
.currency,
value:
offerToUpdate.offersFullTime.totalCompensation
.value,
}, },
update: { update: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.bonus.value, offerToUpdate.offersFullTime.totalCompensation
offerToUpdate.offersFullTime.bonus.currency, .value,
offerToUpdate.offersFullTime.totalCompensation
.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.bonus.currency, currency:
value: offerToUpdate.offersFullTime.bonus.value, offerToUpdate.offersFullTime.totalCompensation
.currency,
value:
offerToUpdate.offersFullTime.totalCompensation
.value,
}, },
}, },
}, },
@ -1724,78 +1955,65 @@ export const offersProfileRouter = createRouter()
}, },
}); });
} }
if (offerToUpdate.offersFullTime.stocks != null) {
await ctx.prisma.offersFullTime.update({ await ctx.prisma.offersOffer.update({
data: {
offersIntern: undefined,
offersInternId: null,
},
where: {
id: offerToUpdate.id,
},
});
} else if (currentOffer.jobType === JobType.INTERN) {
if (offerToUpdate.offersIntern?.monthlySalary != null) {
await ctx.prisma.offersIntern.update({
data: { data: {
stocks: { internshipCycle:
offerToUpdate.offersIntern.internshipCycle ?? undefined,
monthlySalary: {
upsert: { upsert: {
create: { create: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.stocks.value, offerToUpdate.offersIntern.monthlySalary.value,
offerToUpdate.offersFullTime.stocks.currency, offerToUpdate.offersIntern.monthlySalary.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: currency:
offerToUpdate.offersFullTime.stocks.currency, offerToUpdate.offersIntern.monthlySalary.currency,
value: offerToUpdate.offersFullTime.stocks.value, value: offerToUpdate.offersIntern.monthlySalary.value,
}, },
update: { update: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.stocks.value, offerToUpdate.offersIntern.monthlySalary.value,
offerToUpdate.offersFullTime.stocks.currency, offerToUpdate.offersIntern.monthlySalary.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: currency:
offerToUpdate.offersFullTime.stocks.currency, offerToUpdate.offersIntern.monthlySalary.currency,
value: offerToUpdate.offersFullTime.stocks.value, value: offerToUpdate.offersIntern.monthlySalary.value,
}, },
}, },
}, },
startYear:
offerToUpdate.offersIntern.startYear ?? undefined,
title: offerToUpdate.offersIntern.title,
}, },
where: { where: {
id: offerToUpdate.offersFullTime.id, id: offerToUpdate.offersIntern.id,
}, },
}); });
} }
await ctx.prisma.offersFullTime.update({
await ctx.prisma.offersOffer.update({
data: { data: {
totalCompensation: { offersFullTime: undefined,
upsert: { offersFullTimeId: null,
create: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.totalCompensation.value,
offerToUpdate.offersFullTime.totalCompensation
.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.totalCompensation
.currency,
value:
offerToUpdate.offersFullTime.totalCompensation.value,
},
update: {
baseCurrency: baseCurrencyString,
baseValue: await convert(
offerToUpdate.offersFullTime.totalCompensation.value,
offerToUpdate.offersFullTime.totalCompensation
.currency,
baseCurrencyString,
),
currency:
offerToUpdate.offersFullTime.totalCompensation
.currency,
value:
offerToUpdate.offersFullTime.totalCompensation.value,
},
},
},
}, },
where: { where: {
id: offerToUpdate.offersFullTime.id, id: offerToUpdate.id,
}, },
}); });
} }

@ -157,10 +157,15 @@ export type ProfileAnalysis = {
}; };
export type AnalysisUnit = { export type AnalysisUnit = {
companyId: string;
companyName: string; companyName: string;
income: Valuation;
jobType: JobType;
noOfOffers: number; noOfOffers: number;
percentile: number; percentile: number;
title: string;
topPercentileOffers: Array<AnalysisOffer>; topPercentileOffers: Array<AnalysisOffer>;
totalYoe: number;
}; };
export type AnalysisHighestOffer = { export type AnalysisHighestOffer = {
@ -181,6 +186,7 @@ export type AnalysisOffer = {
monthYearReceived: Date; monthYearReceived: Date;
negotiationStrategy: string; negotiationStrategy: string;
previousCompanies: Array<string>; previousCompanies: Array<string>;
profileId: string;
profileName: string; profileName: string;
title: string; title: string;
totalYoe: number; totalYoe: number;

@ -15,7 +15,8 @@ import type {
} from '@prisma/client'; } from '@prisma/client';
import { TRPCError } from '@trpc/server'; import { TRPCError } from '@trpc/server';
import { profileAnalysisDtoMapper } from '../../mappers/offers-mappers'; import { analysisInclusion } from './analysisInclusion';
import { profileAnalysisDtoMapper } from '../../../mappers/offers-mappers';
type Offer = OffersOffer & { type Offer = OffersOffer & {
company: Company; company: Company;
@ -292,7 +293,7 @@ export const generateAnalysis = async (params: {
: similarCompanyOffers; : similarCompanyOffers;
return { return {
companyId: companyOffer.companyId, analysedOfferId: companyOffer.id,
noOfSimilarOffers: noOfSimilarCompanyOffers, noOfSimilarOffers: noOfSimilarCompanyOffers,
percentile: companyPercentile, percentile: companyPercentile,
topSimilarOffers: topPercentileCompanyOffers, topSimilarOffers: topPercentileCompanyOffers,
@ -329,9 +330,9 @@ export const generateAnalysis = async (params: {
companyAnalysis: { companyAnalysis: {
create: companyAnalysis.map((analysisUnit) => { create: companyAnalysis.map((analysisUnit) => {
return { return {
company: { analysedOffer: {
connect: { connect: {
id: analysisUnit.companyId, id: analysisUnit.analysedOfferId,
}, },
}, },
noOfSimilarOffers: analysisUnit.noOfSimilarOffers, noOfSimilarOffers: analysisUnit.noOfSimilarOffers,
@ -346,9 +347,9 @@ export const generateAnalysis = async (params: {
}, },
overallAnalysis: { overallAnalysis: {
create: { create: {
company: { analysedOffer: {
connect: { connect: {
id: overallHighestOffer.companyId, id: overallHighestOffer.id,
}, },
}, },
noOfSimilarOffers, noOfSimilarOffers,
@ -371,139 +372,7 @@ export const generateAnalysis = async (params: {
}, },
}, },
}, },
include: { include: analysisInclusion,
companyAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallHighestOffer: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
},
}); });
return profileAnalysisDtoMapper(analysis); return profileAnalysisDtoMapper(analysis);

@ -0,0 +1,171 @@
export const analysisInclusion = {
companyAnalysis: {
include: {
analysedOffer: {
include: {
company: true,
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallAnalysis: {
include: {
analysedOffer: {
include: {
company: true,
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallHighestOffer: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
};

@ -20,7 +20,7 @@ export default function CurrencySelector({
<Select <Select
display="inline" display="inline"
isLabelHidden={true} isLabelHidden={true}
label="Select fruit" label="Currency"
name="" name=""
options={currencyOptions} options={currencyOptions}
value={selectedCurrency} value={selectedCurrency}

@ -0,0 +1,37 @@
import type { JobType } from '@prisma/client';
import { JobTypeLabel } from '~/components/offers/constants';
import type { Location } from '~/types/offers';
export function joinWithComma(...strings: Array<string | null | undefined>) {
return strings.filter((value) => !!value).join(', ');
}
export function getLocationDisplayText({ cityName, countryName }: Location) {
return cityName === countryName
? cityName
: joinWithComma(cityName, countryName);
}
export function getCompanyDisplayText(
companyName?: string | null,
location?: Location | null,
) {
if (!location) {
return companyName;
}
return joinWithComma(companyName, getLocationDisplayText(location));
}
export function getJobDisplayText(
jobTitle?: string | null,
jobLevel?: string | null,
jobType?: JobType | null,
) {
let jobDisplay = joinWithComma(jobTitle, jobLevel);
if (jobType) {
jobDisplay = jobDisplay.concat(` (${JobTypeLabel[jobType]})`);
}
return jobDisplay;
}

@ -55,3 +55,18 @@ export function getCurrentYear() {
export function convertToMonthYear(date: Date) { export function convertToMonthYear(date: Date) {
return { month: date.getMonth() + 1, year: date.getFullYear() } as MonthYear; return { month: date.getMonth() + 1, year: date.getFullYear() } as MonthYear;
} }
export function getDurationDisplayText(months: number) {
const years = Math.floor(months / 12);
const monthsRemainder = months % 12;
let durationDisplay = '';
if (years > 0) {
durationDisplay = `${years} year${years > 1 ? 's' : ''}`;
}
if (monthsRemainder > 0) {
durationDisplay = durationDisplay.concat(
` ${monthsRemainder} month${monthsRemainder > 1 ? 's' : ''}`,
);
}
return durationDisplay;
}

@ -0,0 +1,79 @@
import { useRouter } from 'next/router';
import { useCallback, useEffect, useState } from 'react';
type SearchParamOptions<Value> = [Value] extends [string]
? {
defaultValues?: Array<Value>;
paramToString?: (value: Value) => string | null;
stringToParam?: (param: string) => Value | null;
}
: {
defaultValues?: Array<Value>;
paramToString: (value: Value) => string | null;
stringToParam: (param: string) => Value | null;
};
export const useSearchParam = <Value = string>(
name: string,
opts?: SearchParamOptions<Value>,
) => {
const {
defaultValues,
stringToParam = (param: string) => param,
paramToString: valueToQueryParam = (value: Value) => String(value),
} = opts ?? {};
const [isInitialized, setIsInitialized] = useState(false);
const router = useRouter();
const [params, setParams] = useState<Array<Value>>(defaultValues || []);
useEffect(() => {
if (router.isReady && !isInitialized) {
// Initialize from query params
const query = router.query[name];
if (query) {
const queryValues = Array.isArray(query) ? query : [query];
setParams(
queryValues
.map(stringToParam)
.filter((value) => value !== null) as Array<Value>,
);
}
setIsInitialized(true);
}
}, [isInitialized, name, stringToParam, router]);
const setParamsCallback = useCallback(
(newParams: Array<Value>) => {
setParams(newParams);
localStorage.setItem(
name,
JSON.stringify(
newParams.map(valueToQueryParam).filter((param) => param !== null),
),
);
},
[name, valueToQueryParam],
);
return [params, setParamsCallback, isInitialized] as const;
};
export const useSearchParamSingle = <Value = string>(
name: string,
opts?: Omit<SearchParamOptions<Value>, 'defaultValues'> & {
defaultValue?: Value;
},
) => {
const { defaultValue, ...restOpts } = opts ?? {};
const [params, setParams, isInitialized] = useSearchParam<Value>(name, {
defaultValues: defaultValue !== undefined ? [defaultValue] : undefined,
...restOpts,
} as SearchParamOptions<Value>);
return [
params[0],
(value: Value) => setParams([value]),
isInitialized,
] as const;
};

@ -144,7 +144,7 @@ export default function Typeahead({
<Combobox.Input <Combobox.Input
aria-describedby={hasError ? errorId : undefined} aria-describedby={hasError ? errorId : undefined}
className={clsx( className={clsx(
'w-full border-none py-2 pl-3 pr-10 leading-5 focus:ring-0', 'w-full border-none py-2 pl-3 pr-10 text-[length:inherit] leading-5 focus:ring-0',
stateClasses[state].input, stateClasses[state].input,
textSizes[textSize], textSizes[textSize],
'disabled:cursor-not-allowed disabled:bg-transparent disabled:text-slate-500', 'disabled:cursor-not-allowed disabled:bg-transparent disabled:text-slate-500',

Loading…
Cancel
Save