mirror of
https://github.com/selfxyz/self.git
synced 2026-02-19 02:24:25 -05:00
* add document selector test screen * clean up mock docs * update selection options * Add DocumentSelectorForProving screen and route proof flows through it (#1555) * Add document selector to proving flow * fix formatting * improvements * redirect user to document not found screen when no documents * option flow tweaks and tests * wip tweaks * fix scrollview bottom padding (#1556) * tighten up selection text * create inerstitial * save wip * remove not accepted state * save wip design * formatting * update design * update layout * Update proving flow tests (#1559) * Refactor ProveScreen to ProofRequestCard layout and preserve scroll position (#1560) * Refactor prove screen layout * fix: amount of hooks rendered needs to be the same for all variants * long URL ellipsis * keep titles consistent * lint --------- Co-authored-by: Leszek Stachowski <leszek.stachowski@self.xyz> * wip fix tests * fix tests * formatting * agent feedback * fix tests * save wip * remove text * fix types * save working header update * no transition * cache document load for proving flow * save fixes * small fixes * match disclosure text * design updates * fix approve flow * fix document type flash * add min height so text doesn't jump * update lock * formatting * save refactor wip * don't enable euclid yet * fix tests * fix staleness check * fix select box description * remove id selector screen * vertically center * button updates * Remove proving document cache (#1567) * formatting --------- Co-authored-by: Leszek Stachowski <leszek.stachowski@self.xyz>
90 lines
2.5 KiB
TypeScript
90 lines
2.5 KiB
TypeScript
// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
|
|
|
|
import type { Country3LetterCode } from '@selfxyz/common/constants';
|
|
import { countryCodes } from '@selfxyz/common/constants';
|
|
import type { SelfAppDisclosureConfig } from '@selfxyz/common/utils/appType';
|
|
|
|
function listToString(list: string[]): string {
|
|
if (list.length === 1) {
|
|
return list[0];
|
|
} else if (list.length === 2) {
|
|
return list.join(' nor ');
|
|
}
|
|
return `${list.slice(0, -1).join(', ')} nor ${list.at(-1)}`;
|
|
}
|
|
|
|
function countriesToSentence(countries: Country3LetterCode[]): string {
|
|
return listToString(countries.map(country => countryCodes[country]));
|
|
}
|
|
|
|
export const ORDERED_DISCLOSURE_KEYS: Array<keyof SelfAppDisclosureConfig> = [
|
|
'issuing_state',
|
|
'name',
|
|
'passport_number',
|
|
'nationality',
|
|
'date_of_birth',
|
|
'gender',
|
|
'expiry_date',
|
|
'ofac',
|
|
'excludedCountries',
|
|
'minimumAge',
|
|
] as const;
|
|
|
|
export function getDisclosureItems(
|
|
disclosures: SelfAppDisclosureConfig,
|
|
): Array<{ key: string; text: string }> {
|
|
const items: Array<{ key: string; text: string }> = [];
|
|
|
|
for (const key of ORDERED_DISCLOSURE_KEYS) {
|
|
const isEnabled = disclosures[key];
|
|
if (!isEnabled || (Array.isArray(isEnabled) && isEnabled.length === 0)) {
|
|
continue;
|
|
}
|
|
|
|
const text = getDisclosureText(key, disclosures);
|
|
if (text) {
|
|
items.push({ key, text });
|
|
}
|
|
}
|
|
|
|
return items;
|
|
}
|
|
|
|
/**
|
|
* Generates the display text for a disclosure key.
|
|
* This is the single source of truth for disclosure text across the app.
|
|
*/
|
|
export function getDisclosureText(
|
|
key: keyof SelfAppDisclosureConfig,
|
|
disclosures: SelfAppDisclosureConfig,
|
|
): string {
|
|
switch (key) {
|
|
case 'ofac':
|
|
return 'I am not on the OFAC sanction list';
|
|
case 'excludedCountries':
|
|
return `I am not a citizen of the following countries: ${countriesToSentence(
|
|
(disclosures.excludedCountries as Country3LetterCode[]) || [],
|
|
)}`;
|
|
case 'minimumAge':
|
|
return `Age is over ${disclosures.minimumAge}`;
|
|
case 'name':
|
|
return 'Name';
|
|
case 'passport_number':
|
|
return 'Passport Number';
|
|
case 'date_of_birth':
|
|
return 'Date of Birth';
|
|
case 'gender':
|
|
return 'Gender';
|
|
case 'expiry_date':
|
|
return 'Passport Expiry Date';
|
|
case 'issuing_state':
|
|
return 'Issuing State';
|
|
case 'nationality':
|
|
return 'Nationality';
|
|
default:
|
|
return '';
|
|
}
|
|
}
|