'use client'; import clsx from 'clsx'; import { useState } from 'react'; import { useAuth } from '@/backend/auth/useAuth'; import SelectLocationContext from '@/components/select/SelectLocationContext'; import SelectLocationHead from '@/components/select/SelectLocationHead'; import Label from '@/components/ui/Label'; import Modal from '@/components/ui/Modal'; import TextArea from '@/components/ui/TextArea'; import { LocationHead } from '@/models/library'; import { combineLocation, validateLocation } from '@/models/libraryAPI'; import { useDialogsStore } from '@/stores/dialogs'; import { limits } from '@/utils/constants'; export interface DlgChangeLocationProps { initial: string; onChangeLocation: (newLocation: string) => void; } function DlgChangeLocation() { const { initial, onChangeLocation } = useDialogsStore(state => state.props as DlgChangeLocationProps); const { user } = useAuth(); const [head, setHead] = useState(initial.substring(0, 2) as LocationHead); const [body, setBody] = useState(initial.substring(3)); const location = combineLocation(head, body); const isValid = initial !== location && validateLocation(location); function handleSelectLocation(newValue: string) { setHead(newValue.substring(0, 2) as LocationHead); setBody(newValue.length > 3 ? newValue.substring(3) : ''); } return ( onChangeLocation(location)} className={clsx('w-[35rem]', 'pb-3 px-6 flex gap-3 h-[9rem]')} >