@ludo.ninja/components 2.3.21 → 2.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,7 +3,7 @@ import { ICollectionFilterInput, ICreationFilterInput } from "@ludo.ninja/api/bu
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
interface Props {
|
|
5
5
|
options: ISelectInput[];
|
|
6
|
-
defaultOptionValue
|
|
6
|
+
defaultOptionValue?: string;
|
|
7
7
|
isLoading?: boolean;
|
|
8
8
|
onChangeHandler: (fieldName: keyof ICreationFilterInput & keyof ICollectionFilterInput, fieldValue: string) => Promise<void>;
|
|
9
9
|
name: string;
|
|
@@ -152,22 +152,22 @@ const DropdownIndicator = (props) => {
|
|
|
152
152
|
const DesktopSelect = ({ options, isLoading, onChangeHandler, defaultOptionValue, name, ...props }) => {
|
|
153
153
|
const [selectedOption, setSelectedOption] = (0, react_1.useState)(options.find((option) => {
|
|
154
154
|
return defaultOptionValue === option.id;
|
|
155
|
-
}) ||
|
|
155
|
+
}) || null);
|
|
156
156
|
(0, react_1.useEffect)(() => {
|
|
157
157
|
const findOption = options.find((option) => {
|
|
158
158
|
return defaultOptionValue === option.id;
|
|
159
159
|
});
|
|
160
|
-
setSelectedOption(findOption ||
|
|
160
|
+
setSelectedOption(findOption || null);
|
|
161
161
|
}, [defaultOptionValue]);
|
|
162
162
|
const handleChangeOption = async (option) => {
|
|
163
163
|
await onChangeHandler(name, option.id);
|
|
164
164
|
setSelectedOption(option);
|
|
165
165
|
};
|
|
166
166
|
const getOptionLabel = (option) => {
|
|
167
|
-
return option
|
|
167
|
+
return option?.label;
|
|
168
168
|
};
|
|
169
169
|
const getOptionValue = (option) => {
|
|
170
|
-
return option
|
|
170
|
+
return option?.id;
|
|
171
171
|
};
|
|
172
172
|
const { windowDimensions } = (0, screen_1.useWindowDimensionsWithServerInitial)();
|
|
173
173
|
if (isLoading)
|