Show badges in nav but don't show any on the page

This commit is contained in:
Kalle
2022-07-03 13:23:34 +03:00
parent 350a435a68
commit d50d2ccaa7
3 changed files with 9 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
[
{ "name": "badges", "displayName": "Badges", "url": "badges" },
{
"name": "plus",
"displayName": "Plus Server",

View File

@@ -19,17 +19,16 @@ export function countsByUserId(userId: User["id"]) {
return countsByUserIdStm.all({ userId }) as CountsByUserId;
}
const allWithAtLeastOneOwnerStm = sql.prepare(`
const allStm = sql.prepare(`
select "Badge"."id", "Badge"."code", "Badge"."displayName"
from "Badge"
`);
export type AllWithAtLeastOneOwner = Array<
Pick<Badge, "id" | "displayName" | "code">
>;
export type All = Array<Pick<Badge, "id" | "displayName" | "code">>;
export function allWithAtLeastOneOwner() {
return allWithAtLeastOneOwnerStm.all() as AllWithAtLeastOneOwner;
export function all() {
return []; // TODO: remove when page is done
return allStm.all() as All;
}
export type OwnersByBadge = Array<

View File

@@ -2,7 +2,7 @@ import type { LinksFunction, LoaderFunction } from "@remix-run/node";
import { Link, Outlet, useLoaderData, useParams } from "@remix-run/react";
import { Main } from "~/components/Main";
import { db } from "~/db";
import type { AllWithAtLeastOneOwner } from "~/db/models/badges.server";
import type { All } from "~/db/models/badges.server";
import styles from "~/styles/badges.css";
import { jsonCached } from "~/utils/remix";
@@ -11,14 +11,11 @@ export const links: LinksFunction = () => {
};
export interface BadgesLoaderData {
badges: AllWithAtLeastOneOwner;
badges: All;
}
export const loader: LoaderFunction = () => {
return jsonCached<BadgesLoaderData>(
{ badges: db.badges.allWithAtLeastOneOwner() },
120
);
return jsonCached<BadgesLoaderData>({ badges: db.badges.all() }, 120);
};
// xxx: https://web.dev/replace-gifs-with-videos/ check possibility to replace gif