import React from 'react' import { Controller, useFormContext, useWatch } from 'react-hook-form' import { GermanStates } from '@heygermany/sdk' import { MultiSelect, Radio, Stack, Title, Group, Box, Input, Alert } from '@pikku/mantine/core' import { DateInput } from '@mantine/dates' import { IconInfoCircle } from '@tabler/icons-react' import { useI18n } from '@/context/i18n-provider' import { CountrySearch } from './CountrySearch' import { SUPPORTED_COUNTRIES } from '@/config' export const BasicInfo: React.FunctionComponent = () => { const t = useI18n() const { control, formState: { errors } } = useFormContext() const countryEducation = useWatch({ control, name: 'countryEducation' }) const isUnsupportedCountry = countryEducation && !SUPPORTED_COUNTRIES.includes(countryEducation) const germanStates = Object.values(GermanStates) return ( {t('jobs.apply.steps.basicinfo')} {/* German States Multi-Select */} ( { if (newValue.includes('ALL')) { // If ALL is selected, select all states if (!field.value?.includes('ALL')) { field.onChange(germanStates) } else { // If ALL is already selected and user clicks it again, deselect all field.onChange([]) } } else { field.onChange(newValue) } }} data={[ { value: 'ALL', label: t('jobs.basicinfo.worklocation.selectall')}, ...germanStates.map(state => ({ value: state, label: state })) ]} placeholder={t('jobs.basicinfo.worklocation.placeholder')} searchable clearable error={errors.stateWorkPreference?.message as string} w="100%" /> )} /> {/* Open to Work */} (value === true || value === false) || t('jobs.basicinfo.validation.optionrequired') }} render={({ field }) => ( field.onChange(value === 'true' ? true : false)} error={errors.joinTalentPool?.message as string} > )} /> {/* Living in Germany */} (value === true || value === false) || t('jobs.basicinfo.validation.optionrequired') }} render={({ field }) => ( field.onChange(value === 'true' ? true : false)} error={errors.livingInGermany?.message as string} > )} /> {/* EU Passport */} (value === true || value === false) || t('jobs.basicinfo.validation.optionrequired') }} render={({ field }) => ( field.onChange(value === 'true' ? true : false)} error={errors.euPassport?.message as string} > )} /> {/* Date of Birth */} ( )} /> {/* Education Country */} ( )} /> {isUnsupportedCountry && ( } title={t('jobs.basicinfo.unsupportedcountry.title')} color="blue" mt="sm" > {t('jobs.basicinfo.unsupportedcountry.message')} )} ) }