From 5a6327fb73b04f9489102ae3e9520f2e332fbf95 Mon Sep 17 00:00:00 2001 From: en Date: Wed, 22 Jan 2025 17:47:38 +0100 Subject: [PATCH] feat(mod): add permissions and details Close #112 --- src/components/ModForm.tsx | 146 ++++++++++++++++++++++++++ src/pages/mod/index.tsx | 190 +++++++++++++++++++++++++++++----- src/pages/submitMod/action.ts | 36 ++++++- src/types/mod.ts | 79 ++++++++++++++ src/utils/mod.ts | 30 +++++- 5 files changed, 451 insertions(+), 30 deletions(-) diff --git a/src/components/ModForm.tsx b/src/components/ModForm.tsx index 716dc21..663e81b 100644 --- a/src/components/ModForm.tsx +++ b/src/components/ModForm.tsx @@ -20,6 +20,9 @@ import { DownloadUrl, ModFormState, ModPageLoaderResult, + ModPermissions, + MODPERMISSIONS_CONF, + MODPERMISSIONS_DESC, SubmitModActionResult } from '../types' import { @@ -114,6 +117,13 @@ export const ModForm = () => { [] ) + const handleRadioChange = useCallback((name: string, value: boolean) => { + setFormState((prevState) => ({ + ...prevState, + [name]: value + })) + }, []) + const addScreenshotUrl = useCallback(() => { setFormState((prevState) => ({ ...prevState, @@ -243,6 +253,17 @@ export const ModForm = () => { [formState, isEditing, submit] ) + const extraBoxRef = useRef(null) + const handleExtraBoxButtonClick = () => { + if (extraBoxRef.current) { + if (extraBoxRef.current.style.display === '') { + extraBoxRef.current.style.display = 'none' + } else { + extraBoxRef.current.style.display = '' + } + } + } + return (
{ )} +
+ +
+

+ What permissions users have with your published mod/post +

+
+ {Object.keys(MODPERMISSIONS_CONF).map((k) => { + const permKey = k as keyof ModPermissions + const confKey = k as keyof typeof MODPERMISSIONS_CONF + const modPermission = MODPERMISSIONS_CONF[confKey] + const value = formState[permKey] + + return ( +
+
+

{modPermission.header}

+
+
+ + +
+
+ ) + })} +
+
+

Publisher Notes

+
+
+