diff --git a/apps/portal/src/components/offers/dashboard/DashboardOfferCard.tsx b/apps/portal/src/components/offers/dashboard/DashboardOfferCard.tsx index dda493ec..3b013c2c 100644 --- a/apps/portal/src/components/offers/dashboard/DashboardOfferCard.tsx +++ b/apps/portal/src/components/offers/dashboard/DashboardOfferCard.tsx @@ -5,6 +5,7 @@ import { } from '@heroicons/react/20/solid'; import { JobType } from '@prisma/client'; +import { JobTypeLabel } from '~/components/offers/constants'; import type { JobTitleType } from '~/components/shared/JobTitles'; import { getLabelForJobTitleType } from '~/components/shared/JobTitles'; @@ -33,7 +34,8 @@ export default function DashboardProfileCard({

- {getLabelForJobTitleType(title as JobTitleType)} + {getLabelForJobTitleType(title as JobTitleType)}{' '} + {jobType && <>({JobTypeLabel[jobType]})}

{company?.name && ( diff --git a/apps/portal/src/components/offers/offerAnalysis/OfferAnalysis.tsx b/apps/portal/src/components/offers/offerAnalysis/OfferAnalysis.tsx index e7e6199b..d229eb52 100644 --- a/apps/portal/src/components/offers/offerAnalysis/OfferAnalysis.tsx +++ b/apps/portal/src/components/offers/offerAnalysis/OfferAnalysis.tsx @@ -109,13 +109,13 @@ export default function OfferAnalysis({ return (
- {isError && ( + {isError ? (

An error occurred while generating profile analysis.

- )} - {isLoading && } - {!isError && !isLoading && ( + ) : isLoading ? ( + + ) : (
- + ); } diff --git a/apps/portal/src/components/offers/offersSubmission/OffersProfileSave.tsx b/apps/portal/src/components/offers/offersSubmission/OffersProfileSave.tsx index d494912e..513d0de7 100644 --- a/apps/portal/src/components/offers/offersSubmission/OffersProfileSave.tsx +++ b/apps/portal/src/components/offers/offersSubmission/OffersProfileSave.tsx @@ -1,5 +1,5 @@ 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 { BookmarkIcon as BookmarkOutlineIcon } from '@heroicons/react/24/outline'; 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'; type OfferProfileSaveProps = Readonly<{ + isSavedQuery: UseQueryResult; profileId: string; token?: string; }>; @@ -18,10 +19,10 @@ type OfferProfileSaveProps = Readonly<{ export default function OffersProfileSave({ profileId, token, + isSavedQuery: { data: isSaved, isLoading }, }: OfferProfileSaveProps) { const { showToast } = useToast(); const { event: gaEvent } = useGoogleAnalytics(); - const [isSaved, setSaved] = useState(false); const { data: session, status } = useSession(); 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 handleSave = () => { if (status === 'unauthenticated') { @@ -125,9 +117,9 @@ export default function OffersProfileSave({

diff --git a/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx b/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx index 42eff26c..a03782dd 100644 --- a/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx +++ b/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx @@ -4,7 +4,7 @@ import type { SubmitHandler } from 'react-hook-form'; import { FormProvider, useForm } from 'react-hook-form'; import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/20/solid'; import { JobType } from '@prisma/client'; -import { Button, useToast } from '@tih/ui'; +import { Button, Spinner, useToast } from '@tih/ui'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import type { BreadcrumbStep } from '~/components/offers/Breadcrumbs'; @@ -116,7 +116,7 @@ export default function OffersSubmissionForm({ const { handleSubmit, trigger, - formState: { isSubmitting, isSubmitSuccessful }, + formState: { isSubmitting }, } = formMethods; const generateAnalysisMutation = trpc.useMutation( @@ -124,6 +124,10 @@ export default function OffersSubmissionForm({ { onError(error) { console.error(error.message); + showToast({ + title: 'Error generating analysis.', + variant: 'failure', + }); }, onSuccess() { router.push( @@ -174,7 +178,7 @@ export default function OffersSubmissionForm({ title: editProfileId && editToken ? 'Error updating offer profile.' - : 'Error creating offer profile', + : 'Error creating offer profile.', variant: 'failure', }); }, @@ -193,7 +197,7 @@ export default function OffersSubmissionForm({ const onSubmit: SubmitHandler = async (data) => { const result = await trigger(); - if (!result || isSubmitting || isSubmitSuccessful) { + if (!result || isSubmitting || createOrUpdateMutation.isLoading) { return; } @@ -272,7 +276,9 @@ export default function OffersSubmissionForm({ // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - return ( + return generateAnalysisMutation.isLoading ? ( + + ) : (
@@ -324,9 +330,16 @@ export default function OffersSubmissionForm({ }} />
)} - {duration && ( + {!!duration && (
-

{`${duration} months`}

+

{getDurationDisplayText(duration)}

)}
@@ -99,24 +101,27 @@ export default function OfferCard({ return (
- {totalCompensation && ( -
-
- Total Compensation -
-
- {totalCompensation} -
-
- )} - {monthlySalary && ( -
-
- Monthly Salary -
-
{monthlySalary}
-
- )} + {jobType === JobType.FULLTIME + ? totalCompensation && ( +
+
+ Total Compensation +
+
+ {totalCompensation} +
+
+ ) + : monthlySalary && ( +
+
+ Monthly Salary +
+
+ {monthlySalary} +
+
+ )} {base && (
diff --git a/apps/portal/src/components/offers/profile/ProfileComments.tsx b/apps/portal/src/components/offers/profile/ProfileComments.tsx index 34ac8b67..0eeaa1a3 100644 --- a/apps/portal/src/components/offers/profile/ProfileComments.tsx +++ b/apps/portal/src/components/offers/profile/ProfileComments.tsx @@ -1,13 +1,7 @@ import { signIn, useSession } from 'next-auth/react'; import { useState } from 'react'; import { ClipboardDocumentIcon, ShareIcon } from '@heroicons/react/24/outline'; -import { - Button, - HorizontalDivider, - Spinner, - TextArea, - useToast, -} from '@tih/ui'; +import { Button, Spinner, TextArea, useToast } from '@tih/ui'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import ExpandableCommentCard from '~/components/offers/profile/comments/ExpandableCommentCard'; @@ -110,8 +104,8 @@ export default function ProfileComments({ ); } return ( -
-
+
+
@@ -169,7 +163,7 @@ export default function ProfileComments({
-
+

Discussions

{isEditable || session?.user?.name ? (
@@ -199,11 +193,9 @@ export default function ProfileComments({ />
-
) : (
-
-
    +
    +
      {replies?.map((reply: Reply) => ( -
    • +
    • +
      {!analysis ? (

      No analysis available.

      ) : ( diff --git a/apps/portal/src/components/offers/profile/ProfilePhotoHolder.tsx b/apps/portal/src/components/offers/profile/ProfilePhotoHolder.tsx index 3cfb3745..372d9f06 100644 --- a/apps/portal/src/components/offers/profile/ProfilePhotoHolder.tsx +++ b/apps/portal/src/components/offers/profile/ProfilePhotoHolder.tsx @@ -1,11 +1,11 @@ type ProfilePhotoHolderProps = Readonly<{ - size?: 'lg' | 'sm'; + size?: 'lg' | 'sm' | 'xs'; }>; export default function ProfilePhotoHolder({ size = 'lg', }: ProfilePhotoHolderProps) { - const sizeMap = { lg: '16', sm: '12' }; + const sizeMap = { lg: '16', sm: '12', xs: '10' }; return ( diff --git a/apps/portal/src/components/offers/profile/comments/CommentCard.tsx b/apps/portal/src/components/offers/profile/comments/CommentCard.tsx index 9f0a0bef..b958d329 100644 --- a/apps/portal/src/components/offers/profile/comments/CommentCard.tsx +++ b/apps/portal/src/components/offers/profile/comments/CommentCard.tsx @@ -2,6 +2,8 @@ import { signIn, useSession } from 'next-auth/react'; import { useState } from 'react'; import { Button, Dialog, TextArea, useToast } from '@tih/ui'; +import ProfilePhotoHolder from '~/components/offers/profile/ProfilePhotoHolder'; + import { timeSinceNow } from '~/utils/offers/time'; import { trpc } from '~/utils/trpc'; @@ -121,14 +123,18 @@ export default function CommentCard({ return (
      - {/*
      - -
      */} -
      +
      + {user?.image ? ( + {user?.name + ) : ( + + )} +
      +

      {user?.name ?? 'unknown user'} @@ -137,35 +143,35 @@ export default function CommentCard({

      {message}

      -
      +
      {timeSinceNow(createdAt)} ago {' '} - ·{' '} {replyLength > 0 && ( <> + ·{' '} - ·{' '} )} {!disableReply && ( <> + ·{' '} - ·{' '} )} {deletable && ( <> + ·{' '}