mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-31 06:03:55 +08:00
[resumes][feat] Fetch all resumes in browse page (#325)
* [resumes][fix] Remove BrowsePageBody component * [resumes][feat] Add router to fetch all resumes * [resumes][feat] Fetch all resumes in browse page * [resumes][chore] Add todo * [resumes][fix] Remove unnecessary updatedAt field * [resumes][fix] Change from resumeProfile to user
This commit is contained in:
@ -3,19 +3,11 @@ import type { UrlObject } from 'url';
|
|||||||
import { ChevronRightIcon } from '@heroicons/react/20/solid';
|
import { ChevronRightIcon } from '@heroicons/react/20/solid';
|
||||||
import { ChatBubbleLeftIcon, StarIcon } from '@heroicons/react/24/outline';
|
import { ChatBubbleLeftIcon, StarIcon } from '@heroicons/react/24/outline';
|
||||||
|
|
||||||
type ResumeInfo = Readonly<{
|
import type { Resume } from '~/types/resume';
|
||||||
createdAt: Date;
|
|
||||||
experience: string;
|
|
||||||
numComments: number;
|
|
||||||
numStars: number;
|
|
||||||
role: string;
|
|
||||||
title: string;
|
|
||||||
user: string;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
type Props = Readonly<{
|
type Props = Readonly<{
|
||||||
href: UrlObject | string;
|
href: UrlObject | string;
|
||||||
resumeInfo: ResumeInfo;
|
resumeInfo: Resume;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export default function BrowseListItem({ href, resumeInfo }: Props) {
|
export default function BrowseListItem({ href, resumeInfo }: Props) {
|
||||||
@ -42,6 +34,7 @@ export default function BrowseListItem({ href, resumeInfo }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="self-center text-sm text-slate-500">
|
<div className="self-center text-sm text-slate-500">
|
||||||
|
{/* TODO: Replace hardcoded days ago with calculated days ago*/}
|
||||||
Uploaded 2 days ago by {resumeInfo.user}
|
Uploaded 2 days ago by {resumeInfo.user}
|
||||||
</div>
|
</div>
|
||||||
<ChevronRightIcon className="w-8" />
|
<ChevronRightIcon className="w-8" />
|
||||||
|
@ -1,226 +0,0 @@
|
|||||||
import clsx from 'clsx';
|
|
||||||
import { Fragment, useState } from 'react';
|
|
||||||
import { Disclosure, Menu, Transition } from '@headlessui/react';
|
|
||||||
import {
|
|
||||||
ChevronDownIcon,
|
|
||||||
MinusIcon,
|
|
||||||
PlusIcon,
|
|
||||||
} from '@heroicons/react/20/solid';
|
|
||||||
import { MagnifyingGlassIcon } from '@heroicons/react/24/outline';
|
|
||||||
import { Tabs, TextInput } from '@tih/ui';
|
|
||||||
|
|
||||||
import BrowseListItem from './BrowseListItem';
|
|
||||||
import {
|
|
||||||
EXPERIENCE,
|
|
||||||
LOCATION,
|
|
||||||
ROLES,
|
|
||||||
SORT_OPTIONS,
|
|
||||||
TEST_RESUMES,
|
|
||||||
TOP_HITS,
|
|
||||||
} from './constants';
|
|
||||||
import FilterPill from './FilterPill';
|
|
||||||
|
|
||||||
const filters = [
|
|
||||||
{
|
|
||||||
id: 'roles',
|
|
||||||
name: 'Roles',
|
|
||||||
options: ROLES,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'experience',
|
|
||||||
name: 'Experience',
|
|
||||||
options: EXPERIENCE,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'location',
|
|
||||||
name: 'Location',
|
|
||||||
options: LOCATION,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function BrowsePageBody() {
|
|
||||||
const [tabsValue, setTabsValue] = useState('all');
|
|
||||||
const [searchValue, setSearchValue] = useState('');
|
|
||||||
return (
|
|
||||||
<div className="w-screen sm:px-4 md:px-8">
|
|
||||||
<div className="grid grid-cols-12">
|
|
||||||
<div className="col-span-2 self-end">
|
|
||||||
<h1 className="mb-4 tracking-tight text-gray-900">Filters</h1>
|
|
||||||
</div>
|
|
||||||
<div className="col-span-10">
|
|
||||||
<div className="border-grey-200 grid grid-cols-12 items-center gap-4 border-b pb-2">
|
|
||||||
<div className="col-span-7">
|
|
||||||
<Tabs
|
|
||||||
label="Resume Browse Tabs"
|
|
||||||
tabs={[
|
|
||||||
{
|
|
||||||
label: 'All Resumes',
|
|
||||||
value: 'all',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Starred Resumes',
|
|
||||||
value: 'starred',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'My Resumes',
|
|
||||||
value: 'my',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
value={tabsValue}
|
|
||||||
onChange={setTabsValue}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="col-span-3 self-end">
|
|
||||||
<form>
|
|
||||||
<TextInput
|
|
||||||
label=""
|
|
||||||
placeholder="Search Resumes"
|
|
||||||
startAddOn={MagnifyingGlassIcon}
|
|
||||||
startAddOnType="icon"
|
|
||||||
type="text"
|
|
||||||
value={searchValue}
|
|
||||||
onChange={setSearchValue}
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div className="col-span-1 justify-self-center">
|
|
||||||
<Menu as="div" className="relative inline-block text-left">
|
|
||||||
<div>
|
|
||||||
<Menu.Button className="group inline-flex justify-center text-sm font-medium text-gray-700 hover:text-gray-900">
|
|
||||||
Sort
|
|
||||||
<ChevronDownIcon
|
|
||||||
aria-hidden="true"
|
|
||||||
className="-mr-1 ml-1 h-5 w-5 flex-shrink-0 text-gray-400 group-hover:text-gray-500"
|
|
||||||
/>
|
|
||||||
</Menu.Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Transition
|
|
||||||
as={Fragment}
|
|
||||||
enter="transition ease-out duration-100"
|
|
||||||
enterFrom="transform opacity-0 scale-95"
|
|
||||||
enterTo="transform opacity-100 scale-100"
|
|
||||||
leave="transition ease-in duration-75"
|
|
||||||
leaveFrom="transform opacity-100 scale-100"
|
|
||||||
leaveTo="transform opacity-0 scale-95">
|
|
||||||
<Menu.Items className="absolute right-0 z-10 mt-2 w-40 origin-top-right rounded-md bg-white shadow-2xl ring-1 ring-black ring-opacity-5 focus:outline-none">
|
|
||||||
<div className="py-1">
|
|
||||||
{SORT_OPTIONS.map((option) => (
|
|
||||||
<Menu.Item key={option.name}>
|
|
||||||
{({ active }) => (
|
|
||||||
<a
|
|
||||||
className={clsx(
|
|
||||||
option.current
|
|
||||||
? 'font-medium text-gray-900'
|
|
||||||
: 'text-gray-500',
|
|
||||||
active ? 'bg-gray-100' : '',
|
|
||||||
'block px-4 py-2 text-sm',
|
|
||||||
)}
|
|
||||||
href={option.href}>
|
|
||||||
{option.name}
|
|
||||||
</a>
|
|
||||||
)}
|
|
||||||
</Menu.Item>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</Menu.Items>
|
|
||||||
</Transition>
|
|
||||||
</Menu>
|
|
||||||
</div>
|
|
||||||
<div className="col-span-1">
|
|
||||||
<button
|
|
||||||
className="rounded-md bg-indigo-500 py-1 px-3 text-sm text-white"
|
|
||||||
type="button">
|
|
||||||
New
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-12">
|
|
||||||
<div className="col-span-2">
|
|
||||||
<div className="w-100 pt-4 sm:pr-0 md:pr-4">
|
|
||||||
<form>
|
|
||||||
<h3 className="sr-only">Categories</h3>
|
|
||||||
<ul
|
|
||||||
className="flex flex-wrap justify-start gap-4 pb-6 text-sm font-medium text-gray-900"
|
|
||||||
role="list">
|
|
||||||
{TOP_HITS.map((category) => (
|
|
||||||
<li key={category.name}>
|
|
||||||
{/* TODO: Replace onClick with filtering function */}
|
|
||||||
<FilterPill title={category.name} onClick={() => true} />
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{filters.map((section) => (
|
|
||||||
<Disclosure
|
|
||||||
key={section.id}
|
|
||||||
as="div"
|
|
||||||
className="border-b border-gray-200 py-6">
|
|
||||||
{({ open }) => (
|
|
||||||
<>
|
|
||||||
<h3 className="-my-3 flow-root">
|
|
||||||
<Disclosure.Button className="flex w-full items-center justify-between py-3 text-sm text-gray-400 hover:text-gray-500">
|
|
||||||
<span className="font-medium text-gray-900">
|
|
||||||
{section.name}
|
|
||||||
</span>
|
|
||||||
<span className="ml-6 flex items-center">
|
|
||||||
{open ? (
|
|
||||||
<MinusIcon
|
|
||||||
aria-hidden="true"
|
|
||||||
className="h-5 w-5"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<PlusIcon
|
|
||||||
aria-hidden="true"
|
|
||||||
className="h-5 w-5"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
</Disclosure.Button>
|
|
||||||
</h3>
|
|
||||||
<Disclosure.Panel className="pt-6">
|
|
||||||
<div className="space-y-4">
|
|
||||||
{section.options.map((option, optionIdx) => (
|
|
||||||
<div
|
|
||||||
key={option.value}
|
|
||||||
className="flex items-center">
|
|
||||||
<input
|
|
||||||
className="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
|
|
||||||
defaultChecked={option.checked}
|
|
||||||
defaultValue={option.value}
|
|
||||||
id={`filter-${section.id}-${optionIdx}`}
|
|
||||||
name={`${section.id}[]`}
|
|
||||||
type="checkbox"
|
|
||||||
/>
|
|
||||||
<label
|
|
||||||
className="ml-3 text-sm text-gray-600"
|
|
||||||
htmlFor={`filter-${section.id}-${optionIdx}`}>
|
|
||||||
{option.label}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</Disclosure.Panel>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Disclosure>
|
|
||||||
))}
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-span-10 pr-8">
|
|
||||||
<ul role="list">
|
|
||||||
{TEST_RESUMES.map((resumeObj) => (
|
|
||||||
<li key={resumeObj.title}>
|
|
||||||
<BrowseListItem href="#" resumeInfo={resumeObj} />
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,14 +1,243 @@
|
|||||||
import BrowsePageBody from '~/components/resumes/browse/BrowsePageBody';
|
import clsx from 'clsx';
|
||||||
|
import { Fragment, useState } from 'react';
|
||||||
|
import { Disclosure, Menu, Transition } from '@headlessui/react';
|
||||||
|
import {
|
||||||
|
ChevronDownIcon,
|
||||||
|
MinusIcon,
|
||||||
|
PlusIcon,
|
||||||
|
} from '@heroicons/react/20/solid';
|
||||||
|
import { MagnifyingGlassIcon } from '@heroicons/react/24/outline';
|
||||||
|
import { Tabs, TextInput } from '@tih/ui';
|
||||||
|
|
||||||
|
import BrowseListItem from '~/components/resumes/browse/BrowseListItem';
|
||||||
|
import {
|
||||||
|
EXPERIENCE,
|
||||||
|
LOCATION,
|
||||||
|
ROLES,
|
||||||
|
SORT_OPTIONS,
|
||||||
|
TOP_HITS,
|
||||||
|
} from '~/components/resumes/browse/constants';
|
||||||
|
import FilterPill from '~/components/resumes/browse/FilterPill';
|
||||||
|
|
||||||
|
const filters = [
|
||||||
|
{
|
||||||
|
id: 'roles',
|
||||||
|
name: 'Roles',
|
||||||
|
options: ROLES,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'experience',
|
||||||
|
name: 'Experience',
|
||||||
|
options: EXPERIENCE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'location',
|
||||||
|
name: 'Location',
|
||||||
|
options: LOCATION,
|
||||||
|
},
|
||||||
|
];
|
||||||
import ResumeReviewsTitle from '~/components/resumes/ResumeReviewsTitle';
|
import ResumeReviewsTitle from '~/components/resumes/ResumeReviewsTitle';
|
||||||
|
|
||||||
|
import { trpc } from '~/utils/trpc';
|
||||||
|
|
||||||
export default function ResumeHomePage() {
|
export default function ResumeHomePage() {
|
||||||
|
const [tabsValue, setTabsValue] = useState('all');
|
||||||
|
const [searchValue, setSearchValue] = useState('');
|
||||||
|
const resumesQuery = trpc.useQuery(['resumes.resume.list']);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="h-full flex-1 overflow-y-auto">
|
<main className="h-full flex-1 overflow-y-auto">
|
||||||
<div className="ml-4 py-4">
|
<div className="ml-4 py-4">
|
||||||
<ResumeReviewsTitle />
|
<ResumeReviewsTitle />
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-4 flex items-start">
|
<div className="mt-4 flex items-start">
|
||||||
<BrowsePageBody />
|
<div className="w-screen sm:px-4 md:px-8">
|
||||||
|
<div className="grid grid-cols-12">
|
||||||
|
<div className="col-span-2 self-end">
|
||||||
|
<h1 className="mb-4 tracking-tight text-gray-900">Filters</h1>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-10">
|
||||||
|
<div className="border-grey-200 grid grid-cols-12 items-center gap-4 border-b pb-2">
|
||||||
|
<div className="col-span-7">
|
||||||
|
<Tabs
|
||||||
|
label="Resume Browse Tabs"
|
||||||
|
tabs={[
|
||||||
|
{
|
||||||
|
label: 'All Resumes',
|
||||||
|
value: 'all',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Starred Resumes',
|
||||||
|
value: 'starred',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'My Resumes',
|
||||||
|
value: 'my',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
value={tabsValue}
|
||||||
|
onChange={setTabsValue}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-3 self-end">
|
||||||
|
<form>
|
||||||
|
<TextInput
|
||||||
|
label=""
|
||||||
|
placeholder="Search Resumes"
|
||||||
|
startAddOn={MagnifyingGlassIcon}
|
||||||
|
startAddOnType="icon"
|
||||||
|
type="text"
|
||||||
|
value={searchValue}
|
||||||
|
onChange={setSearchValue}
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-1 justify-self-center">
|
||||||
|
<Menu as="div" className="relative inline-block text-left">
|
||||||
|
<div>
|
||||||
|
<Menu.Button className="group inline-flex justify-center text-sm font-medium text-gray-700 hover:text-gray-900">
|
||||||
|
Sort
|
||||||
|
<ChevronDownIcon
|
||||||
|
aria-hidden="true"
|
||||||
|
className="-mr-1 ml-1 h-5 w-5 flex-shrink-0 text-gray-400 group-hover:text-gray-500"
|
||||||
|
/>
|
||||||
|
</Menu.Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Transition
|
||||||
|
as={Fragment}
|
||||||
|
enter="transition ease-out duration-100"
|
||||||
|
enterFrom="transform opacity-0 scale-95"
|
||||||
|
enterTo="transform opacity-100 scale-100"
|
||||||
|
leave="transition ease-in duration-75"
|
||||||
|
leaveFrom="transform opacity-100 scale-100"
|
||||||
|
leaveTo="transform opacity-0 scale-95">
|
||||||
|
<Menu.Items className="absolute right-0 z-10 mt-2 w-40 origin-top-right rounded-md bg-white shadow-2xl ring-1 ring-black ring-opacity-5 focus:outline-none">
|
||||||
|
<div className="py-1">
|
||||||
|
{SORT_OPTIONS.map((option) => (
|
||||||
|
<Menu.Item key={option.name}>
|
||||||
|
{({ active }) => (
|
||||||
|
<a
|
||||||
|
className={clsx(
|
||||||
|
option.current
|
||||||
|
? 'font-medium text-gray-900'
|
||||||
|
: 'text-gray-500',
|
||||||
|
active ? 'bg-gray-100' : '',
|
||||||
|
'block px-4 py-2 text-sm',
|
||||||
|
)}
|
||||||
|
href={option.href}>
|
||||||
|
{option.name}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</Menu.Item>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Menu.Items>
|
||||||
|
</Transition>
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
|
<div className="col-span-1">
|
||||||
|
<button
|
||||||
|
className="rounded-md bg-indigo-500 py-1 px-3 text-sm text-white"
|
||||||
|
type="button">
|
||||||
|
New
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-12">
|
||||||
|
<div className="col-span-2">
|
||||||
|
<div className="w-100 pt-4 sm:pr-0 md:pr-4">
|
||||||
|
<form>
|
||||||
|
<h3 className="sr-only">Categories</h3>
|
||||||
|
<ul
|
||||||
|
className="flex flex-wrap justify-start gap-4 pb-6 text-sm font-medium text-gray-900"
|
||||||
|
role="list">
|
||||||
|
{TOP_HITS.map((category) => (
|
||||||
|
<li key={category.name}>
|
||||||
|
{/* TODO: Replace onClick with filtering function */}
|
||||||
|
<FilterPill
|
||||||
|
title={category.name}
|
||||||
|
onClick={() => true}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{filters.map((section) => (
|
||||||
|
<Disclosure
|
||||||
|
key={section.id}
|
||||||
|
as="div"
|
||||||
|
className="border-b border-gray-200 py-6">
|
||||||
|
{({ open }) => (
|
||||||
|
<>
|
||||||
|
<h3 className="-my-3 flow-root">
|
||||||
|
<Disclosure.Button className="flex w-full items-center justify-between py-3 text-sm text-gray-400 hover:text-gray-500">
|
||||||
|
<span className="font-medium text-gray-900">
|
||||||
|
{section.name}
|
||||||
|
</span>
|
||||||
|
<span className="ml-6 flex items-center">
|
||||||
|
{open ? (
|
||||||
|
<MinusIcon
|
||||||
|
aria-hidden="true"
|
||||||
|
className="h-5 w-5"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<PlusIcon
|
||||||
|
aria-hidden="true"
|
||||||
|
className="h-5 w-5"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</Disclosure.Button>
|
||||||
|
</h3>
|
||||||
|
<Disclosure.Panel className="pt-6">
|
||||||
|
<div className="space-y-4">
|
||||||
|
{section.options.map((option, optionIdx) => (
|
||||||
|
<div
|
||||||
|
key={option.value}
|
||||||
|
className="flex items-center">
|
||||||
|
<input
|
||||||
|
className="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
|
||||||
|
defaultChecked={option.checked}
|
||||||
|
defaultValue={option.value}
|
||||||
|
id={`filter-${section.id}-${optionIdx}`}
|
||||||
|
name={`${section.id}[]`}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
className="ml-3 text-sm text-gray-600"
|
||||||
|
htmlFor={`filter-${section.id}-${optionIdx}`}>
|
||||||
|
{option.label}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Disclosure.Panel>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Disclosure>
|
||||||
|
))}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{resumesQuery.isLoading ? (
|
||||||
|
<div>Loading...</div>
|
||||||
|
) : (
|
||||||
|
<div className="col-span-10 pr-8">
|
||||||
|
<ul role="list">
|
||||||
|
{resumesQuery.data?.map((resumeObj) => (
|
||||||
|
<li key={resumeObj.id}>
|
||||||
|
<BrowseListItem href="#" resumeInfo={resumeObj} />
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
@ -2,6 +2,7 @@ import superjson from 'superjson';
|
|||||||
|
|
||||||
import { createRouter } from './context';
|
import { createRouter } from './context';
|
||||||
import { protectedExampleRouter } from './protected-example-router';
|
import { protectedExampleRouter } from './protected-example-router';
|
||||||
|
import { resumesRouter } from './resumes';
|
||||||
import { resumesDetailsRouter } from './resumes-details-router';
|
import { resumesDetailsRouter } from './resumes-details-router';
|
||||||
import { resumesResumeUserRouter } from './resumes-resume-user-router';
|
import { resumesResumeUserRouter } from './resumes-resume-user-router';
|
||||||
import { resumeReviewsRouter } from './resumes-reviews-router';
|
import { resumeReviewsRouter } from './resumes-reviews-router';
|
||||||
@ -17,6 +18,7 @@ export const appRouter = createRouter()
|
|||||||
.merge('auth.', protectedExampleRouter)
|
.merge('auth.', protectedExampleRouter)
|
||||||
.merge('todos.', todosRouter)
|
.merge('todos.', todosRouter)
|
||||||
.merge('todos.user.', todosUserRouter)
|
.merge('todos.user.', todosUserRouter)
|
||||||
|
.merge('resumes.resume.', resumesRouter)
|
||||||
.merge('resumes.details.', resumesDetailsRouter)
|
.merge('resumes.details.', resumesDetailsRouter)
|
||||||
.merge('resumes.resume.user.', resumesResumeUserRouter)
|
.merge('resumes.resume.user.', resumesResumeUserRouter)
|
||||||
.merge('resumes.reviews.', resumeReviewsRouter)
|
.merge('resumes.reviews.', resumeReviewsRouter)
|
||||||
|
42
apps/portal/src/server/router/resumes.ts
Normal file
42
apps/portal/src/server/router/resumes.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { createRouter } from './context';
|
||||||
|
|
||||||
|
import type { Resume } from '~/types/resume';
|
||||||
|
|
||||||
|
export const resumesRouter = createRouter().query('list', {
|
||||||
|
async resolve({ ctx }) {
|
||||||
|
const resumesData = await ctx.prisma.resumesResume.findMany({
|
||||||
|
include: {
|
||||||
|
_count: {
|
||||||
|
select: {
|
||||||
|
comments: true,
|
||||||
|
stars: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
user: {
|
||||||
|
select: {
|
||||||
|
name: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
orderBy: {
|
||||||
|
createdAt: 'desc',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return resumesData.map((r) => {
|
||||||
|
const resume: Resume = {
|
||||||
|
additionalInfo: r.additionalInfo,
|
||||||
|
createdAt: r.createdAt,
|
||||||
|
experience: r.experience,
|
||||||
|
id: r.id,
|
||||||
|
location: r.location,
|
||||||
|
numComments: r._count.comments,
|
||||||
|
numStars: r._count.stars,
|
||||||
|
role: r.role,
|
||||||
|
title: r.title,
|
||||||
|
url: r.url,
|
||||||
|
user: r.user.name!,
|
||||||
|
};
|
||||||
|
return resume;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
13
apps/portal/src/types/resume.d.ts
vendored
Normal file
13
apps/portal/src/types/resume.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export type Resume = {
|
||||||
|
additionalInfo: string?;
|
||||||
|
createdAt: Date;
|
||||||
|
experience: string;
|
||||||
|
id: string;
|
||||||
|
location: string;
|
||||||
|
numComments: number;
|
||||||
|
numStars: number;
|
||||||
|
role: string;
|
||||||
|
title: string;
|
||||||
|
url: string;
|
||||||
|
user: string;
|
||||||
|
};
|
Reference in New Issue
Block a user