From 9b4cf2bde2fae6916cfcf5ca1f38cc36e0a3a46e Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:25:30 +0300 Subject: [PATCH] M: Improve location picker --- .../components/PickLocation/PickLocation.tsx | 65 +++++++++++++++++++ .../SelectLocationContext.tsx | 8 +-- .../library/components/PickLocation/index.tsx | 1 + .../library/dialogs/DlgChangeLocation.tsx | 43 ++---------- .../library/dialogs/DlgCloneLibraryItem.tsx | 55 +++------------- .../pages/CreateItemPage/FormCreateItem.tsx | 55 +++------------- 6 files changed, 95 insertions(+), 132 deletions(-) create mode 100644 rsconcept/frontend/src/features/library/components/PickLocation/PickLocation.tsx rename rsconcept/frontend/src/features/library/components/{ => PickLocation}/SelectLocationContext.tsx (81%) create mode 100644 rsconcept/frontend/src/features/library/components/PickLocation/index.tsx diff --git a/rsconcept/frontend/src/features/library/components/PickLocation/PickLocation.tsx b/rsconcept/frontend/src/features/library/components/PickLocation/PickLocation.tsx new file mode 100644 index 00000000..4fdecada --- /dev/null +++ b/rsconcept/frontend/src/features/library/components/PickLocation/PickLocation.tsx @@ -0,0 +1,65 @@ +'use client'; + +import { type FieldError } from 'react-hook-form'; +import clsx from 'clsx'; + +import { useAuthSuspense } from '@/features/auth'; + +import { Label, TextArea } from '@/components/Input'; +import { type Styling } from '@/components/props'; + +import { LocationHead } from '../../models/library'; +import { combineLocation } from '../../models/libraryAPI'; +import { SelectLocationHead } from '../SelectLocationHead'; + +import { SelectLocationContext } from './SelectLocationContext'; + +interface PickLocationProps extends Styling { + dropdownHeight?: string; + rows?: number; + + value: string; + onChange: (newLocation: string) => void; + error?: FieldError; +} + +export function PickLocation({ + dropdownHeight, + rows = 3, + value, + onChange, + error, + className, + ...restProps +}: PickLocationProps) { + const { user } = useAuthSuspense(); + + return ( +
+
+
+ + + +