Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/store/components/AdminItemPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Formik } from 'formik';
import * as Yup from 'yup';
import { Option } from 'react-dropdown';

import Config from '../../../config';
import { history } from '../../../redux_store';
Expand Down Expand Up @@ -129,6 +130,12 @@ const AdminItemPage: React.FC<AdminItemPageProps> = (props) => {
discountPercentage: (!item?.hasVariantsEnabled && item?.options[0].discountPercentage.toString()) || '',
};

// converts uuid of a collection to { label: ..., value: ... }
const getOptionFormat: (string) => Option = (uuid: string) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with a better long-term solution in #608, if we revert this code back, we can merge as a solution to the other bug being resolved.

const selected = collections.find((c) => c.uuid === uuid);
return { label: selected?.title ?? '', value: selected?.uuid ?? '' };
};

return (
<>
<StoreHeader breadcrumb breadcrumbLocation="/store" />
Expand Down Expand Up @@ -247,7 +254,7 @@ const AdminItemPage: React.FC<AdminItemPageProps> = (props) => {
onChange={(option) => {
setFieldValue('collection', option.value);
}}
value={values.collection}
value={getOptionFormat(values.collection)}
error={touched.collection && errors.collection}
/>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/store/components/StoreImageUpload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const StoreImageUpload: React.FC<StoreImageUploadProps> = (props) => {
const [fileList, setFileList] = useState<any[]>([]);

const handleChange: (info: UploadChangeParam) => void = ({ fileList: newFileList }) => {
if (newFileList.length === 1) {
if (newFileList.length === 0) {
setFileList([]);
} else if (newFileList.length === 1) {
setFileList([{ ...newFileList[0], name: 'New Image' }]);
} else {
setFileList([{ ...newFileList[1], name: 'New Image' }]);
Expand Down