/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ /* eslint-disable @typescript-eslint/no-unsafe-return */ import * as React from 'react' import ComboBoxInput from '../../Input/ComboBoxInput' import { Item } from '../../../types' import { useEffect } from 'react' import { FormState } from '../Templates/OnepagerForm' interface groupType { groupTypes_id: { name: string color: string image: string markerIcon: string } } export const GroupSubheaderForm = ({ state, setState, groupStates, groupTypes, }: { state: FormState setState: React.Dispatch> item: Item groupStates?: string[] groupTypes?: groupType[] }) => { useEffect(() => { if (groupTypes && groupStates) { const groupType = groupTypes.find((gt) => gt.groupTypes_id.name === state.group_type) console.log(state.group_type) setState((prevState) => ({ ...prevState, color: groupType?.groupTypes_id.color || groupTypes[0].groupTypes_id.color, marker_icon: groupType?.groupTypes_id.markerIcon || groupTypes[0].groupTypes_id.markerIcon, image: groupType?.groupTypes_id.image || groupTypes[0].groupTypes_id.image, status: state.status || groupStates[0], group_type: state.group_type || groupTypes[0].groupTypes_id.name, })) } // eslint-disable-next-line react-hooks/exhaustive-deps }, [state.group_type, groupTypes]) return (
setState((prevState) => ({ ...prevState, status: v, })) } />
gt.groupTypes_id.name) || []} value={state.group_type} onValueChange={(v) => setState((prevState) => ({ ...prevState, group_type: v, })) } />
) }