diff --git a/public/i18n/en.json b/public/i18n/en.json index dc91bc0..7899000 100644 --- a/public/i18n/en.json +++ b/public/i18n/en.json @@ -47,7 +47,9 @@ "modal_paid_title": "Paid", "modal_paid_sub": "fastCHECK successfully accepted.", "share_email": "Send by email", - "share_tg": "Send via Telegram" + "share_tg": "Send via Telegram", + "modal_loggedin_title": "Signed in", + "modal_loggedin_sub": "You are now signed in to fastCHECK." }, "create": { "title": "New", diff --git a/public/i18n/hy.json b/public/i18n/hy.json index b1596a3..93fb2c9 100644 --- a/public/i18n/hy.json +++ b/public/i18n/hy.json @@ -47,7 +47,9 @@ "modal_paid_title": "Վճարված է", "modal_paid_sub": "fastCHECK-ը հաջողությամբ ընդունված է:", "share_email": "Ուղարկել էլ. նամակով", - "share_tg": "Ուղարկել Telegram-ով" + "share_tg": "Ուղարկել Telegram-ով", + "modal_loggedin_title": "Մուտք գործել", + "modal_loggedin_sub": "Դուք մուտք գործել եք fastCHECK:" }, "create": { "title": "Նոր", diff --git a/public/i18n/ru.json b/public/i18n/ru.json index d4a025b..837bac6 100644 --- a/public/i18n/ru.json +++ b/public/i18n/ru.json @@ -47,7 +47,9 @@ "modal_paid_title": "Оплачено", "modal_paid_sub": "fastCHECK успешно принят.", "share_email": "Отправить на почту", - "share_tg": "Отправить в Telegram" + "share_tg": "Отправить в Telegram", + "modal_loggedin_title": "Вы вошли", + "modal_loggedin_sub": "Вы авторизованы в fastCHECK." }, "create": { "title": "Новый", diff --git a/public/logo_big.png b/public/logo_big.png index 1bec9be..188e680 100644 Binary files a/public/logo_big.png and b/public/logo_big.png differ diff --git a/src/app/pages/fastcheck-page/fastcheck-page.html b/src/app/pages/fastcheck-page/fastcheck-page.html index 614d6d4..72a4de9 100644 --- a/src/app/pages/fastcheck-page/fastcheck-page.html +++ b/src/app/pages/fastcheck-page/fastcheck-page.html @@ -133,11 +133,16 @@ stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"> - - + @if (loginOnly()) { + + + } @else { + + + } } @else { (''); webSessionId = signal(''); paid = signal(false); + loginOnly = signal(false); + sessionToken = signal(localStorage.getItem('fc_session') ?? ''); private pollHandle: ReturnType | null = null; private lastLookedUpNumber = ''; @@ -113,6 +115,7 @@ export class FastcheckPage { return; } this.error.set(''); + this.loginOnly.set(false); this.openPopup(); } @@ -122,6 +125,32 @@ export class FastcheckPage { this.paid.set(false); this.popupLoading.set(true); + const existing = this.sessionToken(); + if (existing) { + this.http.get(`${FASTCHECK_API}/websession/${existing}`).subscribe({ + next: (res) => { + if (res?.Status) { + this.popupLoading.set(false); + this.webSessionId.set(existing); + if (this.loginOnly()) { + this.paid.set(true); + } else { + this.acceptFastcheck(existing); + } + } else { + this.sessionToken.set(''); + this.createNewSession(); + } + }, + error: () => { this.sessionToken.set(''); this.createNewSession(); } + }); + return; + } + + this.createNewSession(); + } + + private createNewSession(): void { this.http.get(`${FASTCHECK_API}/websession`).subscribe({ next: (res) => { this.popupLoading.set(false); @@ -142,13 +171,20 @@ export class FastcheckPage { closePopup(): void { this.popupOpen.set(false); this.stopPolling(); - if (this.webSessionId()) { + if (this.loginOnly() && this.paid()) { + // Keep session alive — user is logged in, preserve token for next action. + const tok = this.webSessionId(); + localStorage.setItem('fc_session', tok); + this.sessionToken.set(tok); + } else if (this.webSessionId()) { // Best-effort logout; ignore errors. this.http .request('DELETE', `${FASTCHECK_API}/websession/${this.webSessionId()}`, { body: { sessionId: this.webSessionId() } }) .subscribe({ error: () => undefined }); + localStorage.removeItem('fc_session'); + this.sessionToken.set(''); } this.webSessionId.set(''); } @@ -162,7 +198,11 @@ export class FastcheckPage { next: (res) => { if (res?.Status) { this.stopPolling(); - this.acceptFastcheck(sessionId); + if (this.loginOnly()) { + this.paid.set(true); + } else { + this.acceptFastcheck(sessionId); + } } }, error: () => undefined @@ -285,9 +325,7 @@ export class FastcheckPage { } shareByTelegram(): void { - const num = this.fastcheckNumber(); - const amount = this.fastcheckAmount(); - const text = encodeURIComponent(`fastCHECK: ${num} — ${amount} ₽`); - window.open(`https://t.me/share/url?url=https%3A%2F%2Fqr.vitanova.network%2F&text=${text}`, '_blank'); + this.loginOnly.set(true); + this.openPopup(); } }