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
+19 -8
View File
@@ -788,14 +788,25 @@ export async function getPendingApprovalsForReferrer(
const applicantAddress = key.args[0].toString();
const appData = (value as any).toJSON() as Record<string, unknown>;
if (
appData.status === 'PendingReferral' &&
appData.referrer?.toString() === referrerAddress
) {
pending.push({
applicantAddress,
identityHash: (appData.identityHash as string) || ''
});
// Application struct has { identityHash, referrer } - no status field.
// An application is "pending" if it exists in applications but is NOT yet
// 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({
applicantAddress,
identityHash: (appData.identityHash as string) || ''
});
}
}
}