Fix variant create null thumbnail (#1956)
* Fix null thumbnail error * Fix too few hooks rendered on non-existent products & variants
This commit is contained in:
parent
879e1da69e
commit
26f8a776be
3 changed files with 9 additions and 8 deletions
|
@ -235,7 +235,7 @@ const ProductVariantPage: React.FC<ProductVariantPageProps> = ({
|
|||
<ProductVariantNavigation
|
||||
current={variant?.id}
|
||||
defaultVariantId={defaultVariantId}
|
||||
fallbackThumbnail={variant?.product?.thumbnail.url}
|
||||
fallbackThumbnail={variant?.product?.thumbnail?.url}
|
||||
variants={variant?.product.variants}
|
||||
onAdd={onAdd}
|
||||
onRowClick={(variantId: string) => {
|
||||
|
|
|
@ -389,9 +389,6 @@ export const ProductUpdate: React.FC<ProductUpdateProps> = ({ id, params }) => {
|
|||
|
||||
const handleBack = () => navigate(productListUrl());
|
||||
|
||||
if (product === null) {
|
||||
return <NotFoundPage onBack={handleBack} />;
|
||||
}
|
||||
const handleVariantAdd = () => navigate(productVariantAddUrl(id));
|
||||
const handleVariantsAdd = () => navigate(productVariantCreatorUrl(id));
|
||||
|
||||
|
@ -520,6 +517,10 @@ export const ProductUpdate: React.FC<ProductUpdateProps> = ({ id, params }) => {
|
|||
onFetchMore: loadMoreAttributeValues
|
||||
};
|
||||
|
||||
if (product === null) {
|
||||
return <NotFoundPage onBack={handleBack} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<WindowTitle title={data?.product?.name} />
|
||||
|
|
|
@ -197,10 +197,6 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
|||
const variant = data?.productVariant;
|
||||
const channels = createVariantChannels(variant);
|
||||
|
||||
if (variant === null) {
|
||||
return <NotFoundPage onBack={handleBack} />;
|
||||
}
|
||||
|
||||
const [
|
||||
deactivatePreorder,
|
||||
deactivatePreoderOpts
|
||||
|
@ -360,6 +356,10 @@ export const ProductVariant: React.FC<ProductUpdateProps> = ({
|
|||
const attributeValues =
|
||||
mapEdgesToItems(searchAttributeValuesOpts?.data?.attribute.choices) || [];
|
||||
|
||||
if (variant === null) {
|
||||
return <NotFoundPage onBack={handleBack} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<WindowTitle title={data?.productVariant?.name} />
|
||||
|
|
Loading…
Reference in a new issue