fix(clients): minor-specific KYC document types (Birth Certificate/School ID) never appeared
filterDocTypesForMinor() only ever removes entries. The initial (pre-DOB, isMinor=false) seed already stripped Birth Certificate/School ID Card out of kycDocumentTypes, so the isMinor ngOnChanges handler re-filtering that same shortened list could never bring them back once the client turned out to be a minor. Rebuild from the full defaultDocumentTypes source instead (matching how the initial seed itself is built) whenever isMinor changes and the backend KYC template hasn't already taken over. Also gives School ID Card the "Government-issued ID" category it was missing, so it groups with Aadhaar/Passport/Birth Certificate instead of "Other". Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -607,11 +607,19 @@ export class ClientKycStepComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this.kycForm.get('hasPan')?.setValue(false);
|
||||
this.kycForm.get('panNumber')?.setValue('');
|
||||
}
|
||||
const filtered = this.filterDocTypesForMinor(this.kycDocumentTypes);
|
||||
if (filtered.length !== this.kycDocumentTypes.length) {
|
||||
this.kycDocumentTypes = filtered;
|
||||
// Re-derive from the full default list, not by re-filtering the already-narrowed
|
||||
// `kycDocumentTypes` — filterDocTypesForMinor() only ever REMOVES entries, so once the
|
||||
// initial (pre-DOB, isMinor=false) seed has already stripped out Birth Certificate /
|
||||
// School ID Card, re-filtering that same shortened list can never bring them back once
|
||||
// the client turns out to be a minor. Once the backend KYC template has loaded
|
||||
// (kycTemplateLoaded), that list is already minor-aware and authoritative — leave it alone.
|
||||
if (!this.kycTemplateLoaded) {
|
||||
const rebuilt = this.filterDocTypesForMinor(
|
||||
this.defaultDocumentTypes.map((d) => ({ name: d.name, code: d.code, mandatory: false }))
|
||||
);
|
||||
this.kycDocumentTypes = rebuilt;
|
||||
const currentName = this.kycForm.get('kycDocumentName')?.value;
|
||||
if (currentName && !filtered.some((d) => d.name === currentName)) {
|
||||
if (currentName && !rebuilt.some((d) => d.name === currentName)) {
|
||||
this.kycForm.get('kycDocumentName')?.setValue('');
|
||||
}
|
||||
this.rebuildKycDocPicker();
|
||||
|
||||
Reference in New Issue
Block a user