diff --git a/src/components/ui/Select.tsx b/src/components/ui/Select.tsx new file mode 100644 index 0000000..7a09bfb --- /dev/null +++ b/src/components/ui/Select.tsx @@ -0,0 +1,40 @@ +import { twMerge } from "tailwind-merge"; +import { type ReactNode } from "react"; + +export const Select = ({ + name, + value, + currentValue, + onCheck, + children, + className, +}: { + name: string; + value: T; + currentValue: T; + onCheck?: (v: T) => void | Promise; + className?: string; + children?: ReactNode | ReactNode[]; +}) => { + return ( + + ); +}; diff --git a/src/lib/export/formats/mrpack.ts b/src/lib/export/formats/mrpack.ts index 3631a20..7ef1416 100644 --- a/src/lib/export/formats/mrpack.ts +++ b/src/lib/export/formats/mrpack.ts @@ -27,10 +27,16 @@ const sha512 = async (f: ArrayBuffer) => { return he; }; +export const enum CurseForgeStrategy { + Embed = "embed", + Links = "links", + Skip = "skip", +} + const generateModrinthPack = async ( list: RichModList, urls: ExportReturnData, - extraData: { name?: string; version?: string; cfStrategy?: string }, + extraData: { name?: string; version?: string; cfStrategy?: CurseForgeStrategy }, ) => { const mrIndex = { formatVersion: 1, @@ -64,7 +70,7 @@ const generateModrinthPack = async ( const mrpack = new JSZip(); - if (extraData.cfStrategy === "embed") { + if (extraData.cfStrategy === CurseForgeStrategy.Embed) { const cfDownloads = urls.filter( (dl) => !("error" in dl) && dl.provider === "curseforge", ) as CurseForgeDownload[]; @@ -80,7 +86,7 @@ const generateModrinthPack = async ( mrpack.file(`overrides/mods/${url.name}`, fileContents); } - } else if (extraData.cfStrategy === "links") { + } else if (extraData.cfStrategy === CurseForgeStrategy.Links) { const cfDownloads = urls.filter( (dl) => !("error" in dl) && dl.provider === "curseforge", ) as CurseForgeDownload[]; @@ -119,7 +125,7 @@ export const modrinthExport = async ({ setStatus, }: { data: RichModList; - mrpackData: { name: string; version: string; cfStrategy: string }; + mrpackData: { name: string; version: string; cfStrategy: CurseForgeStrategy }; } & PageStateHooks) => { setStatus(ExportStatus.Resolving); setProgress({ value: 0, max: data.mods.length }); diff --git a/src/pages/list/[id]/index.tsx b/src/pages/list/[id]/index.tsx index 11e7e90..d66edcd 100644 --- a/src/pages/list/[id]/index.tsx +++ b/src/pages/list/[id]/index.tsx @@ -16,7 +16,7 @@ import { signIn, useSession } from "next-auth/react"; import { authOptions } from "~/lib/authOptions"; import { getSpecificList } from "~/lib/db"; -import { modrinthExport } from "~/lib/export/formats/mrpack"; +import { modrinthExport, CurseForgeStrategy as MrpackCurseforgeStrategy } from "~/lib/export/formats/mrpack"; import { prismAutoUpdateExport, prismStaticExport } from "~/lib/export/formats/prism"; import { ExportStatus } from "~/lib/export/formats/shared"; import { zipExport } from "~/lib/export/formats/zip"; @@ -33,8 +33,10 @@ import { DonationMessage } from "~/components/partials/DonationMessage"; import { RichModDisplay } from "~/components/partials/RichModDisplay"; import { Search } from "~/components/partials/Search"; import { Spinner } from "~/components/partials/Spinner"; +import { Metadata } from "~/components/partials/Metadata"; import { ProgressOverlay } from "~/components/ProgressOverlay"; import { Button, buttonVariants } from "~/components/ui/Button"; +import { Select } from "~/components/ui/Select"; import { AreaChartIcon, @@ -57,7 +59,6 @@ import { MarkdownIcon, ModrinthIcon } from "~/components/icons"; import toast from "react-hot-toast"; import { twMerge } from "tailwind-merge"; -import { Metadata } from "~/components/partials/Metadata"; interface PageProps { data: ModListWithExtraData; @@ -96,7 +97,9 @@ const ListPage: NextPage = ({ data }) => { const [mrpackName, setMrpackName] = useState(data.title); const [mrpackVersion, setMrpackVersion] = useState("0.0.1"); - const [mrpackCurseForgeStrategy, setMrpackCurseForgeStrategy] = useState("skip"); + const [mrpackCurseForgeStrategy, setMrpackCurseForgeStrategy] = useState( + MrpackCurseforgeStrategy.Skip, + ); const [progress, setProgress] = useState({ value: 0, max: 0 }); const [result, setResult] = useState<{ success: string[]; failed: string[] }>({ @@ -711,7 +714,7 @@ ${ }} > + - - {mrpackCurseForgeStrategy !== "skip" && ( -
- {mrpackCurseForgeStrategy === "embed" - ? "Make sure you have the rights to embed these files in your modpack distribution!" - : "This modpack will be ineligible for publication on Modrinth."} +