'use client'; import clsx from 'clsx'; import { useState } from 'react'; import { Label, TextArea } from '@/components/Input'; import { ModalForm } from '@/components/Modal'; import { useAuthSuspense } from '@/features/auth/backend/useAuth'; import { useDialogsStore } from '@/stores/dialogs'; import { limits } from '@/utils/constants'; import SelectLocationContext from '../components/SelectLocationContext'; import SelectLocationHead from '../components/SelectLocationHead'; import { LocationHead } from '../models/library'; import { combineLocation, validateLocation } from '../models/libraryAPI'; export interface DlgChangeLocationProps { initial: string; onChangeLocation: (newLocation: string) => void; } function DlgChangeLocation() { const { initial, onChangeLocation } = useDialogsStore(state => state.props as DlgChangeLocationProps); const { user } = useAuthSuspense(); 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) : ''); } function handleSubmit() { onChangeLocation(location); return true; } return (