From 5065e0f70c5719426e0964206e34d785f67b93e7 Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Sat, 28 Feb 2026 01:59:10 +0300 Subject: [PATCH] fix: wire referral deep link to citizenship form via startParam - Detect SS58 address in Telegram startParam and auto-route to CitizenPage - Pass startParam as initialReferrer to CitizenForm - Show read-only referrer badge when pre-filled from referral link --- package.json | 2 +- src/App.tsx | 7 +++++- src/components/citizen/CitizenForm.tsx | 34 +++++++++++++++++--------- src/pages/CitizenPage.tsx | 6 ++++- src/version.json | 6 ++--- 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 68bb3a6..9e11978 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pezkuwi-telegram-miniapp", - "version": "1.0.225", + "version": "1.0.226", "type": "module", "description": "Pezkuwichain Telegram Mini App - Forum, Announcements, Rewards", "author": "Pezkuwichain Team", diff --git a/src/App.tsx b/src/App.tsx index 9b2d98f..dbed0a3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -52,7 +52,12 @@ const NAV_ITEMS: NavItem[] = [ // Check for standalone pages via URL query params or path (evaluated once at module level) const PAGE_PARAM = new URLSearchParams(window.location.search).get('page'); -const IS_CITIZEN_PAGE = PAGE_PARAM === 'citizen' || window.location.pathname === '/citizens'; +const TELEGRAM_START_PARAM = window.Telegram?.WebApp?.initDataUnsafe?.start_param; +// SS58 address for prefix 42 starts with "5" and is 48 chars of base58 +const IS_CITIZENSHIP_REFERRAL = + !!TELEGRAM_START_PARAM && /^5[1-9A-HJ-NP-Za-km-z]{46,47}$/.test(TELEGRAM_START_PARAM); +const IS_CITIZEN_PAGE = + PAGE_PARAM === 'citizen' || window.location.pathname === '/citizens' || IS_CITIZENSHIP_REFERRAL; const IS_EXPLORER_PAGE = window.location.pathname.replace(/\/$/, '') === '/explorer'; export default function App() { diff --git a/src/components/citizen/CitizenForm.tsx b/src/components/citizen/CitizenForm.tsx index ab73e91..32f3a4f 100644 --- a/src/components/citizen/CitizenForm.tsx +++ b/src/components/citizen/CitizenForm.tsx @@ -12,6 +12,7 @@ import type { CitizenshipData, Region, MaritalStatus, ChildInfo } from '@/lib/ci interface Props { onSubmit: (data: CitizenshipData) => void; + initialReferrer?: string; } const REGIONS: { value: Region; labelKey: string }[] = [ @@ -23,7 +24,7 @@ const REGIONS: { value: Region; labelKey: string }[] = [ { value: 'diaspora', labelKey: 'citizen.regionDiaspora' }, ]; -export function CitizenForm({ onSubmit }: Props) { +export function CitizenForm({ onSubmit, initialReferrer }: Props) { const { t } = useTranslation(); const { hapticImpact, hapticNotification } = useTelegram(); @@ -38,7 +39,7 @@ export function CitizenForm({ onSubmit }: Props) { const [region, setRegion] = useState(''); const [email, setEmail] = useState(''); const [profession, setProfession] = useState(''); - const [referrerAddress, setReferrerAddress] = useState(''); + const [referrerAddress, setReferrerAddress] = useState(initialReferrer || ''); const [seedPhrase, setSeedPhrase] = useState(''); const [consent, setConsent] = useState(false); const [error, setError] = useState(''); @@ -377,16 +378,25 @@ export function CitizenForm({ onSubmit }: Props) { {/* Referrer Address */} -
- - setReferrerAddress(e.target.value)} - className={inputClass} - placeholder={t('citizen.referrerPlaceholder')} - /> -
+ {initialReferrer ? ( +
+ +

{initialReferrer}

+
+ ) : ( +
+ + setReferrerAddress(e.target.value)} + className={inputClass} + placeholder={t('citizen.referrerPlaceholder')} + /> +
+ )} {/* Consent */}