import { useForm } from 'react-hook-form'; import { useEffect } from 'react'; import { PreferencesSchema } from '~common/schemas'; import zodResolver from '~renderer/utils/zodResolver'; import { api } from '~renderer/utils/api'; import TextButton from './styled/TextButton'; import FilePickerInput from './form/FilePickerInput'; import CloseButton from './styled/CloseButton'; type Props = { close: () => void }; const ClientDirDialog = ({ close }: Props) => { const { data: pref } = api.preferences.get.useQuery(); const setPref = api.preferences.set.useMutation(); const isValidClientDir = api.preferences.isValidClientDir.useQuery( pref?.clientDir, { enabled: !!pref?.isPortable } ); const verify = api.updater.verify.useMutation(); const { register, handleSubmit, watch, formState, setValue, setError, reset } = useForm({ defaultValues: { clientDir: pref?.clientDir ?? '' }, resolver: zodResolver(PreferencesSchema.pick({ clientDir: true })) }); useEffect(() => { pref && reset(pref); }, [reset, pref]); if (pref?.isPortable) { return (

Install location

You are using the portable version of the launcher. Install location is determined by the location of the launcher executable.

{!isValidClientDir.isLoading && !isValidClientDir.data && (

Error: WoW.exe not found in current folder. Please close the launcher and move it to your WoW 1.12 client directory.

)} ); } return (
{ try { await setPref.mutateAsync({ clientDir }); verify.mutateAsync(); close(); } catch (e) { setError('clientDir', { message: e instanceof Error ? e.message : JSON.stringify(e) }); } })} > { reset(); close(); }} />

Install location


Select a directory for the game client installation.

You may also choose a directory with an existing Turtle WoW or Vanilla WoW installation, and it will be automatically upgraded.

setValue('clientDir', v, { shouldTouch: true, shouldDirty: true, shouldValidate: true }) } options={{ properties: ['openDirectory', 'createDirectory'] }} />
{formState.errors.clientDir && (

{formState.errors.clientDir.message}

)} Confirm ); }; export default ClientDirDialog;