-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathproduct-component.tsx
More file actions
34 lines (31 loc) · 893 Bytes
/
product-component.tsx
File metadata and controls
34 lines (31 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react';
import { ProductDetails } from './elements/product-details/product-details';
import { useGetProductQuery } from '../../graphql/_generated-hooks';
import { ProductPlaceholder } from './elements/product-details/product-placeholder';
export interface ProductProps extends React.HTMLAttributes<HTMLElement> {
id: string;
ssr: boolean;
context: any;
short?: boolean;
}
// TODO: HOC/with for Product
export const ProductComponent = ({
id,
ssr = false,
context = {},
short = false,
}: ProductProps) => {
const { data, loading } = useGetProductQuery({
variables: { id },
ssr,
context,
});
return (
<>
{loading && <ProductPlaceholder />}
{data ? (
<ProductDetails data={data} short={short} instantImage={ssr} />
) : null}
</>
);
};