Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Buggy Store Merch Editing Interface #582 #605

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
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