Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Refactor product type list

dominik-zeglen327c80f9f877
diff --git a/saleor/static/dashboard-next/productTypes/components/ProductTypeList/ProductTypeList.tsx b/saleor/static/dashboard-next/productTypes/components/ProductTypeList/ProductTypeList.tsx
index 776ce93991..0f1229adda 100644
--- a/saleor/static/dashboard-next/productTypes/components/ProductTypeList/ProductTypeList.tsx
+++ b/saleor/static/dashboard-next/productTypes/components/ProductTypeList/ProductTypeList.tsx
@@ -12,25 +12,24 @@ import { ListProps } from "../../..";
import Skeleton from "../../../components/Skeleton";
import TablePagination from "../../../components/TablePagination";
import i18n from "../../../i18n";
-import { maybe, renderCollection } from "../../../misc";
-import { AttributeType } from "../../../products";
+import { maybe, renderCollection, translatedTaxRates } from "../../../misc";
+import { ProductTypeList_productTypes_edges_node } from "../../types/ProductTypeList";
interface ProductTypeListProps extends ListProps {
- productTypes?: Array<{
- id: string;
- name?: string;
- hasVariants?: boolean;
- productAttributes?: AttributeType[];
- variantAttributes?: AttributeType[];
- }>;
+ productTypes: ProductTypeList_productTypes_edges_node[];
}
-const decorate = withStyles(theme => ({
+const decorate = withStyles({
+ leftText: {
+ textAlign: "left" as "left"
+ },
link: {
- color: theme.palette.secondary.main,
cursor: "pointer" as "pointer"
+ },
+ wideCell: {
+ width: "60%"
}
-}));
+});
const ProductTypeList = decorate<ProductTypeListProps>(
({
classes,
@@ -45,12 +44,14 @@ const ProductTypeList = decorate<ProductTypeListProps>(
<Table>
<TableHead>
<TableRow>
- <TableCell>{i18n.t("Name", { context: "object" })}</TableCell>
- <TableCell>
- {i18n.t("Product attributes", { context: "object" })}
+ <TableCell className={classes.wideCell}>
+ {i18n.t("Type Name", { context: "table header" })}
</TableCell>
- <TableCell>
- {i18n.t("Variant attributes", { context: "object" })}
+ <TableCell className={classes.leftText}>
+ {i18n.t("Type", { context: "table header" })}
+ </TableCell>
+ <TableCell className={classes.leftText}>
+ {i18n.t("Tax", { context: "table header" })}
</TableCell>
</TableRow>
</TableHead>
@@ -71,37 +72,30 @@ const ProductTypeList = decorate<ProductTypeListProps>(
{renderCollection(
productTypes,
productType => (
- <TableRow key={productType ? productType.id : "skeleton"}>
+ <TableRow
+ className={!!productType ? classes.link : undefined}
+ hover={!!productType}
+ key={productType ? productType.id : "skeleton"}
+ >
<TableCell
- onClick={
- productType && onRowClick && onRowClick(productType.id)
- }
- className={classes.link}
+ onClick={productType ? onRowClick(productType.id) : undefined}
>
{productType ? productType.name : <Skeleton />}
</TableCell>
- <TableCell>
- {maybe(() => productType.productAttributes) ? (
- productType.productAttributes
- .map(attribute => attribute.name)
- .join(", ")
+ <TableCell className={classes.leftText}>
+ {maybe(() => productType.isShippingRequired) !== undefined ? (
+ productType.isShippingRequired ? (
+ <>{i18n.t("Physical", { context: "product type" })}</>
+ ) : (
+ <>{i18n.t("Digital", { context: "product type" })}</>
+ )
) : (
<Skeleton />
)}
</TableCell>
- <TableCell>
- {maybe(() => productType.hasVariants) !== undefined ? (
- maybe(() => productType.variantAttributes) ? (
- productType.variantAttributes.length > 0 ? (
- productType.variantAttributes
- .map(attribute => attribute.name)
- .join(", ")
- ) : (
- "-"
- )
- ) : (
- <Skeleton />
- )
+ <TableCell className={classes.leftText}>
+ {maybe(() => productType.taxRate) ? (
+ translatedTaxRates()[productType.taxRate]
) : (
<Skeleton />
)}
diff --git a/saleor/static/dashboard-next/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx b/saleor/static/dashboard-next/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx
index 46e050c8c5..fe916badd9 100644
--- a/saleor/static/dashboard-next/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx
+++ b/saleor/static/dashboard-next/productTypes/components/ProductTypeListPage/ProductTypeListPage.tsx
@@ -6,20 +6,11 @@ import { PageListProps } from "../../..";
import Container from "../../../components/Container";
import PageHeader from "../../../components/PageHeader";
import i18n from "../../../i18n";
-import {
- ProductTypeList_productTypes_edges_node_productAttributes,
- ProductTypeList_productTypes_edges_node_variantAttributes
-} from "../../types/ProductTypeList";
+import { ProductTypeList_productTypes_edges_node } from "../../types/ProductTypeList";
import ProductTypeList from "../ProductTypeList";
interface ProductTypeListPageProps extends PageListProps {
- productTypes?: Array<{
- id: string;
- name?: string;
- hasVariants?: boolean;
- productAttributes?: ProductTypeList_productTypes_edges_node_productAttributes[];
- variantAttributes?: ProductTypeList_productTypes_edges_node_variantAttributes[];
- }>;
+ productTypes: ProductTypeList_productTypes_edges_node[];
}
const ProductTypeListPage: React.StatelessComponent<
diff --git a/saleor/static/dashboard-next/productTypes/fixtures.ts b/saleor/static/dashboard-next/productTypes/fixtures.ts
index e80344a9f7..3c4f996532 100644
--- a/saleor/static/dashboard-next/productTypes/fixtures.ts
+++ b/saleor/static/dashboard-next/productTypes/fixtures.ts
@@ -1,869 +1,53 @@
import { TaxRateType } from "../types/globalTypes";
+import { ProductTypeDetails_productType } from "./types/ProductTypeDetails";
+import { ProductTypeList_productTypes_edges_node } from "./types/ProductTypeList";
-export const productTypes = [
+export const productTypes: ProductTypeList_productTypes_edges_node[] = [
{
+ __typename: "ProductType",
hasVariants: true,
- id: "pt79303",
- isShippingRequired: false,
- name: "Granite",
- productAttributes: [
- {
- id: "pta69348",
- name: "Licensed Soft Chair",
- slug: "Licensed-Soft-Chair",
- sortOrder: 0,
- values: [
- {
- id: "ptav55305",
- name: "cross-platform",
- slug: "cross-platform",
- sortOrder: 0
- },
- {
- id: "ptav18686",
- name: "Bolivar Fuerte",
- slug: "Bolivar-Fuerte",
- sortOrder: 1
- },
- {
- id: "ptav55165",
- name: "Algeria",
- slug: "Algeria",
- sortOrder: 2
- },
- { id: "ptav66704", name: "Tuna", slug: "Tuna", sortOrder: 3 },
- { id: "ptav9030", name: "Car", slug: "Car", sortOrder: 4 }
- ]
- },
- {
- id: "pta41729",
- name: "interfaces",
- slug: "interfaces",
- sortOrder: 1,
- values: [
- { id: "ptav35163", name: "Steel", slug: "Steel", sortOrder: 0 },
- {
- id: "ptav40084",
- name: "methodologies",
- slug: "methodologies",
- sortOrder: 1
- },
- { id: "ptav18853", name: "Summit", slug: "Summit", sortOrder: 2 },
- {
- id: "ptav78991",
- name: "5th generation",
- slug: "5th-generation",
- sortOrder: 3
- }
- ]
- },
- {
- id: "pta63704",
- name: "Outdoors",
- slug: "Outdoors",
- sortOrder: 2,
- values: [
- {
- id: "ptav36871",
- name: "Handmade Concrete Tuna",
- slug: "Handmade-Concrete-Tuna",
- sortOrder: 0
- }
- ]
- }
- ],
- taxRate: "standard",
- variantAttributes: [
- {
- id: "pta42902",
- name: "silver",
- slug: "silver",
- sortOrder: 0,
- values: [
- {
- id: "ptav22950",
- name: "Principal",
- slug: "Principal",
- sortOrder: 0
- },
- {
- id: "ptav35592",
- name: "interface",
- slug: "interface",
- sortOrder: 1
- },
- {
- id: "ptav93692",
- name: "scalable",
- slug: "scalable",
- sortOrder: 2
- },
- { id: "ptav28320", name: "Fresh", slug: "Fresh", sortOrder: 3 },
- { id: "ptav35474", name: "white", slug: "white", sortOrder: 4 }
- ]
- }
- ]
- },
- {
- hasVariants: false,
- id: "pt74994",
+ id: "UHJvZHVjdFR5cGU6NA==",
isShippingRequired: true,
- name: "Metal",
- productAttributes: [
- {
- id: "pta30527",
- name: "THX",
- slug: "THX",
- sortOrder: 0,
- values: [
- { id: "ptav4461", name: "Health", slug: "Health", sortOrder: 0 },
- {
- id: "ptav63442",
- name: "infomediaries",
- slug: "infomediaries",
- sortOrder: 1
- },
- {
- id: "ptav44484",
- name: "Multi-channelled",
- slug: "Multi-channelled",
- sortOrder: 2
- },
- {
- id: "ptav25378",
- name: "compressing",
- slug: "compressing",
- sortOrder: 3
- },
- {
- id: "ptav49406",
- name: "Moldova",
- slug: "Moldova",
- sortOrder: 4
- }
- ]
- },
- {
- id: "pta27975",
- name: "primary",
- slug: "primary",
- sortOrder: 1,
- values: [
- { id: "ptav6173", name: "Lights", slug: "Lights", sortOrder: 0 },
- {
- id: "ptav95257",
- name: "open-source",
- slug: "open-source",
- sortOrder: 1
- },
- {
- id: "ptav74274",
- name: "Rustic Steel Shirt",
- slug: "Rustic-Steel-Shirt",
- sortOrder: 2
- }
- ]
- },
- {
- id: "pta30602",
- name: "calculate",
- slug: "calculate",
- sortOrder: 2,
- values: [
- { id: "ptav62030", name: "purple", slug: "purple", sortOrder: 0 }
- ]
- }
- ],
- taxRate: "standard",
- variantAttributes: []
- },
- {
- hasVariants: true,
- id: "pt11788",
- isShippingRequired: false,
- name: "Rubber",
- productAttributes: [
- {
- id: "pta17130",
- name: "override",
- slug: "override",
- sortOrder: 0,
- values: [
- {
- id: "ptav46700",
- name: "mint green",
- slug: "mint-green",
- sortOrder: 0
- },
- {
- id: "ptav84349",
- name: "asymmetric",
- slug: "asymmetric",
- sortOrder: 1
- }
- ]
- },
- {
- id: "pta31482",
- name: "backing up",
- slug: "backing-up",
- sortOrder: 1,
- values: [
- { id: "ptav51776", name: "JBOD", slug: "JBOD", sortOrder: 0 },
- {
- id: "ptav70107",
- name: "Investment Account",
- slug: "Investment-Account",
- sortOrder: 1
- },
- {
- id: "ptav96788",
- name: "connecting",
- slug: "connecting",
- sortOrder: 2
- },
- {
- id: "ptav90352",
- name: "ability",
- slug: "ability",
- sortOrder: 3
- }
- ]
- },
- {
- id: "pta11523",
- name: "Health",
- slug: "Health",
- sortOrder: 2,
- values: [
- { id: "ptav19288", name: "index", slug: "index", sortOrder: 0 },
- {
- id: "ptav47297",
- name: "Assimilated",
- slug: "Assimilated",
- sortOrder: 1
- }
- ]
- }
- ],
- taxRate: "standard",
- variantAttributes: [
- {
- id: "pta63002",
- name: "magenta",
- slug: "magenta",
- sortOrder: 0,
- values: [
- {
- id: "ptav73703",
- name: "Arkansas",
- slug: "Arkansas",
- sortOrder: 0
- },
- {
- id: "ptav48391",
- name: "Dominican Republic",
- slug: "Dominican-Republic",
- sortOrder: 1
- },
- { id: "ptav4296", name: "hacking", slug: "hacking", sortOrder: 2 }
- ]
- },
- {
- id: "pta32365",
- name: "Buckinghamshire",
- slug: "Buckinghamshire",
- sortOrder: 1,
- values: [
- {
- id: "ptav25429",
- name: "override",
- slug: "override",
- sortOrder: 0
- },
- {
- id: "ptav49824",
- name: "revolutionary",
- slug: "revolutionary",
- sortOrder: 1
- }
- ]
- }
- ]
+ name: "Candy",
+ taxRate: "FOODSTUFFS" as TaxRateType
},
{
- hasVariants: true,
- id: "pt98059",
- isShippingRequired: false,
- name: "Wooden",
- productAttributes: [
- {
- id: "pta94742",
- name: "Som",
- slug: "Som",
- sortOrder: 0,
- values: [
- { id: "ptav22212", name: "driver", slug: "driver", sortOrder: 0 },
- { id: "ptav56627", name: "Courts", slug: "Courts", sortOrder: 1 },
- {
- id: "ptav90083",
- name: "navigate",
- slug: "navigate",
- sortOrder: 2
- }
- ]
- }
- ],
- taxRate: "standard",
- variantAttributes: [
- {
- id: "pta22383",
- name: "payment",
- slug: "payment",
- sortOrder: 0,
- values: [
- {
- id: "ptav49178",
- name: "approach",
- slug: "approach",
- sortOrder: 0
- }
- ]
- },
- {
- id: "pta80861",
- name: "Trafficway",
- slug: "Trafficway",
- sortOrder: 1,
- values: [
- {
- id: "ptav46452",
- name: "matrices",
- slug: "matrices",
- sortOrder: 0
- },
- { id: "ptav85638", name: "Shirt", slug: "Shirt", sortOrder: 1 },
- {
- id: "ptav58144",
- name: "Gorgeous",
- slug: "Gorgeous",
- sortOrder: 2
- },
- { id: "ptav14423", name: "hub", slug: "hub", sortOrder: 3 },
- {
- id: "ptav96207",
- name: "navigate",
- slug: "navigate",
- sortOrder: 4
- }
- ]
- }
- ]
- },
- {
- hasVariants: true,
- id: "pt2515",
+ __typename: "ProductType",
+ hasVariants: false,
+ id: "UHJvZHVjdFR5cGU6NQ==",
isShippingRequired: false,
- name: "Granite",
- productAttributes: [
- {
- id: "pta64711",
- name: "Metal",
- slug: "Metal",
- sortOrder: 0,
- values: [
- {
- id: "ptav33402",
- name: "infomediaries",
- slug: "infomediaries",
- sortOrder: 0
- },
- {
- id: "ptav10636",
- name: "e-tailers",
- slug: "e-tailers",
- sortOrder: 1
- },
- { id: "ptav90325", name: "matrix", slug: "matrix", sortOrder: 2 }
- ]
- }
- ],
- taxRate: "standard",
- variantAttributes: [
- {
- id: "pta20692",
- name: "encompassing",
- slug: "encompassing",
- sortOrder: 0,
- values: [
- {
- id: "ptav46153",
- name: "Engineer",
- slug: "Engineer",
- sortOrder: 0
- },
- { id: "ptav35859", name: "copy", slug: "copy", sortOrder: 1 },
- {
- id: "ptav86046",
- name: "reinvent",
- slug: "reinvent",
- sortOrder: 2
- }
- ]
- }
- ]
+ name: "E-books",
+ taxRate: "STANDARD" as TaxRateType
},
{
- hasVariants: true,
- id: "pt84268",
+ __typename: "ProductType",
+ hasVariants: false,
+ id: "UHJvZHVjdFR5cGU6Mg==",
isShippingRequired: true,
- name: "Fresh",
- productAttributes: [
- {
- id: "pta44796",
- name: "auxiliary",
- slug: "auxiliary",
- sortOrder: 0,
- values: [
- {
- id: "ptav78424",
- name: "mint green",
- slug: "mint-green",
- sortOrder: 0
- },
- {
- id: "ptav46319",
- name: "synergies",
- slug: "synergies",
- sortOrder: 1
- },
- {
- id: "ptav14736",
- name: "Cambodia",
- slug: "Cambodia",
- sortOrder: 2
- },
- {
- id: "ptav8502",
- name: "Forward",
- slug: "Forward",
- sortOrder: 3
- },
- { id: "ptav31965", name: "Ball", slug: "Ball", sortOrder: 4 }
- ]
- },
- {
- id: "pta60251",
- name: "synergize",
- slug: "synergize",
- sortOrder: 1,
- values: [
- {
- id: "ptav49015",
- name: "Refined",
- slug: "Refined",
- sortOrder: 0
- },
- {
- id: "ptav58572",
- name: "solid state",
- slug: "solid-state",
- sortOrder: 1
- },
- {
- id: "ptav79851",
- name: "asynchronous",
- slug: "asynchronous",
- sortOrder: 2
- }
- ]
- },
- {
- id: "pta22408",
- name: "out-of-the-box",
- slug: "out-of-the-box",
- sortOrder: 2,
- values: [
- { id: "ptav93528", name: "Texas", slug: "Texas", sortOrder: 0 },
- {
- id: "ptav13773",
- name: "homogeneous",
- slug: "homogeneous",
- sortOrder: 1
- }
- ]
- }
- ],
- taxRate: "standard",
- variantAttributes: [
- {
- id: "pta67026",
- name: "connect",
- slug: "connect",
- sortOrder: 0,
- values: [
- {
- id: "ptav27987",
- name: "sky blue",
- slug: "sky-blue",
- sortOrder: 0
- },
- {
- id: "ptav48264",
- name: "Granite",
- slug: "Granite",
- sortOrder: 1
- },
- {
- id: "ptav64745",
- name: "payment",
- slug: "payment",
- sortOrder: 2
- },
- { id: "ptav71939", name: "Beauty", slug: "Beauty", sortOrder: 3 },
- {
- id: "ptav63121",
- name: "Buckinghamshire",
- slug: "Buckinghamshire",
- sortOrder: 4
- }
- ]
- }
- ]
+ name: "Mugs",
+ taxRate: "STANDARD" as TaxRateType
},
{
+ __typename: "ProductType",
hasVariants: true,
- id: "pt72644",
+ id: "UHJvZHVjdFR5cGU6Mw==",
isShippingRequired: true,
- name: "Rubber",
- productAttributes: [
- {
- id: "pta5371",
- name: "Tools",
- slug: "Tools",
- sortOrder: 0,
- values: [
- { id: "ptav88704", name: "input", slug: "input", sortOrder: 0 },
- { id: "ptav18871", name: "Forges", slug: "Forges", sortOrder: 1 },
- { id: "ptav97275", name: "Soft", slug: "Soft", sortOrder: 2 },
- { id: "ptav96784", name: "1080p", slug: "1080p", sortOrder: 3 },
- { id: "ptav30336", name: "Chips", slug: "Chips", sortOrder: 4 }
- ]
- },
- {
- id: "pta71197",
- name: "solid state",
- slug: "solid-state",
- sortOrder: 1,
- values: [
- {
- id: "ptav64739",
- name: "Graphical User Interface",
- slug: "Graphical-User-Interface",
- sortOrder: 0
- },
- { id: "ptav54719", name: "pixel", slug: "pixel", sortOrder: 1 },
- {
- id: "ptav92895",
- name: "calculating",
- slug: "calculating",
- sortOrder: 2
- }
- ]
- }
- ],
- taxRate: "standard",
- variantAttributes: [
- {
- id: "pta30118",
- name: "user-facing",
- slug: "user-facing",
- sortOrder: 0,
- values: [
- {
- id: "ptav55703",
- name: "transmitting",
- slug: "transmitting",
- sortOrder: 0
- },
- {
- id: "ptav76397",
- name: "Division",
- slug: "Division",
- sortOrder: 1
- },
- {
- id: "ptav14897",
- name: "Division",
- slug: "Division",
- sortOrder: 2
- },
- { id: "ptav42477", name: "indigo", slug: "indigo", sortOrder: 3 }
- ]
- }
- ]
+ name: "Coffee",
+ taxRate: "STANDARD" as TaxRateType
},
{
+ __typename: "ProductType",
hasVariants: true,
- id: "pt48595",
+ id: "UHJvZHVjdFR5cGU6MQ==",
isShippingRequired: true,
- name: "Concrete",
- productAttributes: [
- {
- id: "pta17108",
- name: "deposit",
- slug: "deposit",
- sortOrder: 0,
- values: [
- { id: "ptav65920", name: "CSS", slug: "CSS", sortOrder: 0 },
- {
- id: "ptav36958",
- name: "Associate",
- slug: "Associate",
- sortOrder: 1
- }
- ]
- },
- {
- id: "pta19479",
- name: "Borders",
- slug: "Borders",
- sortOrder: 1,
- values: [
- {
- id: "ptav17219",
- name: "invoice",
- slug: "invoice",
- sortOrder: 0
- }
- ]
- },
- {
- id: "pta40010",
- name: "Hat",
- slug: "Hat",
- sortOrder: 2,
- values: [
- {
- id: "ptav91080",
- name: "Nebraska",
- slug: "Nebraska",
- sortOrder: 0
- },
- { id: "ptav7571", name: "sexy", slug: "sexy", sortOrder: 1 }
- ]
- }
- ],
- taxRate: "standard",
- variantAttributes: [
- {
- id: "pta39257",
- name: "Global",
- slug: "Global",
- sortOrder: 0,
- values: [
- {
- id: "ptav51966",
- name: "Computer",
- slug: "Computer",
- sortOrder: 0
- }
- ]
- }
- ]
- },
- {
- hasVariants: false,
- id: "pt24899",
- isShippingRequired: false,
- name: "Granite",
- productAttributes: [
- {
- id: "pta34336",
- name: "payment",
- slug: "payment",
- sortOrder: 0,
- values: [
- { id: "ptav980", name: "HTTP", slug: "HTTP", sortOrder: 0 },
- {
- id: "ptav59919",
- name: "Incredible",
- slug: "Incredible",
- sortOrder: 1
- }
- ]
- },
- {
- id: "pta93863",
- name: "white",
- slug: "white",
- sortOrder: 1,
- values: [
- {
- id: "ptav79829",
- name: "methodologies",
- slug: "methodologies",
- sortOrder: 0
- },
- {
- id: "ptav760",
- name: "capacity",
- slug: "capacity",
- sortOrder: 1
- }
- ]
- },
- {
- id: "pta60318",
- name: "parsing",
- slug: "parsing",
- sortOrder: 2,
- values: [
- { id: "ptav16773", name: "SAS", slug: "SAS", sortOrder: 0 },
- { id: "ptav29993", name: "Wooden", slug: "Wooden", sortOrder: 1 }
- ]
- },
- {
- id: "pta76718",
- name: "Soap",
- slug: "Soap",
- sortOrder: 3,
- values: [
- { id: "ptav28373", name: "alarm", slug: "alarm", sortOrder: 0 },
- {
- id: "ptav30263",
- name: "connect",
- slug: "connect",
- sortOrder: 1
- },
- {
- id: "ptav11584",
- name: "Checking Account",
- slug: "Checking-Account",
- sortOrder: 2
- }
- ]
- }
- ],
- taxRate: "standard",
- variantAttributes: []
- },
- {
- hasVariants: true,
- id: "pt96158",
- isShippingRequired: true,
- name: "Concrete",
- productAttributes: [
- {
- id: "pta11427",
- name: "olive",
- slug: "olive",
- sortOrder: 0,
- values: [
- {
- id: "ptav69684",
- name: "interface",
- slug: "interface",
- sortOrder: 0
- },
- { id: "ptav2418", name: "Rwanda", slug: "Rwanda", sortOrder: 1 },
- {
- id: "ptav38513",
- name: "syndicate",
- slug: "syndicate",
- sortOrder: 2
- }
- ]
- },
- {
- id: "pta18934",
- name: "Indian Rupee",
- slug: "Indian-Rupee",
- sortOrder: 1,
- values: [
- {
- id: "ptav34840",
- name: "back up",
- slug: "back-up",
- sortOrder: 0
- }
- ]
- }
- ],
- taxRate: "standard",
- variantAttributes: [
- {
- id: "pta37948",
- name: "wireless",
- slug: "wireless",
- sortOrder: 0,
- values: [
- {
- id: "ptav39010",
- name: "transmitting",
- slug: "transmitting",
- sortOrder: 0
- },
- { id: "ptav47009", name: "Books", slug: "Books", sortOrder: 1 },
- {
- id: "ptav28891",
- name: "Re-contextualized",
- slug: "Re-contextualized",
- sortOrder: 2
- },
- { id: "ptav24868", name: "Creek", slug: "Creek", sortOrder: 3 }
- ]
- },
- {
- id: "pta20337",
- name: "back-end",
- slug: "back-end",
- sortOrder: 1,
- values: [
- {
- id: "ptav47664",
- name: "Home Loan Account",
- slug: "Home-Loan-Account",
- sortOrder: 0
- },
- {
- id: "ptav80296",
- name: "Stand-alone",
- slug: "Stand-alone",
- sortOrder: 1
- },
- {
- id: "ptav17421",
- name: "portals",
- slug: "portals",
- sortOrder: 2
- },
- { id: "ptav29970", name: "Small", slug: "Small", sortOrder: 3 }
- ]
- }
- ]
+ name: "T-Shirt",
+ taxRate: "STANDARD" as TaxRateType
}
].map(productType => ({
...productType,
- __typename: "ProductType" as "ProductType",
- productAttributes: productType.productAttributes.map(attribute => ({
- ...attribute,
- __typename: "Attribute" as "Attribute",
- values: attribute.values.map(value => ({
- ...value,
- __typename: "AttributeValue" as "AttributeValue"
- }))
- })),
- variantAttributes: productType.variantAttributes.map(attribute => ({
- ...attribute,
- __typename: "Attribute" as "Attribute",
- values: attribute.values.map(value => ({
- ...value,
- __typename: "AttributeValue" as "AttributeValue"
- }))
- }))
+ __typename: "ProductType" as "ProductType"
}));
-export const productType = {
+export const productType: ProductTypeDetails_productType = {
hasVariants: true,
id: "pt77249",
isShippingRequired: true,
diff --git a/saleor/static/dashboard-next/productTypes/queries.ts b/saleor/static/dashboard-next/productTypes/queries.ts
index 3c6a408f47..5e5c3ee4bb 100644
--- a/saleor/static/dashboard-next/productTypes/queries.ts
+++ b/saleor/static/dashboard-next/productTypes/queries.ts
@@ -54,7 +54,7 @@ export const TypedProductTypeListQuery = Query as React.ComponentType<
QueryProps<ProductTypeList, ProductTypeListVariables>
>;
export const productTypeListQuery = gql`
- ${attributeFragment}
+ ${productTypeFragment}
query ProductTypeList(
$after: String
$before: String
@@ -64,15 +64,7 @@ export const productTypeListQuery = gql`
productTypes(after: $after, before: $before, first: $first, last: $last) {
edges {
node {
- id
- name
- hasVariants
- productAttributes {
- ...AttributeFragment
- }
- variantAttributes {
- ...AttributeFragment
- }
+ ...ProductTypeFragment
}
}
pageInfo {
@@ -89,20 +81,10 @@ export const TypedProductTypeDetailsQuery = Query as React.ComponentType<
QueryProps<ProductTypeDetails, ProductTypeDetailsVariables>
>;
export const productTypeDetailsQuery = gql`
- ${attributeFragment}
+ ${productTypeDetailsFragment}
query ProductTypeDetails($id: ID!) {
productType(id: $id) {
- id
- name
- hasVariants
- productAttributes {
- ...AttributeFragment
- }
- variantAttributes {
- ...AttributeFragment
- }
- isShippingRequired
- taxRate
+ ...ProductTypeDetailsFragment
}
}
`;
diff --git a/saleor/static/dashboard-next/productTypes/types/ProductTypeDetails.ts b/saleor/static/dashboard-next/productTypes/types/ProductTypeDetails.ts
index d7462c206c..d9a7f32770 100644
--- a/saleor/static/dashboard-next/productTypes/types/ProductTypeDetails.ts
+++ b/saleor/static/dashboard-next/productTypes/types/ProductTypeDetails.ts
@@ -42,10 +42,10 @@ export interface ProductTypeDetails_productType {
id: string;
name: string;
hasVariants: boolean;
- productAttributes: (ProductTypeDetails_productType_productAttributes | null)[] | null;
- variantAttributes: (ProductTypeDetails_productType_variantAttributes | null)[] | null;
isShippingRequired: boolean;
taxRate: TaxRateType | null;
+ productAttributes: (ProductTypeDetails_productType_productAttributes | null)[] | null;
+ variantAttributes: (ProductTypeDetails_productType_variantAttributes | null)[] | null;
}
export interface ProductTypeDetails {
diff --git a/saleor/static/dashboard-next/productTypes/types/ProductTypeDetailsFragment.ts b/saleor/static/dashboard-next/productTypes/types/ProductTypeDetailsFragment.ts
new file mode 100644
index 0000000000..87a0d3daad
--- /dev/null
+++ b/saleor/static/dashboard-next/productTypes/types/ProductTypeDetailsFragment.ts
@@ -0,0 +1,49 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+import { TaxRateType } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL fragment: ProductTypeDetailsFragment
+// ====================================================
+
+export interface ProductTypeDetailsFragment_productAttributes_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+}
+
+export interface ProductTypeDetailsFragment_productAttributes {
+ __typename: "Attribute";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ values: (ProductTypeDetailsFragment_productAttributes_values | null)[] | null;
+}
+
+export interface ProductTypeDetailsFragment_variantAttributes_values {
+ __typename: "AttributeValue";
+ id: string;
+ name: string | null;
+ slug: string | null;
+}
+
+export interface ProductTypeDetailsFragment_variantAttributes {
+ __typename: "Attribute";
+ id: string;
+ name: string | null;
+ slug: string | null;
+ values: (ProductTypeDetailsFragment_variantAttributes_values | null)[] | null;
+}
+
+export interface ProductTypeDetailsFragment {
+ __typename: "ProductType";
+ id: string;
+ name: string;
+ hasVariants: boolean;
+ isShippingRequired: boolean;
+ taxRate: TaxRateType | null;
+ productAttributes: (ProductTypeDetailsFragment_productAttributes | null)[] | null;
+ variantAttributes: (ProductTypeDetailsFragment_variantAttributes | null)[] | null;
+}
diff --git a/saleor/static/dashboard-next/productTypes/types/ProductTypeFragment.ts b/saleor/static/dashboard-next/productTypes/types/ProductTypeFragment.ts
new file mode 100644
index 0000000000..9e552da11e
--- /dev/null
+++ b/saleor/static/dashboard-next/productTypes/types/ProductTypeFragment.ts
@@ -0,0 +1,17 @@
+/* tslint:disable */
+// This file was automatically generated and should not be edited.
+
+import { TaxRateType } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL fragment: ProductTypeFragment
+// ====================================================
+
+export interface ProductTypeFragment {
+ __typename: "ProductType";
+ id: string;
+ name: string;
+ hasVariants: boolean;
+ isShippingRequired: boolean;
+ taxRate: TaxRateType | null;
+}
diff --git a/saleor/static/dashboard-next/productTypes/types/ProductTypeList.ts b/saleor/static/dashboard-next/productTypes/types/ProductTypeList.ts
index 7ea577132a..a7e9cc8acc 100644
--- a/saleor/static/dashboard-next/productTypes/types/ProductTypeList.ts
+++ b/saleor/static/dashboard-next/productTypes/types/ProductTypeList.ts
@@ -1,47 +1,19 @@
/* tslint:disable */
// This file was automatically generated and should not be edited.
+import { TaxRateType } from "./../../types/globalTypes";
+
// ====================================================
// GraphQL query operation: ProductTypeList
// ====================================================
-export interface ProductTypeList_productTypes_edges_node_productAttributes_values {
- __typename: "AttributeValue";
- id: string;
- name: string | null;
- slug: string | null;
-}
-
-export interface ProductTypeList_productTypes_edges_node_productAttributes {
- __typename: "Attribute";
- id: string;
- name: string | null;
- slug: string | null;
- values: (ProductTypeList_productTypes_edges_node_productAttributes_values | null)[] | null;
-}
-
-export interface ProductTypeList_productTypes_edges_node_variantAttributes_values {
- __typename: "AttributeValue";
- id: string;
- name: string | null;
- slug: string | null;
-}
-
-export interface ProductTypeList_productTypes_edges_node_variantAttributes {
- __typename: "Attribute";
- id: string;
- name: string | null;
- slug: string | null;
- values: (ProductTypeList_productTypes_edges_node_variantAttributes_values | null)[] | null;
-}
-
export interface ProductTypeList_productTypes_edges_node {
__typename: "ProductType";
id: string;
name: string;
hasVariants: boolean;
- productAttributes: (ProductTypeList_productTypes_edges_node_productAttributes | null)[] | null;
- variantAttributes: (ProductTypeList_productTypes_edges_node_variantAttributes | null)[] | null;
+ isShippingRequired: boolean;
+ taxRate: TaxRateType | null;
}
export interface ProductTypeList_productTypes_edges {
diff --git a/saleor/static/dashboard-next/storybook/stories/productTypes/ProductTypeListPage.tsx b/saleor/static/dashboard-next/storybook/stories/productTypes/ProductTypeListPage.tsx
index b2dd2e9f88..3a4d42db0b 100644
--- a/saleor/static/dashboard-next/storybook/stories/productTypes/ProductTypeListPage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/productTypes/ProductTypeListPage.tsx
@@ -14,4 +14,6 @@ storiesOf("Views / Product types / Product types list", module)
{...pageListProps.default}
/>
))
- .add("loading", () => <ProductTypeListPage {...pageListProps.loading} />);
+ .add("loading", () => (
+ <ProductTypeListPage productTypes={undefined} {...pageListProps.loading} />
+ ));