diff --git a/src/components/ModForm.tsx b/src/components/ModForm.tsx index 1d17a72..45c3985 100644 --- a/src/components/ModForm.tsx +++ b/src/components/ModForm.tsx @@ -457,12 +457,14 @@ export const ModForm = () => { @@ -530,6 +532,7 @@ type DownloadUrlFieldsProps = { malwareScanLink: string modVersion: string customNote: string + mediaUrl?: string onUrlChange: (index: number, field: keyof DownloadUrl, value: string) => void onRemove: (index: number) => void } @@ -544,6 +547,7 @@ const DownloadUrlFields = React.memo( malwareScanLink, modVersion, customNote, + mediaUrl, onUrlChange, onRemove }: DownloadUrlFieldsProps) => { @@ -713,6 +717,40 @@ const DownloadUrlFields = React.memo( />
+
+
+ + + +
+
+ { + onUrlChange(index, 'mediaUrl', values[0]) + }} + /> + + +
+
+
) } diff --git a/src/pages/mod/index.tsx b/src/pages/mod/index.tsx index a0774b9..1d8d826 100644 --- a/src/pages/mod/index.tsx +++ b/src/pages/mod/index.tsx @@ -573,7 +573,8 @@ const Download = ({ signatureKey, malwareScanLink, modVersion, - customNote + customNote, + mediaUrl }: DownloadUrl) => { const [showAuthDetails, setShowAuthDetails] = useState(false) const [showNotice, setShowNotice] = useState(false) diff --git a/src/pages/submitMod/action.ts b/src/pages/submitMod/action.ts index 5e51df4..51c16ef 100644 --- a/src/pages/submitMod/action.ts +++ b/src/pages/submitMod/action.ts @@ -256,6 +256,19 @@ const validateState = async ( errors.downloadUrls![i] = 'Download url must be valid and reachable' } + + if ( + downloadUrl.mediaUrl && + downloadUrl.mediaUrl.trim() !== '' && + (!isValidUrl(downloadUrl.mediaUrl) || + !isValidImageUrl(downloadUrl.mediaUrl) || + !(await isReachable(downloadUrl.mediaUrl))) + ) { + if (!errors.downloadUrls) + errors.downloadUrls = Array(formState.downloadUrls.length) + + errors.downloadUrls![i] = 'Media URLs must be valid and reachable image' + } } } diff --git a/src/types/mod.ts b/src/types/mod.ts index 555bdf0..fdd9036 100644 --- a/src/types/mod.ts +++ b/src/types/mod.ts @@ -47,6 +47,7 @@ export interface DownloadUrl { malwareScanLink: string modVersion: string customNote: string + mediaUrl?: string } export interface ModDetails extends Omit {