mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-21 10:17:24 +02:00
♻️ Remove unused and update utils (#1786)
This commit is contained in:
parent
7ab25c68de
commit
40d6a51245
4 changed files with 9 additions and 67 deletions
|
@ -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>
|
||||
);
|
||||
};
|
|
@ -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 };
|
||||
}),
|
||||
});
|
|
@ -5,7 +5,6 @@ import utc from "dayjs/plugin/utc";
|
|||
|
||||
import { mergeRouters, router } from "../trpc";
|
||||
import { auth } from "./auth";
|
||||
import { dashboard } from "./dashboard";
|
||||
import { polls } from "./polls";
|
||||
import { user } from "./user";
|
||||
|
||||
|
@ -18,7 +17,6 @@ export const appRouter = mergeRouters(
|
|||
auth,
|
||||
polls,
|
||||
user,
|
||||
dashboard,
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@ function joinPath(baseUrl: string, subpath = "") {
|
|||
return baseUrl;
|
||||
}
|
||||
|
||||
export function absoluteUrl(subpath = "", query: Record<string, string> = {}) {
|
||||
export function absoluteUrl(
|
||||
subpath = "",
|
||||
query: { [key: string]: string | undefined } = {},
|
||||
) {
|
||||
const baseUrl =
|
||||
process.env.NEXT_PUBLIC_BASE_URL ??
|
||||
getVercelUrl() ??
|
||||
|
@ -23,10 +26,11 @@ export function absoluteUrl(subpath = "", query: Record<string, string> = {}) {
|
|||
|
||||
const url = new URL(subpath, baseUrl);
|
||||
|
||||
// biome-ignore lint/complexity/noForEach: Fix this later
|
||||
Object.entries(query).forEach(([key, value]) => {
|
||||
url.searchParams.set(key, value);
|
||||
});
|
||||
for (const [key, value] of Object.entries(query)) {
|
||||
if (value) {
|
||||
url.searchParams.set(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
const urlString = url.href;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue