many breaking changes/fixes

This commit is contained in:
Daniel
2023-03-28 11:01:50 +03:30
parent 3a5ae28f86
commit b9567ca3c2
43 changed files with 1180 additions and 466 deletions
+15 -7
View File
@@ -5,7 +5,17 @@ import CreatableSelect from "react-select/creatable";
import { styles } from "./styles";
import { Options } from "./types";
export default function ({ onChange }: any) {
type Props = {
onChange: any;
defaultValue:
| {
value: number;
label: string;
}
| undefined;
};
export default function ({ onChange, defaultValue }: Props) {
const { collections } = useCollectionStore();
const router = useRouter();
@@ -17,10 +27,8 @@ export default function ({ onChange }: any) {
return e.id === collectionId;
});
let defaultCollection = null;
if (activeCollection) {
defaultCollection = {
if (activeCollection && !defaultValue) {
defaultValue = {
value: activeCollection?.id,
label: activeCollection?.name,
};
@@ -28,7 +36,7 @@ export default function ({ onChange }: any) {
useEffect(() => {
const formatedCollections = collections.map((e) => {
return { value: e.id, label: e.name };
return { value: e.id, label: e.name, ownerId: e.ownerId };
});
setOptions(formatedCollections);
@@ -40,7 +48,7 @@ export default function ({ onChange }: any) {
onChange={onChange}
options={options}
styles={styles}
defaultValue={defaultCollection}
defaultValue={defaultValue}
menuPosition="fixed"
/>
);
+10 -1
View File
@@ -4,7 +4,15 @@ import CreatableSelect from "react-select/creatable";
import { styles } from "./styles";
import { Options } from "./types";
export default function ({ onChange }: any) {
type Props = {
onChange: any;
defaultValue?: {
value: number;
label: string;
}[];
};
export default function ({ onChange, defaultValue }: Props) {
const { tags } = useTagStore();
const [options, setOptions] = useState<Options[]>([]);
@@ -23,6 +31,7 @@ export default function ({ onChange }: any) {
onChange={onChange}
options={options}
styles={styles}
defaultValue={defaultValue}
menuPosition="fixed"
isMulti
/>