feat(demo): add the jury guide and demonstration markers to the demo stand build

This commit is contained in:
shira committed 2026-10-10 01:27:17 +03:00
1 parent d365a05c96
commit 41206abbcf
32 files changed
+1096 -141

No files matched your search

@@ -1,13 +1,17 @@
import { ApiRequestError, invalidResponseCode } from "../../../shared/api";
import {
createOrganizationInvitation,
getGetOrganizationInvitationContactsQueryKey,
getGetOrganizationInvitationQueryKey,
getOrganizationInvitation,
getOrganizationInvitationContacts,
sendOrganizationInvitation,
updateOrganizationInvitation,
} from "../../../shared/api/endpoints/invitation/invitation";
import {
ContactDisclosure as contactDisclosureSchema,
OrganizationInvitation as organizationInvitationSchema,
type ContactDisclosure,
type OrganizationInvitation,
type OrganizationInvitationCreate,
type OrganizationInvitationUpdate,
@@ -100,8 +104,30 @@ export async function readOrganizationInvitation(
);
}
/**
* Reads the contacts that an active grant of an accepted invitation covers.
* The server answers 404 when no grant is readable, which the caller shows as
* "not available" without asking for a reason.
*/
export async function readInvitationContacts(
organizationId: string,
invitationId: string,
signal: AbortSignal | undefined = undefined,
): Promise<ContactDisclosure> {
const parsed = contactDisclosureSchema.safeParse(
await getOrganizationInvitationContacts(organizationId, invitationId, signal ? { signal } : {}),
);
if (!parsed.success) throw invalidResponse();
return parsed.data;
}
/** Invitation reads stay separate for each signed-in account. */
export const invitationQueryKeys = {
detail: (accountId: string, organizationId: string, invitationId: string) =>
[...getGetOrganizationInvitationQueryKey(organizationId, invitationId), accountId] as const,
contacts: (accountId: string, organizationId: string, invitationId: string) =>
[
...getGetOrganizationInvitationContactsQueryKey(organizationId, invitationId),
accountId,
] as const,
};
@@ -7,10 +7,12 @@
export {
createInvitationDraft,
invitationQueryKeys,
readInvitationContacts,
readOrganizationInvitation,
sendInvitationDraft,
updateInvitationDraft,
} from "./api/organization-invitations";
export { contactRows, type ContactRow } from "./model/contact-disclosure";
export {
acceptCandidateInvitation,
candidateInvitationQueryKeys,
@@ -0,0 +1,38 @@
import { describe, expect, it } from "vitest";
import type { ContactDisclosure } from "../../../shared/api/schemas";
import { contactRows } from "./contact-disclosure";
const base: ContactDisclosure = {
invitation_id: "01928f7a-7a8b-7c9d-8e0f-1a2b3c4d5e60",
grant_id: "01928f7a-7a8b-7c9d-8e0f-1a2b3c4d5e61",
fields: ["email"],
granted_at: "2026-10-09T10:00:00Z",
full_name: null,
email: "candidate@example.test",
phone: null,
telegram: null,
};
describe("contactRows", () => {
it("lists only the kinds the grant covers", () => {
expect(contactRows(base)).toEqual([
{ kind: "email", label: "Электронная почта", value: "candidate@example.test" },
]);
});
it("keeps the contract order of the kinds whatever order the server sends them in", () => {
const rows = contactRows({ ...base, fields: ["telegram", "full_name", "email"] });
expect(rows.map((row) => row.kind)).toEqual(["full_name", "email", "telegram"]);
});
it("shows a covered kind with a null value when the profile no longer holds it", () => {
const rows = contactRows({ ...base, fields: ["phone"], phone: null });
expect(rows).toEqual([{ kind: "phone", label: "Телефон", value: null }]);
});
it("returns no rows for a grant that covers nothing", () => {
expect(contactRows({ ...base, fields: [] })).toEqual([]);
});
});
@@ -0,0 +1,30 @@
import type { ContactDisclosure, ContactFieldKind } from "../../../shared/api/schemas";
import { contactKindLabels, orderedContactKinds } from "./candidate-labels";
export type ContactRow = {
readonly kind: ContactFieldKind;
readonly label: string;
/** Null when the grant covers the kind but the profile no longer holds the value. */
readonly value: string | null;
};
const valueOf: Readonly<
Record<ContactFieldKind, (disclosure: ContactDisclosure) => string | null>
> = {
full_name: (disclosure) => disclosure.full_name,
email: (disclosure) => disclosure.email,
phone: (disclosure) => disclosure.phone,
telegram: (disclosure) => disclosure.telegram,
};
/**
* Rows for the kinds that the grant covers, in contract order. A kind outside
* the grant gets no row, so nothing reads as "not disclosed" by accident.
*/
export function contactRows(disclosure: ContactDisclosure): ContactRow[] {
return orderedContactKinds(disclosure.fields).map((kind) => ({
kind,
label: contactKindLabels[kind],
value: valueOf[kind](disclosure),
}));
}