refactor: cleanup part 4
This commit is contained in:
parent
f00c998c30
commit
9e36944219
4 changed files with 14 additions and 14 deletions
|
|
@ -5,11 +5,11 @@ import { prisma } from "@/lib/prisma";
|
|||
|
||||
export async function DELETE() {
|
||||
const session = await auth();
|
||||
if (!session) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
if (!session || !session.user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
|
||||
try {
|
||||
await prisma.user.delete({
|
||||
where: { id: Number(session.user?.id!) },
|
||||
where: { id: Number(session.user.id) },
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to delete user:", error);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export default function Carousel({ images, className }: Props) {
|
|||
|
||||
return (
|
||||
<div className="relative w-full h-fit">
|
||||
<div className={`overflow-hidden rounded-xl bg-zinc-300 border-2 border-zinc-300 ${className}`} ref={emblaRef}>
|
||||
<div className={`overflow-hidden rounded-xl bg-zinc-300 border-2 border-zinc-300 ${className ?? ""}`} ref={emblaRef}>
|
||||
<div className="flex">
|
||||
{images.map((src, index) => (
|
||||
<div key={index} className="flex-[0_0_100%]">
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
"use client";
|
||||
|
||||
import { redirect, useSearchParams } from "next/navigation";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { Icon } from "@iconify/react";
|
||||
|
||||
interface Props {
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ export default async function MiiPage({ params }: Props) {
|
|||
</div>
|
||||
|
||||
<div className="flex flex-col gap-1 p-4 col-span-2 max-lg:col-span-1">
|
||||
<h1 className="text-5xl font-extrabold break-words">{mii?.name}</h1>
|
||||
<h1 className="text-4xl font-extrabold break-words">{mii.name}</h1>
|
||||
<div id="tags" className="flex gap-1 mt-1 *:px-2 *:py-1 *:bg-orange-300 *:rounded-full *:text-xs">
|
||||
{mii?.tags.map((tag) => (
|
||||
{mii.tags.map((tag) => (
|
||||
<Link href={{ pathname: "/", query: { tags: tag } }} key={tag}>
|
||||
{tag}
|
||||
</Link>
|
||||
|
|
@ -67,19 +67,19 @@ export default async function MiiPage({ params }: Props) {
|
|||
</div>
|
||||
|
||||
<div className="mt-2">
|
||||
<Link href={`/profile/${mii?.userId}`} className="text-lg">
|
||||
By: <span className="font-bold">@{mii?.user.username}</span>
|
||||
<Link href={`/profile/${mii.userId}`} className="text-lg">
|
||||
By: <span className="font-bold">@{mii.user.username}</span>
|
||||
</Link>
|
||||
<h4 title={`${mii?.createdAt.toLocaleTimeString("en-GB", { timeZone: "UTC" })} UTC`}>
|
||||
Created: {mii?.createdAt.toLocaleDateString("en-GB", { month: "long", day: "2-digit", year: "numeric" })}
|
||||
<h4 title={`${mii.createdAt.toLocaleTimeString("en-GB", { timeZone: "UTC" })} UTC`}>
|
||||
Created: {mii.createdAt.toLocaleDateString("en-GB", { month: "long", day: "2-digit", year: "numeric" })}
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
<div className="mt-auto">
|
||||
<LikeButton
|
||||
likes={mii?._count.likedBy ?? 0}
|
||||
miiId={mii?.id}
|
||||
isLiked={(mii?.likedBy ?? []).length > 0}
|
||||
likes={mii._count.likedBy ?? 0}
|
||||
miiId={mii.id}
|
||||
isLiked={(mii.likedBy ?? []).length > 0}
|
||||
isLoggedIn={session?.user != null}
|
||||
big
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue