♻️ Remove unused and update utils (#1786)

This commit is contained in:
Luke Vella 2025-06-23 11:07:26 +01:00 committed by GitHub
parent 7ab25c68de
commit 40d6a51245
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 67 deletions

View file

@ -1,37 +0,0 @@
"use client";
import { Button } from "@rallly/ui/button";
import { ArrowUpLeftIcon } from "lucide-react";
import Link from "next/link";
import { PageHeader } from "@/app/components/page-layout";
import { Trans } from "@/components/trans";
import { UserDropdown } from "@/components/user-dropdown";
import { useUser } from "@/components/user-provider";
import { usePoll } from "@/contexts/poll";
export const Nav = () => {
const poll = usePoll();
const { user } = useUser();
return (
<PageHeader variant="ghost">
<div className="flex justify-between">
<div>
<Button
variant="ghost"
asChild
className={poll.userId !== user.id ? "hidden" : ""}
>
<Link href={`/poll/${poll.id}`}>
<ArrowUpLeftIcon className="size-4 text-muted-foreground" />
<Trans i18nKey="manage" />
</Link>
</Button>
</div>
<div>
<UserDropdown />
</div>
</div>
</PageHeader>
);
};

View file

@ -1,23 +0,0 @@
import { prisma } from "@rallly/database";
import { privateProcedure, router } from "../trpc";
export const dashboard = router({
info: privateProcedure.query(async ({ ctx }) => {
const activePollCount = await prisma.poll.count({
where: {
...(ctx.user.isGuest
? {
guestId: ctx.user.id,
}
: {
userId: ctx.user.id,
}),
status: "live",
deleted: false, // TODO (Luke Vella) [2024-06-16]: We should add deleted/cancelled to the status enum
},
});
return { activePollCount };
}),
});

View file

@ -5,7 +5,6 @@ import utc from "dayjs/plugin/utc";
import { mergeRouters, router } from "../trpc"; import { mergeRouters, router } from "../trpc";
import { auth } from "./auth"; import { auth } from "./auth";
import { dashboard } from "./dashboard";
import { polls } from "./polls"; import { polls } from "./polls";
import { user } from "./user"; import { user } from "./user";
@ -18,7 +17,6 @@ export const appRouter = mergeRouters(
auth, auth,
polls, polls,
user, user,
dashboard,
}), }),
); );

View file

@ -15,7 +15,10 @@ function joinPath(baseUrl: string, subpath = "") {
return baseUrl; return baseUrl;
} }
export function absoluteUrl(subpath = "", query: Record<string, string> = {}) { export function absoluteUrl(
subpath = "",
query: { [key: string]: string | undefined } = {},
) {
const baseUrl = const baseUrl =
process.env.NEXT_PUBLIC_BASE_URL ?? process.env.NEXT_PUBLIC_BASE_URL ??
getVercelUrl() ?? getVercelUrl() ??
@ -23,10 +26,11 @@ export function absoluteUrl(subpath = "", query: Record<string, string> = {}) {
const url = new URL(subpath, baseUrl); const url = new URL(subpath, baseUrl);
// biome-ignore lint/complexity/noForEach: Fix this later for (const [key, value] of Object.entries(query)) {
Object.entries(query).forEach(([key, value]) => { if (value) {
url.searchParams.set(key, value); url.searchParams.set(key, value);
}); }
}
const urlString = url.href; const urlString = url.href;