diff --git a/src/components/features/evaluator/response.tsx b/src/components/features/evaluator/response.tsx index 110d2d0..b1ca670 100644 --- a/src/components/features/evaluator/response.tsx +++ b/src/components/features/evaluator/response.tsx @@ -44,10 +44,12 @@ export function Response({ label, type, response, userId }: ResponseProps) { ) : type === "booleanMap" ? ( } /> + ) : type === "resume" ? ( + ) : loading ? ( ) : ( - + )} ); @@ -64,31 +66,64 @@ const BooleanMap = ({ value }: { value?: Record }) => { ); }; +const ResumeField = ({ href, loading }: { href?: string; loading: boolean }) => { + if (loading) return ; + + const value = href ?? ""; + if (!value.trim()) { + return ; + } + + const handleClipboard = () => { + navigator.clipboard.writeText(value); + toast("Copied link to clipboard!"); + }; + + return ( +
+ Uploaded + + View resume + + + +
+ ); +}; + const LinkField = ({ href }: { href?: string }) => { + const value = href ?? ""; + const isUrl = /^https?:\/\//i.test(value.trim()); + const handleClipboard = () => { - if (!href) return; - navigator.clipboard.writeText(href); + if (!value) return; + navigator.clipboard.writeText(value); toast("Copied link to clipboard!"); }; - const hasLink = Boolean(href); + if (!isUrl) { + return ; + } return ( diff --git a/src/components/features/hackerapp/hacker-app-question.tsx b/src/components/features/hackerapp/hacker-app-question.tsx index 62c5295..fbe1dd5 100644 --- a/src/components/features/hackerapp/hacker-app-question.tsx +++ b/src/components/features/hackerapp/hacker-app-question.tsx @@ -31,7 +31,11 @@ import { getEligibleSources, } from "./hacker-app-conditions"; import type { UsedFieldsRegistry } from "./hacker-app-main"; -import { LEGAL_NAME_FORM_INPUTS, isFormInputAllowedInSection } from "./hacker-app-sections"; +import { + LEGAL_NAME_FORM_INPUTS, + isFormInputAllowedInSection, + isQuestionTypeAllowedInSection, +} from "./hacker-app-sections"; const QUESTION_TYPES: HackerApplicationQuestionType[] = [ "Long Answer", @@ -44,6 +48,10 @@ const QUESTION_TYPES: HackerApplicationQuestionType[] = [ "School", "Major", "Country", + "Github", + "LinkedIn", + "Portfolio Website", + "Resume", ]; // Question types that if selected, bricks the select field and locks in the value @@ -53,6 +61,10 @@ const QUESTION_TYPES_UNIQUE: HackerApplicationQuestionType[] = [ "School", "Major", "Country", + "Github", + "LinkedIn", + "Portfolio Website", + "Resume", ]; export const SHOW_FORM_INPUT: HackerApplicationQuestionType[] = [ @@ -132,6 +144,7 @@ export const HackerAppQuestion = memo(function HackerAppQuestion({ ); const usableQuestionTypes = QUESTION_TYPES?.filter( (qt) => + isQuestionTypeAllowedInSection(qt, section) && (qt !== "Full Legal Name" || !hasSplitLegalName) && (!QUESTION_TYPES_UNIQUE.includes(qt) || !usedFieldsRegistry.questionType.has(qt)), ); diff --git a/src/components/features/hackerapp/hacker-app-sections.ts b/src/components/features/hackerapp/hacker-app-sections.ts index c1e9ab4..dfa5f9b 100644 --- a/src/components/features/hackerapp/hacker-app-sections.ts +++ b/src/components/features/hackerapp/hacker-app-sections.ts @@ -1,5 +1,6 @@ import type { HackerApplicationQuestionFormInputField, + HackerApplicationQuestionType, HackerApplicationSections, } from "@/lib/firebase/types"; @@ -69,3 +70,21 @@ export const isFormInputAllowedInSection = ( const pinned = SECTION_BY_FORM_INPUT[formInput]; return pinned === undefined || pinned === section; }; + +export const QUESTION_TYPE_SECTION: Partial< + Record +> = { + Portfolio: "Skills", + Github: "Skills", + LinkedIn: "Skills", + "Portfolio Website": "Skills", + Resume: "Skills", +}; + +export const isQuestionTypeAllowedInSection = ( + questionType: HackerApplicationQuestionType, + section: HackerApplicationSections, +): boolean => { + const pinned = QUESTION_TYPE_SECTION[questionType]; + return pinned === undefined || pinned === section; +}; diff --git a/src/lib/firebase/types.ts b/src/lib/firebase/types.ts index 8201c0e..e597c00 100644 --- a/src/lib/firebase/types.ts +++ b/src/lib/firebase/types.ts @@ -358,7 +358,11 @@ export type HackerApplicationQuestionType = | "Dropdown" | "School" | "Major" - | "Country"; + | "Country" + | "Github" + | "LinkedIn" + | "Portfolio Website" + | "Resume"; // keep in sync with portal-v2 src/lib/firebase/types/hacker-app-questions.ts, which renders these export const FORM_INPUT_FIELDS = [ "academicYear",