fix: citizenship pending approvals not showing for founder

Application struct has no status field - was filtering by
appData.status === 'PendingReferral' which always returned false.
Now checks kycStatuses storage instead, and allows founder to see
all pending applications.
This commit is contained in:
2026-02-20 00:44:05 +03:00
parent ecda5374e4
commit 6ac55ecf88
+15 -4
View File
@@ -788,16 +788,27 @@ export async function getPendingApprovalsForReferrer(
const applicantAddress = key.args[0].toString(); const applicantAddress = key.args[0].toString();
const appData = (value as any).toJSON() as Record<string, unknown>; const appData = (value as any).toJSON() as Record<string, unknown>;
if ( // Application struct has { identityHash, referrer } - no status field.
appData.status === 'PendingReferral' && // An application is "pending" if it exists in applications but is NOT yet
appData.referrer?.toString() === referrerAddress // approved in kycStatuses. Check referrer matches current user, or current
) { // user is the founder (can approve any application).
const isReferrer = appData.referrer?.toString() === referrerAddress;
const isFounder = referrerAddress === FOUNDER_ADDRESS;
if (isReferrer || isFounder) {
// Check if already approved via kycStatuses
const kycStatus = await api.query.identityKyc.kycStatuses(applicantAddress);
const statusStr = kycStatus.isEmpty ? null : kycStatus.toString();
// Pending = not yet approved (no status or PendingReferral)
if (!statusStr || statusStr === 'PendingReferral') {
pending.push({ pending.push({
applicantAddress, applicantAddress,
identityHash: (appData.identityHash as string) || '' identityHash: (appData.identityHash as string) || ''
}); });
} }
} }
}
return pending; return pending;
} catch (error) { } catch (error) {