diff --git a/.eslintrc.json b/.eslintrc.json index bffb357..12dd23b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,6 @@ { + "rules": { + "@next/next/no-img-element": "off" + }, "extends": "next/core-web-vitals" } diff --git a/components/scoreplaylog/colums.tsx b/components/scoreplaylog/colums.tsx index 51f045d..e754028 100644 --- a/components/scoreplaylog/colums.tsx +++ b/components/scoreplaylog/colums.tsx @@ -2,13 +2,12 @@ import { ColumnDef } from "@tanstack/react-table"; import { Button } from "@/components/ui/button"; -import { useState } from "react"; import { ArrowUpDown } from "lucide-react"; import { chuni_score_playlog } from "@/prisma/schemas/artemis/generated/artemis"; import { chuni_static_music } from "@/prisma/schemas/artemis/generated/artemis"; import { getDifficultyText, getGrade } from "@/lib/helpers"; -import { Skeleton } from "../ui/skeleton"; import ActionsCell from "./moreAction"; +import ImageCell from "./image"; type chunithm = chuni_score_playlog & chuni_static_music & { playCount: number }; @@ -18,32 +17,11 @@ export const columns: ColumnDef[] = [ header: "Title", cell: ({ row }) => { - const [isLoading, setIsLoading] = useState(true); - const jacketPath = row.original.jacketPath?.replace(".dds", ".png"); - const handleImageLoad = () => { - setIsLoading(false); - }; - - const handleImageError = () => { - setIsLoading(false); - }; return ( -
- {jacketPath ? ( - Jacket - ) : ( - - )} - {row.original.title} -
+ ); }, }, diff --git a/components/scoreplaylog/image.tsx b/components/scoreplaylog/image.tsx new file mode 100644 index 0000000..f7f2e6c --- /dev/null +++ b/components/scoreplaylog/image.tsx @@ -0,0 +1,41 @@ +"use client"; +import { useState } from "react"; +import { Skeleton } from "../ui/skeleton"; + +interface ImageCellProps { + jacketPath: string | undefined; + title: string; +} + +const ImageCell: React.FC = ({ jacketPath, title }) => { + const [isLoading, setIsLoading] = useState(true); + + const handleImageLoad = () => { + setIsLoading(false); + }; + + const handleImageError = () => { + setIsLoading(false); + }; + + const formattedJacketPath = jacketPath?.replace(".dds", ".png"); + + return ( +
+ {formattedJacketPath ? ( + Jacket + ) : ( + + )} + {title} +
+ ); +}; + +export default ImageCell; diff --git a/components/userRatingBaseHotList/page.tsx b/components/userRatingBaseHotList/page.tsx index e307e03..88493f9 100644 --- a/components/userRatingBaseHotList/page.tsx +++ b/components/userRatingBaseHotList/page.tsx @@ -1,8 +1,9 @@ "use client"; -import React, { FC, useState } from "react"; +import React, { FC } from "react"; import { getDifficultyText } from "@/lib/helpers"; import { Skeleton } from "../ui/skeleton"; +import ImageCell from "../scoreplaylog/image"; type userRatingBaseList = { title: string; @@ -31,31 +32,15 @@ export const ChunithmHotPlays: FC = ({
{" "} {chuniProfileHotPlays.hotRating.map((playerHotRatingList, index) => { - const jacketPath = playerHotRatingList.jacketPath?.replace( - ".dds", - ".png", - ); - const [isLoading, setIsLoading] = useState(true); - - const handleImageLoad = () => { - setIsLoading(false); - }; - - const handleImageError = () => { - setIsLoading(false); - }; return (
- {!jacketPath ? ( - - ) : ( - Jacket - )} + + +
  • diff --git a/components/userRatingBaseList/page.tsx b/components/userRatingBaseList/page.tsx index e0978bd..d17af00 100644 --- a/components/userRatingBaseList/page.tsx +++ b/components/userRatingBaseList/page.tsx @@ -2,6 +2,7 @@ import React, { FC, useState } from "react"; import { getDifficultyText } from "@/lib/helpers"; import { Skeleton } from "../ui/skeleton"; +import ImageCell from "../scoreplaylog/image"; type userRatingBaseList = { title: string; @@ -31,35 +32,13 @@ export const ChunithmTopPlays: FC = ({
    {" "} {chuniProfileTopPlays.topPlays.map((chuniProfileTopPlays, index) => { - const jacketPath = chuniProfileTopPlays.jacketPath?.replace( - ".dds", - ".png", - ); - const [isLoading, setIsLoading] = useState(true); - - const handleImageLoad = () => { - setIsLoading(false); - }; - - const handleImageError = () => { - setIsLoading(false); - }; return (
    - {jacketPath ? ( - Jacket - ) : ( - - )} +
    • Title: {chuniProfileTopPlays.title} diff --git a/components/userRatingBaseNextList/page.tsx b/components/userRatingBaseNextList/page.tsx index 34cc829..8c81cea 100644 --- a/components/userRatingBaseNextList/page.tsx +++ b/components/userRatingBaseNextList/page.tsx @@ -2,6 +2,7 @@ import React, { FC, useState } from "react"; import { getDifficultyText } from "@/lib/helpers"; import { Skeleton } from "../ui/skeleton"; +import ImageCell from "../scoreplaylog/image"; type userRatingBaseList = { title: string; @@ -34,31 +35,14 @@ export const ChunithmNextPlays: FC = ({ ".dds", ".png", ); - const [isLoading, setIsLoading] = useState(true); - const handleImageLoad = () => { - setIsLoading(false); - }; - - const handleImageError = () => { - setIsLoading(false); - }; return (
      - {jacketPath ? ( - Jacket - ) : ( - - )} +