diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a7a134f..66bffbb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,3 +46,12 @@ repos: - "@typescript-eslint/eslint-plugin" - "@typescript-eslint/parser" - svelte-eslint-parser + - repo: local + hooks: + - id: svelte-check + name: Svelte check + language: system + entry: npx svelte-check --fail-on-warnings + always_run: true + pass_filenames: false + require_serial: true diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 4ed9f66..9019445 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -32,7 +32,7 @@ "prettier": "^2.8.8", "prettier-plugin-svelte": "^2.10.1", "svelte": "^4.2.2", - "svelte-check": "^3.4.3", + "svelte-check": "^3.5.2", "tailwindcss": "^3.3.2", "tslib": "^2.4.1", "typescript": "^5.0.0", diff --git a/frontend/package.json b/frontend/package.json index 634c44f..ab59c1f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -29,7 +29,7 @@ "prettier": "^2.8.8", "prettier-plugin-svelte": "^2.10.1", "svelte": "^4.2.2", - "svelte-check": "^3.4.3", + "svelte-check": "^3.5.2", "tailwindcss": "^3.3.2", "tslib": "^2.4.1", "typescript": "^5.0.0", diff --git a/frontend/src/lib/RatingInstalls.svelte b/frontend/src/lib/RatingInstalls.svelte index 41e8904..ba2237a 100644 --- a/frontend/src/lib/RatingInstalls.svelte +++ b/frontend/src/lib/RatingInstalls.svelte @@ -1,20 +1,21 @@ -
{app.name}
- {#if app.rating_count != 0 && app.rating_count != 'N/A'} + {#if app.rating_count != '0' && app.rating_count != 'N/A'}
({app.rating_count})
{/if} - {#if app.installs != 0 && app.installs != 'N/A'} + {#if app.installs != '0' && app.installs != 'N/A'}
diff --git a/frontend/src/lib/RatingInstallsLarge.svelte b/frontend/src/lib/RatingInstallsLarge.svelte new file mode 100644 index 0000000..b643935 --- /dev/null +++ b/frontend/src/lib/RatingInstallsLarge.svelte @@ -0,0 +1,31 @@ + + +
+
{app.name}
+ + {#if app.installs != '0' && app.installs != 'N/A'} +
+
+ + {app.installs} +
+
+ {/if} + + + + {#if app.rating_count != '0' && app.rating_count != 'N/A'} +
+ Ratings: {app.rating_count} +
+ Reviews: {app.review_count} +
+ {:else} + Ratings not yet available + {/if} +
diff --git a/frontend/src/routes/+layout.server.ts b/frontend/src/routes/+layout.server.ts index c7f9ad0..f7fb088 100644 --- a/frontend/src/routes/+layout.server.ts +++ b/frontend/src/routes/+layout.server.ts @@ -1,11 +1,7 @@ export const ssr = true; export const csr = false; -export interface Categories { - mycats: any; - status?: number; - error?: string; -} +import type { Categories, MyCats } from '../types'; /** @type {import('./$types').PageServerLoad} */ export async function load(): Promise { @@ -17,14 +13,14 @@ export async function load(): Promise { throw new Error(`Failed to fetch categories with status ${res.status}`); } - const categories = await res.json(); + const categories: MyCats = await res.json(); console.log(`load categories len: ${Object.keys(categories).length}`); return { mycats: categories }; } catch (error) { console.error('Failed to load layout categories data:', error); return { - mycats: null, + mycats: { categories: {} }, status: 500, error: 'Failed to load categories' }; diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index f682c00..acf0f91 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -1,4 +1,4 @@ - diff --git a/frontend/src/routes/apps/[id]/+page.server.ts b/frontend/src/routes/apps/[id]/+page.server.ts index 18ec110..87fac64 100644 --- a/frontend/src/routes/apps/[id]/+page.server.ts +++ b/frontend/src/routes/apps/[id]/+page.server.ts @@ -1,8 +1,10 @@ export const ssr = true; export const csr = true; +import type { AppFullDetails } from '../../../types.js'; + /** @type {import('../[id]/$types').PageServerLoad} */ -export async function load({ params }) { +export async function load({ params }): Promise { console.log('load app started'); try { const id = params.id; diff --git a/frontend/src/routes/apps/[id]/+page.svelte b/frontend/src/routes/apps/[id]/+page.svelte index 45054cf..a8b615c 100644 --- a/frontend/src/routes/apps/[id]/+page.svelte +++ b/frontend/src/routes/apps/[id]/+page.svelte @@ -1,11 +1,12 @@ - -{#if data} +{#if data.myapp}
@@ -20,7 +21,7 @@ /> {/if}
- {#if data.myapp.installs && data.myapp.installs != 0} + {#if data.myapp.installs && data.myapp.installs != '0'} {/if}
@@ -157,10 +158,4 @@ border-radius: 10px; /* Rounded corners */ /* flex-grow: 1; Allow the bar to grow and take available space */ } - - .label, - .count { - margin: 0 10px; - font-size: 14px; - } diff --git a/frontend/src/routes/collections/[collection]/+page.server.ts b/frontend/src/routes/collections/[collection]/+page.server.ts index fda2609..60ee366 100644 --- a/frontend/src/routes/collections/[collection]/+page.server.ts +++ b/frontend/src/routes/collections/[collection]/+page.server.ts @@ -1,16 +1,12 @@ export const ssr: boolean = true; export const csr: boolean = true; -console.log('Script executed'); +import type { Collection, Collections } from '../../../types.js'; -interface LoadResponse { - myapps: any; - status?: number; - error?: string; -} +console.log('Script executed'); /** @type {import('../[collection]/$types').PageServerLoad} */ -export async function load({ params }): Promise { +export async function load({ params }): Promise { const collectionValue = params.collection; console.log(`load started collection=${collectionValue}`); try { @@ -21,13 +17,12 @@ export async function load({ params }): Promise { throw new Error(`Failed to fetch collections status ${res.status} ${text}`); } - const app_collections: any = await res.json(); + const app_collections: Collection = await res.json(); console.log(`loaded collections with len: ${Object.keys(app_collections).length}`); return { myapps: app_collections }; } catch (error) { console.error('Failed to load data:', error); return { - myapps: {}, status: 500, error: 'Failed to load trending apps' }; diff --git a/frontend/src/routes/collections/[collection]/+page.svelte b/frontend/src/routes/collections/[collection]/+page.svelte index 49c614d..becd37a 100644 --- a/frontend/src/routes/collections/[collection]/+page.svelte +++ b/frontend/src/routes/collections/[collection]/+page.svelte @@ -1,8 +1,9 @@ -