feat(matches): add the candidate match screen with expandable explanations
This commit is contained in:
1 parent
0b11021b16
commit
28337d84cb
50 files changed
+4834
-37
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import type { SpecializationCode } from "../../../shared/api/schemas";
|
||||
import type { MatchCardModel } from "./adapter";
|
||||
import { specializationCodes } from "./labels";
|
||||
|
||||
/** The view that shows every specialization, each entry labelled with its own. */
|
||||
export const allSpecializationsView = "all";
|
||||
|
||||
export type SpecializationView = typeof allSpecializationsView | SpecializationCode;
|
||||
|
||||
/** Stable key of one entry: one candidate under one specialization. */
|
||||
export function matchCardKey(card: Pick<MatchCardModel, "candidateHandle" | "specialization">) {
|
||||
return `${card.candidateHandle}:${card.specialization}`;
|
||||
}
|
||||
|
||||
/** Specializations that occur in the result, in catalog order. */
|
||||
export function specializationsInResult(cards: readonly MatchCardModel[]): SpecializationCode[] {
|
||||
const present = new Set(cards.map((card) => card.specialization));
|
||||
return specializationCodes.filter((code) => present.has(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* Entries of one specialization view. Selecting a specialization only hides
|
||||
* the others; the server order inside each group is kept and no entry
|
||||
* borrows a confirmation from another specialization.
|
||||
*/
|
||||
export function cardsForView(
|
||||
cards: readonly MatchCardModel[],
|
||||
view: SpecializationView,
|
||||
): MatchCardModel[] {
|
||||
return view === allSpecializationsView
|
||||
? [...cards]
|
||||
: cards.filter((card) => card.specialization === view);
|
||||
}
|
||||
|
||||
/** Short display form of an opaque handle; the full handle is used for requests only. */
|
||||
export function shortHandle(handle: string): string {
|
||||
return `${handle.slice(0, 12)}...`;
|
||||
}
|
||||
Reference in new issue
Block a user