fix: update form state on getting existing mod data
All checks were successful
Release to Staging / build_and_release (push) Successful in 46s

This commit is contained in:
daniyal 2024-09-30 14:52:19 +05:00
parent 35c1d704e0
commit 3b2e899c14

View File

@ -60,7 +60,7 @@ export const ModForm = ({ existingModData }: ModFormProps) => {
const [isPublishing, setIsPublishing] = useState(false)
const [gameOptions, setGameOptions] = useState<GameOption[]>([])
const [formState, setFormState] = useState<ModFormState>(
initializeFormState(existingModData)
initializeFormState()
)
const [formErrors, setFormErrors] = useState<FormErrors>({})
@ -70,6 +70,12 @@ export const ModForm = ({ existingModData }: ModFormProps) => {
}
}, [location.pathname]) // Only trigger when the pathname changes to submit-mod
useEffect(() => {
if (existingModData) {
setFormState(initializeFormState(existingModData))
}
}, [existingModData])
useEffect(() => {
const options = games.map((game) => ({
label: game['Game Name'],