Fix types
This commit is contained in:
parent
26e537db88
commit
55df3df28d
12 changed files with 64 additions and 41 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { Divider, Typography } from "@material-ui/core";
|
import { Divider, Typography } from "@material-ui/core";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import { Channel_channel_shippingZones } from "@saleor/channels/types/Channel";
|
import { ChannelShippingZone } from "@saleor/channels/pages/ChannelDetailsPage/types";
|
||||||
import DeletableItem from "@saleor/components/DeletableItem";
|
import DeletableItem from "@saleor/components/DeletableItem";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ const useStyles = makeStyles(
|
||||||
);
|
);
|
||||||
|
|
||||||
interface ShippingZoneItemProps {
|
interface ShippingZoneItemProps {
|
||||||
zone: Channel_channel_shippingZones;
|
zone: ChannelShippingZone;
|
||||||
onDelete: (id: string) => void;
|
onDelete: (id: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Channel_channel_shippingZones } from "@saleor/channels/types/Channel";
|
import { ChannelShippingZones } from "@saleor/channels/pages/ChannelDetailsPage/types";
|
||||||
import CommonDecorator from "@saleor/storybook/Decorator";
|
import CommonDecorator from "@saleor/storybook/Decorator";
|
||||||
import { storiesOf } from "@storybook/react";
|
import { storiesOf } from "@storybook/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
@ -28,7 +28,7 @@ const baseProps = {
|
||||||
onFetchMore: () => undefined
|
onFetchMore: () => undefined
|
||||||
},
|
},
|
||||||
shippingZones: [],
|
shippingZones: [],
|
||||||
shippingZonesChoices: shippingZones as Channel_channel_shippingZones[]
|
shippingZonesChoices: shippingZones as ChannelShippingZones
|
||||||
};
|
};
|
||||||
|
|
||||||
storiesOf("Shipping zones card", module)
|
storiesOf("Shipping zones card", module)
|
||||||
|
@ -37,6 +37,6 @@ storiesOf("Shipping zones card", module)
|
||||||
.add("with options selected", () => (
|
.add("with options selected", () => (
|
||||||
<ShippingZonesCard
|
<ShippingZonesCard
|
||||||
{...baseProps}
|
{...baseProps}
|
||||||
shippingZones={shippingZones as Channel_channel_shippingZones[]}
|
shippingZones={shippingZones as ChannelShippingZones}
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { ClickAwayListener } from "@material-ui/core";
|
import { ClickAwayListener } from "@material-ui/core";
|
||||||
import { Channel_channel_shippingZones } from "@saleor/channels/types/Channel";
|
import { ChannelShippingZones } from "@saleor/channels/pages/ChannelDetailsPage/types";
|
||||||
import SingleAutocompleteSelectField from "@saleor/components/SingleAutocompleteSelectField";
|
import SingleAutocompleteSelectField from "@saleor/components/SingleAutocompleteSelectField";
|
||||||
import CardAddItemsFooter from "@saleor/products/components/ProductStocks/CardAddItemsFooter";
|
import CardAddItemsFooter from "@saleor/products/components/ProductStocks/CardAddItemsFooter";
|
||||||
import { mapNodeToChoice } from "@saleor/utils/maps";
|
import { mapNodeToChoice } from "@saleor/utils/maps";
|
||||||
|
@ -25,9 +25,7 @@ const ShippingZonesCardListFooter: React.FC<ShippingZonesCardListFooterProps> =
|
||||||
shippingZones
|
shippingZones
|
||||||
}) => {
|
}) => {
|
||||||
const [isChoicesSelectShown, setIsChoicesSelectShown] = useState(false);
|
const [isChoicesSelectShown, setIsChoicesSelectShown] = useState(false);
|
||||||
const shippingZonesRef = useRef<Channel_channel_shippingZones[]>(
|
const shippingZonesRef = useRef<ChannelShippingZones>(shippingZones);
|
||||||
shippingZones
|
|
||||||
);
|
|
||||||
|
|
||||||
// select holds value and displays it so it needs remounting
|
// select holds value and displays it so it needs remounting
|
||||||
// to display empty input after adding new zone
|
// to display empty input after adding new zone
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { ExpansionPanelSummary, Typography } from "@material-ui/core";
|
import { ExpansionPanelSummary, Typography } from "@material-ui/core";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import HorizontalSpacer from "@saleor/apps/components/HorizontalSpacer";
|
import HorizontalSpacer from "@saleor/apps/components/HorizontalSpacer";
|
||||||
import { Channel_channel_shippingZones } from "@saleor/channels/types/Channel";
|
import { ChannelShippingZones } from "@saleor/channels/pages/ChannelDetailsPage/types";
|
||||||
import IconChevronDown from "@saleor/icons/ChevronDown";
|
import IconChevronDown from "@saleor/icons/ChevronDown";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { defineMessages, useIntl } from "react-intl";
|
import { defineMessages, useIntl } from "react-intl";
|
||||||
|
@ -47,7 +47,7 @@ const messages = defineMessages({
|
||||||
});
|
});
|
||||||
|
|
||||||
interface ShippingZonesListHeaderProps {
|
interface ShippingZonesListHeaderProps {
|
||||||
shippingZones: Channel_channel_shippingZones[];
|
shippingZones: ChannelShippingZones;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ShippingZonesListHeader: React.FC<ShippingZonesListHeaderProps> = ({
|
const ShippingZonesListHeader: React.FC<ShippingZonesListHeaderProps> = ({
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Channel_channel_shippingZones } from "@saleor/channels/types/Channel";
|
import { ChannelShippingZones } from "@saleor/channels/pages/ChannelDetailsPage/types";
|
||||||
import { SearchShippingZones_search_edges_node } from "@saleor/searches/types/SearchShippingZones";
|
import { SearchShippingZones_search_edges_node } from "@saleor/searches/types/SearchShippingZones";
|
||||||
import { FetchMoreProps } from "@saleor/types";
|
import { FetchMoreProps } from "@saleor/types";
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ export interface ShippingZonesProps {
|
||||||
removeShippingZone: (id: string) => void;
|
removeShippingZone: (id: string) => void;
|
||||||
searchShippingZones: (searchPhrase: string) => void;
|
searchShippingZones: (searchPhrase: string) => void;
|
||||||
fetchMoreShippingZones: FetchMoreProps;
|
fetchMoreShippingZones: FetchMoreProps;
|
||||||
shippingZones: Channel_channel_shippingZones[];
|
shippingZones: ChannelShippingZones;
|
||||||
shippingZonesChoices: SearchShippingZones_search_edges_node[];
|
shippingZonesChoices: SearchShippingZones_search_edges_node[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ export const channelsList: Channels_channels[] = [
|
||||||
{
|
{
|
||||||
__typename: "Channel",
|
__typename: "Channel",
|
||||||
currencyCode: "euro",
|
currencyCode: "euro",
|
||||||
shippingZones: [],
|
|
||||||
hasOrders: false,
|
hasOrders: false,
|
||||||
id: "Q2hhbm5lcDoy",
|
id: "Q2hhbm5lcDoy",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
@ -28,7 +27,6 @@ export const channelsList: Channels_channels[] = [
|
||||||
{
|
{
|
||||||
__typename: "Channel",
|
__typename: "Channel",
|
||||||
currencyCode: "euro",
|
currencyCode: "euro",
|
||||||
shippingZones: [],
|
|
||||||
hasOrders: false,
|
hasOrders: false,
|
||||||
id: "Q2hhbm7lbDoy213",
|
id: "Q2hhbm7lbDoy213",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
@ -39,7 +37,6 @@ export const channelsList: Channels_channels[] = [
|
||||||
__typename: "Channel",
|
__typename: "Channel",
|
||||||
currencyCode: "euro",
|
currencyCode: "euro",
|
||||||
hasOrders: false,
|
hasOrders: false,
|
||||||
shippingZones: [],
|
|
||||||
id: "Q2hhbn5lbDoytr",
|
id: "Q2hhbn5lbDoytr",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: "Channel test",
|
name: "Channel test",
|
||||||
|
@ -48,7 +45,6 @@ export const channelsList: Channels_channels[] = [
|
||||||
{
|
{
|
||||||
__typename: "Channel",
|
__typename: "Channel",
|
||||||
currencyCode: "euro",
|
currencyCode: "euro",
|
||||||
shippingZones: [],
|
|
||||||
hasOrders: false,
|
hasOrders: false,
|
||||||
id: "Q2hhbm5lbDo5bot",
|
id: "Q2hhbm5lbDo5bot",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
@ -58,7 +54,6 @@ export const channelsList: Channels_channels[] = [
|
||||||
{
|
{
|
||||||
__typename: "Channel",
|
__typename: "Channel",
|
||||||
currencyCode: "euro",
|
currencyCode: "euro",
|
||||||
shippingZones: [],
|
|
||||||
hasOrders: false,
|
hasOrders: false,
|
||||||
id: "Q2hhbm7lbDoyr0tr",
|
id: "Q2hhbm7lbDoyr0tr",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
@ -68,7 +63,6 @@ export const channelsList: Channels_channels[] = [
|
||||||
{
|
{
|
||||||
__typename: "Channel",
|
__typename: "Channel",
|
||||||
currencyCode: "euro",
|
currencyCode: "euro",
|
||||||
shippingZones: [],
|
|
||||||
hasOrders: false,
|
hasOrders: false,
|
||||||
id: "Q2hhbn5lbDoyya",
|
id: "Q2hhbn5lbDoyya",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
@ -78,7 +72,6 @@ export const channelsList: Channels_channels[] = [
|
||||||
{
|
{
|
||||||
__typename: "Channel",
|
__typename: "Channel",
|
||||||
currencyCode: "euro",
|
currencyCode: "euro",
|
||||||
shippingZones: [],
|
|
||||||
hasOrders: false,
|
hasOrders: false,
|
||||||
id: "Q2hhbm5lbDo5w0z",
|
id: "Q2hhbm5lbDo5w0z",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
@ -90,7 +83,6 @@ export const channelsList: Channels_channels[] = [
|
||||||
export const channel: Channel_channel = {
|
export const channel: Channel_channel = {
|
||||||
__typename: "Channel",
|
__typename: "Channel",
|
||||||
currencyCode: "zl",
|
currencyCode: "zl",
|
||||||
shippingZones: [],
|
|
||||||
hasOrders: false,
|
hasOrders: false,
|
||||||
id: "Q2hhbm5lbDov78",
|
id: "Q2hhbm5lbDov78",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
|
|
@ -21,6 +21,18 @@ const props: ChannelDetailsPageProps = {
|
||||||
updateChannelStatus: () => undefined,
|
updateChannelStatus: () => undefined,
|
||||||
searchShippingZones: () => undefined,
|
searchShippingZones: () => undefined,
|
||||||
searchShippingZonesData: undefined,
|
searchShippingZonesData: undefined,
|
||||||
|
channelShippingZones: [
|
||||||
|
{
|
||||||
|
__typename: "ShippingZone",
|
||||||
|
id: "zone-1",
|
||||||
|
name: "Europe"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
__typename: "ShippingZone",
|
||||||
|
id: "zone-2",
|
||||||
|
name: "USA"
|
||||||
|
}
|
||||||
|
],
|
||||||
fetchMoreShippingZones: {
|
fetchMoreShippingZones: {
|
||||||
loading: false,
|
loading: false,
|
||||||
hasMore: false,
|
hasMore: false,
|
||||||
|
|
|
@ -38,7 +38,7 @@ export interface ChannelDetailsPageProps {
|
||||||
searchShippingZones: (query: string) => void;
|
searchShippingZones: (query: string) => void;
|
||||||
searchShippingZonesData?: SearchData;
|
searchShippingZonesData?: SearchData;
|
||||||
fetchMoreShippingZones: FetchMoreProps;
|
fetchMoreShippingZones: FetchMoreProps;
|
||||||
channelShippingZones: ChannelShippingZones;
|
channelShippingZones?: ChannelShippingZones;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ChannelDetailsPage: React.FC<ChannelDetailsPageProps> = ({
|
export const ChannelDetailsPage: React.FC<ChannelDetailsPageProps> = ({
|
||||||
|
@ -55,13 +55,13 @@ export const ChannelDetailsPage: React.FC<ChannelDetailsPageProps> = ({
|
||||||
searchShippingZones,
|
searchShippingZones,
|
||||||
searchShippingZonesData,
|
searchShippingZonesData,
|
||||||
fetchMoreShippingZones,
|
fetchMoreShippingZones,
|
||||||
channelShippingZones
|
channelShippingZones = []
|
||||||
}) => {
|
}) => {
|
||||||
const [selectedCurrencyCode, setSelectedCurrencyCode] = useState("");
|
const [selectedCurrencyCode, setSelectedCurrencyCode] = useState("");
|
||||||
|
|
||||||
const [shippingZonesToDisplay, setShippingZonesToDisplay] = useStateFromProps<
|
const [shippingZonesToDisplay, setShippingZonesToDisplay] = useStateFromProps<
|
||||||
ChannelShippingZones
|
ChannelShippingZones
|
||||||
>(channelShippingZones || []);
|
>(channelShippingZones);
|
||||||
|
|
||||||
const initialData: FormData = {
|
const initialData: FormData = {
|
||||||
currencyCode: "",
|
currencyCode: "",
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
import { ShippingZoneChannels_shippingZones_edges_node } from "@saleor/shipping/types/ShippingZoneChannels";
|
import { ChannelShippingZones_shippingZones_edges_node } from "@saleor/shipping/types/ChannelShippingZones";
|
||||||
|
|
||||||
export type ChannelShippingZones = ShippingZoneChannels_shippingZones_edges_node[];
|
export type ChannelShippingZone = ChannelShippingZones_shippingZones_edges_node;
|
||||||
|
|
||||||
|
export type ChannelShippingZones = ChannelShippingZone[];
|
||||||
|
|
|
@ -185,7 +185,9 @@ export const ChannelDetails: React.FC<ChannelDetailsProps> = ({
|
||||||
</AppHeader>
|
</AppHeader>
|
||||||
<PageHeader title={data?.channel?.name} />
|
<PageHeader title={data?.channel?.name} />
|
||||||
<ChannelDetailsPage
|
<ChannelDetailsPage
|
||||||
channelShippingZones={channelShippingZonesData?.shippingZones?.edges}
|
channelShippingZones={channelShippingZonesData?.shippingZones?.edges?.map(
|
||||||
|
({ node }) => node
|
||||||
|
)}
|
||||||
searchShippingZones={searchShippingZones}
|
searchShippingZones={searchShippingZones}
|
||||||
searchShippingZonesData={searchShippingZonesResult.data}
|
searchShippingZonesData={searchShippingZonesResult.data}
|
||||||
fetchMoreShippingZones={getSearchFetchMoreProps(
|
fetchMoreShippingZones={getSearchFetchMoreProps(
|
||||||
|
|
|
@ -11,6 +11,10 @@ import {
|
||||||
ChannelShippingZonesVariables
|
ChannelShippingZonesVariables
|
||||||
} from "./types/ChannelShippingZones";
|
} from "./types/ChannelShippingZones";
|
||||||
import { ShippingZone, ShippingZoneVariables } from "./types/ShippingZone";
|
import { ShippingZone, ShippingZoneVariables } from "./types/ShippingZone";
|
||||||
|
import {
|
||||||
|
ShippingZoneChannels,
|
||||||
|
ShippingZoneChannelsVariables
|
||||||
|
} from "./types/ShippingZoneChannels";
|
||||||
import { ShippingZones, ShippingZonesVariables } from "./types/ShippingZones";
|
import { ShippingZones, ShippingZonesVariables } from "./types/ShippingZones";
|
||||||
|
|
||||||
const shippingZones = gql`
|
const shippingZones = gql`
|
||||||
|
@ -71,6 +75,24 @@ export const useShippingZone = makeQuery<ShippingZone, ShippingZoneVariables>(
|
||||||
shippingZone
|
shippingZone
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const shippingZoneChannels = gql`
|
||||||
|
query ShippingZoneChannels($id: ID!) {
|
||||||
|
shippingZone(id: $id) {
|
||||||
|
id
|
||||||
|
channels {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
currencyCode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const useShippingZoneChannels = makeQuery<
|
||||||
|
ShippingZoneChannels,
|
||||||
|
ShippingZoneChannelsVariables
|
||||||
|
>(shippingZoneChannels);
|
||||||
|
|
||||||
const channelShippingZones = gql`
|
const channelShippingZones = gql`
|
||||||
query ChannelShippingZones($filter: ShippingZoneFilterInput) {
|
query ChannelShippingZones($filter: ShippingZoneFilterInput) {
|
||||||
shippingZones(filter: $filter) {
|
shippingZones(filter: $filter) {
|
||||||
|
|
|
@ -3,32 +3,27 @@
|
||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { ShippingZoneFilterInput } from "./../../types/globalTypes";
|
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL query operation: ShippingZoneChannels
|
// GraphQL query operation: ShippingZoneChannels
|
||||||
// ====================================================
|
// ====================================================
|
||||||
|
|
||||||
export interface ShippingZoneChannels_shippingZones_edges_node {
|
export interface ShippingZoneChannels_shippingZone_channels {
|
||||||
__typename: "ShippingZone";
|
__typename: "Channel";
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
currencyCode: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShippingZoneChannels_shippingZones_edges {
|
export interface ShippingZoneChannels_shippingZone {
|
||||||
__typename: "ShippingZoneCountableEdge";
|
__typename: "ShippingZone";
|
||||||
node: ShippingZoneChannels_shippingZones_edges_node;
|
id: string;
|
||||||
}
|
channels: ShippingZoneChannels_shippingZone_channels[];
|
||||||
|
|
||||||
export interface ShippingZoneChannels_shippingZones {
|
|
||||||
__typename: "ShippingZoneCountableConnection";
|
|
||||||
edges: ShippingZoneChannels_shippingZones_edges[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShippingZoneChannels {
|
export interface ShippingZoneChannels {
|
||||||
shippingZones: ShippingZoneChannels_shippingZones | null;
|
shippingZone: ShippingZoneChannels_shippingZone | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ShippingZoneChannelsVariables {
|
export interface ShippingZoneChannelsVariables {
|
||||||
filter?: ShippingZoneFilterInput | null;
|
id: string;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue