fix: demo page inlanding

This commit is contained in:
Oleg Proskurin 2025-10-05 19:41:04 +07:00
parent bfff9b49ec
commit 97502ddae1
4 changed files with 39 additions and 34 deletions

View File

@ -89,35 +89,14 @@ export const createApp = (): Application => {
const apiKey = await apiKeyService.validateKey(providedKey);
if (apiKey) {
// Query org and project names
let organizationName = apiKey.organizationId;
let projectName = apiKey.projectId;
try {
const { db } = await import('./db');
const { organizations, projects } = await import('@banatie/database');
const { eq } = await import('drizzle-orm');
if (apiKey.organizationId) {
const org = await db.select().from(organizations).where(eq(organizations.id, apiKey.organizationId)).limit(1);
if (org.length > 0) organizationName = org[0].name;
}
if (apiKey.projectId) {
const proj = await db.select().from(projects).where(eq(projects.id, apiKey.projectId)).limit(1);
if (proj.length > 0) projectName = proj[0].name;
}
} catch (dbError) {
// Fallback to IDs if DB query fails
}
// Use slugs from validated API key (already fetched via LEFT JOIN)
info.authenticated = true;
info.keyInfo = {
type: apiKey.keyType,
organizationId: apiKey.organizationId,
organizationName,
organizationSlug: apiKey.organizationSlug,
projectId: apiKey.projectId,
projectName,
projectSlug: apiKey.projectSlug,
expiresAt: apiKey.expiresAt
};
}

View File

@ -24,8 +24,8 @@ interface GenerationResult {
}
interface ApiKeyInfo {
organizationName?: string;
projectName?: string;
organizationSlug?: string;
projectSlug?: string;
}
export default function DemoTTIPage() {
@ -74,13 +74,13 @@ export default function DemoTTIPage() {
// Extract org/project info from API response
if (data.keyInfo) {
setApiKeyInfo({
organizationName: data.keyInfo.organizationName || data.keyInfo.organizationId,
projectName: data.keyInfo.projectName || data.keyInfo.projectId,
organizationSlug: data.keyInfo.organizationSlug || data.keyInfo.organizationId,
projectSlug: data.keyInfo.projectSlug || data.keyInfo.projectId,
});
} else {
setApiKeyInfo({
organizationName: 'Unknown',
projectName: 'Unknown',
organizationSlug: 'Unknown',
projectSlug: 'Unknown',
});
}
} else{
@ -264,7 +264,7 @@ export default function DemoTTIPage() {
{apiKeyValidated && apiKeyInfo && (
<div className="mt-3 text-sm text-green-400">
Validated {apiKeyInfo.organizationName} / {apiKeyInfo.projectName}
Validated {apiKeyInfo.organizationSlug} / {apiKeyInfo.projectSlug}
</div>
)}
</div>

View File

@ -50,6 +50,7 @@
"author": "",
"license": "MIT",
"devDependencies": {
"kill-port": "^2.0.1",
"typescript": "^5.9.2"
}
}

View File

@ -8,6 +8,9 @@ importers:
.:
devDependencies:
kill-port:
specifier: ^2.0.1
version: 2.0.1
typescript:
specifier: ^5.9.2
version: 5.9.2
@ -163,6 +166,9 @@ importers:
apps/landing:
dependencies:
'@banatie/database':
specifier: workspace:*
version: link:../../packages/database
next:
specifier: 15.5.4
version: 15.5.4(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
@ -2997,6 +3003,9 @@ packages:
resolution: {integrity: sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==}
engines: {node: '>= 0.4'}
get-them-args@1.3.2:
resolution: {integrity: sha512-LRn8Jlk+DwZE4GTlDbT3Hikd1wSHgLMme/+7ddlqKd7ldwR6LjJgTVWzBnR01wnYGe4KgrXjg287RaI22UHmAw==}
get-tsconfig@4.10.1:
resolution: {integrity: sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==}
@ -3535,6 +3544,10 @@ packages:
keyv@4.5.4:
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
kill-port@2.0.1:
resolution: {integrity: sha512-e0SVOV5jFo0mx8r7bS29maVWp17qGqLBZ5ricNSajON6//kmb7qqqNnml4twNE8Dtj97UQD+gNFOaipS/q1zzQ==}
hasBin: true
kleur@3.0.3:
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
engines: {node: '>=6'}
@ -4312,6 +4325,9 @@ packages:
resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==}
engines: {node: '>=8'}
shell-exec@1.0.2:
resolution: {integrity: sha512-jyVd+kU2X+mWKMmGhx4fpWbPsjvD53k9ivqetutVW/BQ+WIZoDoP4d8vUMGezV6saZsiNoW2f9GIhg9Dondohg==}
side-channel-list@1.0.0:
resolution: {integrity: sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==}
engines: {node: '>= 0.4'}
@ -7263,7 +7279,7 @@ snapshots:
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.44.0(eslint@8.57.1)(typescript@5.9.2))(eslint@8.57.1))(eslint@8.57.1)
eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.44.0(eslint@8.57.1)(typescript@5.9.2))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.44.0(eslint@8.57.1)(typescript@5.9.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1)
eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.44.0(eslint@8.57.1)(typescript@5.9.2))(eslint-import-resolver-typescript@3.10.1)(eslint@8.57.1)
eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1)
eslint-plugin-react: 7.37.5(eslint@8.57.1)
eslint-plugin-react-hooks: 5.0.0-canary-7118f5dd7-20230705(eslint@8.57.1)
@ -7297,7 +7313,7 @@ snapshots:
tinyglobby: 0.2.15
unrs-resolver: 1.11.1
optionalDependencies:
eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.44.0(eslint@8.57.1)(typescript@5.9.2))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.44.0(eslint@8.57.1)(typescript@5.9.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1)
eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.44.0(eslint@8.57.1)(typescript@5.9.2))(eslint-import-resolver-typescript@3.10.1)(eslint@8.57.1)
transitivePeerDependencies:
- supports-color
@ -7312,7 +7328,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.44.0(eslint@8.57.1)(typescript@5.9.2))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.44.0(eslint@8.57.1)(typescript@5.9.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1):
eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.44.0(eslint@8.57.1)(typescript@5.9.2))(eslint-import-resolver-typescript@3.10.1)(eslint@8.57.1):
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.9
@ -7778,6 +7794,8 @@ snapshots:
es-errors: 1.3.0
get-intrinsic: 1.3.0
get-them-args@1.3.2: {}
get-tsconfig@4.10.1:
dependencies:
resolve-pkg-maps: 1.0.0
@ -8551,6 +8569,11 @@ snapshots:
dependencies:
json-buffer: 3.0.1
kill-port@2.0.1:
dependencies:
get-them-args: 1.3.2
shell-exec: 1.0.2
kleur@3.0.3: {}
kuler@2.0.0: {}
@ -9355,6 +9378,8 @@ snapshots:
shebang-regex@3.0.0: {}
shell-exec@1.0.2: {}
side-channel-list@1.0.0:
dependencies:
es-errors: 1.3.0