mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
feat: convert ConnectionModal to /connection page with crypto deep links
- Add @kastov/cryptohapp + jsencrypt for encrypted Happ deep links
- Add templateEngine utility to resolve {{SUBSCRIPTION_LINK}},
{{HAPP_CRYPT3_LINK}}, {{HAPP_CRYPT4_LINK}}, {{USERNAME}} templates
- Convert ConnectionModal component into a standalone Connection page
- Add /connection route with ProtectedRoute and lazy loading
- Replace modal invocation in Dashboard and Subscription with
navigate('/connection')
- Add type and svgIconKey optional fields to RemnawaveButton
- Show button type badge and SVG icon in AdminApps BlockCard
- Refactor ThemeTab to use local draft state with Save/Cancel flow
This commit is contained in:
32
src/utils/templateEngine.ts
Normal file
32
src/utils/templateEngine.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { createHappCryptoLink } from '@kastov/cryptohapp';
|
||||
|
||||
const TEMPLATE_RE = /\{\{[A-Z0-9_]+\}\}/;
|
||||
|
||||
export function hasTemplates(url: string): boolean {
|
||||
return TEMPLATE_RE.test(url);
|
||||
}
|
||||
|
||||
interface ResolveContext {
|
||||
subscriptionUrl: string;
|
||||
username?: string;
|
||||
}
|
||||
|
||||
export function resolveTemplate(template: string, ctx: ResolveContext): string {
|
||||
let result = template;
|
||||
|
||||
result = result.replace(/\{\{SUBSCRIPTION_LINK\}\}/g, ctx.subscriptionUrl);
|
||||
|
||||
if (ctx.username) {
|
||||
result = result.replace(/\{\{USERNAME\}\}/g, ctx.username);
|
||||
}
|
||||
|
||||
result = result.replace(/\{\{HAPP_CRYPT3_LINK\}\}/g, () => {
|
||||
return createHappCryptoLink(ctx.subscriptionUrl, 'v3', true) ?? ctx.subscriptionUrl;
|
||||
});
|
||||
|
||||
result = result.replace(/\{\{HAPP_CRYPT4_LINK\}\}/g, () => {
|
||||
return createHappCryptoLink(ctx.subscriptionUrl, 'v4', true) ?? ctx.subscriptionUrl;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user