Fix rtypes
This commit is contained in:
parent
e5274afa64
commit
34698b7d6f
7 changed files with 31 additions and 23 deletions
|
@ -161,7 +161,9 @@ const CompanyAddressInput: React.FC<CompanyAddressInputProps> = props => {
|
||||||
value={data.country}
|
value={data.country}
|
||||||
choices={countries}
|
choices={countries}
|
||||||
InputProps={{
|
InputProps={{
|
||||||
autoComplete: "off"
|
inputProps: {
|
||||||
|
autocomplete: "plsdontautocomplete" // Somehow it shuts it down
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
|
|
|
@ -3,19 +3,23 @@ import React from "react";
|
||||||
|
|
||||||
import Decorator from "@saleor/storybook/Decorator";
|
import Decorator from "@saleor/storybook/Decorator";
|
||||||
import { formError } from "@saleor/storybook/misc";
|
import { formError } from "@saleor/storybook/misc";
|
||||||
import { shop } from "@saleor/siteSettings/fixtures";
|
import { countries } from "@saleor/fixtures";
|
||||||
import WarehouseCreatePage, {
|
import WarehouseCreatePage, {
|
||||||
WarehouseCreatePageProps,
|
WarehouseCreatePageProps,
|
||||||
WarehouseCreatePageFormData
|
WarehouseCreatePageFormData
|
||||||
} from "./WarehouseCreatePage";
|
} from "./WarehouseCreatePage";
|
||||||
|
|
||||||
const props: WarehouseCreatePageProps = {
|
const props: WarehouseCreatePageProps = {
|
||||||
|
countries: countries.map(c => ({
|
||||||
|
__typename: "CountryDisplay",
|
||||||
|
code: c.code,
|
||||||
|
country: c.name
|
||||||
|
})),
|
||||||
disabled: false,
|
disabled: false,
|
||||||
errors: [],
|
errors: [],
|
||||||
onBack: () => undefined,
|
onBack: () => undefined,
|
||||||
onSubmit: () => undefined,
|
onSubmit: () => undefined,
|
||||||
saveButtonBarState: "default",
|
saveButtonBarState: "default"
|
||||||
shop
|
|
||||||
};
|
};
|
||||||
storiesOf("Views / Warehouses / Create warehouse", module)
|
storiesOf("Views / Warehouses / Create warehouse", module)
|
||||||
.addDecorator(Decorator)
|
.addDecorator(Decorator)
|
||||||
|
|
|
@ -14,8 +14,7 @@ import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/single
|
||||||
import { mapCountriesToChoices } from "@saleor/utils/maps";
|
import { mapCountriesToChoices } from "@saleor/utils/maps";
|
||||||
import useAddressValidation from "@saleor/hooks/useAddressValidation";
|
import useAddressValidation from "@saleor/hooks/useAddressValidation";
|
||||||
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
||||||
import { maybe } from "@saleor/misc";
|
import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo";
|
||||||
import { ShopInfo_shop } from "@saleor/components/Shop/types/ShopInfo";
|
|
||||||
import AppHeader from "@saleor/components/AppHeader";
|
import AppHeader from "@saleor/components/AppHeader";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
|
@ -25,10 +24,10 @@ export interface WarehouseCreatePageFormData extends AddressTypeInput {
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
export interface WarehouseCreatePageProps {
|
export interface WarehouseCreatePageProps {
|
||||||
|
countries: ShopInfo_shop_countries[];
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
errors: UserError[];
|
errors: UserError[];
|
||||||
saveButtonBarState: ConfirmButtonTransitionState;
|
saveButtonBarState: ConfirmButtonTransitionState;
|
||||||
shop: ShopInfo_shop;
|
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onSubmit: (data: WarehouseCreatePageFormData) => void;
|
onSubmit: (data: WarehouseCreatePageFormData) => void;
|
||||||
}
|
}
|
||||||
|
@ -46,10 +45,10 @@ const initialForm: WarehouseCreatePageFormData = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const WarehouseCreatePage: React.FC<WarehouseCreatePageProps> = ({
|
const WarehouseCreatePage: React.FC<WarehouseCreatePageProps> = ({
|
||||||
|
countries,
|
||||||
disabled,
|
disabled,
|
||||||
errors: apiErrors,
|
errors: apiErrors,
|
||||||
saveButtonBarState,
|
saveButtonBarState,
|
||||||
shop,
|
|
||||||
onBack,
|
onBack,
|
||||||
onSubmit
|
onSubmit
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -68,9 +67,7 @@ const WarehouseCreatePage: React.FC<WarehouseCreatePageProps> = ({
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
>
|
>
|
||||||
{({ change, data, errors, submit }) => {
|
{({ change, data, errors, submit }) => {
|
||||||
const countryChoices = mapCountriesToChoices(
|
const countryChoices = mapCountriesToChoices(countries);
|
||||||
maybe(() => shop.countries, [])
|
|
||||||
);
|
|
||||||
const handleCountryChange = createSingleAutocompleteSelectHandler(
|
const handleCountryChange = createSingleAutocompleteSelectHandler(
|
||||||
change,
|
change,
|
||||||
setDisplayCountry,
|
setDisplayCountry,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { storiesOf } from "@storybook/react";
|
import { storiesOf } from "@storybook/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { address } from "@saleor/fixtures";
|
import { address, countries } from "@saleor/fixtures";
|
||||||
import Decorator from "@saleor/storybook/Decorator";
|
import Decorator from "@saleor/storybook/Decorator";
|
||||||
import { formError } from "@saleor/storybook/misc";
|
import { formError } from "@saleor/storybook/misc";
|
||||||
import { warehouseList } from "../../fixtures";
|
import { warehouseList } from "../../fixtures";
|
||||||
|
@ -11,9 +11,16 @@ import WarehouseDetailsPage, {
|
||||||
} from "./WarehouseDetailsPage";
|
} from "./WarehouseDetailsPage";
|
||||||
|
|
||||||
const props: WarehouseDetailsPageProps = {
|
const props: WarehouseDetailsPageProps = {
|
||||||
|
countries: countries.map(c => ({
|
||||||
|
__typename: "CountryDisplay",
|
||||||
|
code: c.code,
|
||||||
|
country: c.name
|
||||||
|
})),
|
||||||
disabled: false,
|
disabled: false,
|
||||||
errors: [],
|
errors: [],
|
||||||
onBack: () => undefined,
|
onBack: () => undefined,
|
||||||
|
onDelete: () => undefined,
|
||||||
|
onShippingZoneClick: () => undefined,
|
||||||
onSubmit: () => undefined,
|
onSubmit: () => undefined,
|
||||||
saveButtonBarState: "default",
|
saveButtonBarState: "default",
|
||||||
warehouse: {
|
warehouse: {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { mapCountriesToChoices } from "@saleor/utils/maps";
|
||||||
import useAddressValidation from "@saleor/hooks/useAddressValidation";
|
import useAddressValidation from "@saleor/hooks/useAddressValidation";
|
||||||
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
import useStateFromProps from "@saleor/hooks/useStateFromProps";
|
||||||
import { maybe, findValueInEnum } from "@saleor/misc";
|
import { maybe, findValueInEnum } from "@saleor/misc";
|
||||||
import { ShopInfo_shop } from "@saleor/components/Shop/types/ShopInfo";
|
import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo";
|
||||||
import AppHeader from "@saleor/components/AppHeader";
|
import AppHeader from "@saleor/components/AppHeader";
|
||||||
import PageHeader from "@saleor/components/PageHeader";
|
import PageHeader from "@saleor/components/PageHeader";
|
||||||
import { sectionNames } from "@saleor/intl";
|
import { sectionNames } from "@saleor/intl";
|
||||||
|
@ -28,10 +28,10 @@ export interface WarehouseDetailsPageFormData extends AddressTypeInput {
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
export interface WarehouseDetailsPageProps {
|
export interface WarehouseDetailsPageProps {
|
||||||
|
countries: ShopInfo_shop_countries[];
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
errors: UserError[];
|
errors: UserError[];
|
||||||
saveButtonBarState: ConfirmButtonTransitionState;
|
saveButtonBarState: ConfirmButtonTransitionState;
|
||||||
shop: ShopInfo_shop;
|
|
||||||
warehouse: WarehouseDetails_warehouse;
|
warehouse: WarehouseDetails_warehouse;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
|
@ -40,10 +40,10 @@ export interface WarehouseDetailsPageProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const WarehouseDetailsPage: React.FC<WarehouseDetailsPageProps> = ({
|
const WarehouseDetailsPage: React.FC<WarehouseDetailsPageProps> = ({
|
||||||
|
countries,
|
||||||
disabled,
|
disabled,
|
||||||
errors: apiErrors,
|
errors: apiErrors,
|
||||||
saveButtonBarState,
|
saveButtonBarState,
|
||||||
shop,
|
|
||||||
warehouse,
|
warehouse,
|
||||||
onBack,
|
onBack,
|
||||||
onDelete,
|
onDelete,
|
||||||
|
@ -79,9 +79,7 @@ const WarehouseDetailsPage: React.FC<WarehouseDetailsPageProps> = ({
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
>
|
>
|
||||||
{({ change, data, errors, submit }) => {
|
{({ change, data, errors, submit }) => {
|
||||||
const countryChoices = mapCountriesToChoices(
|
const countryChoices = mapCountriesToChoices(countries);
|
||||||
maybe(() => shop.countries, [])
|
|
||||||
);
|
|
||||||
const handleCountryChange = createSingleAutocompleteSelectHandler(
|
const handleCountryChange = createSingleAutocompleteSelectHandler(
|
||||||
change,
|
change,
|
||||||
setDisplayCountry,
|
setDisplayCountry,
|
||||||
|
|
|
@ -36,13 +36,14 @@ const WarehouseCreate: React.FC = () => {
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<WarehouseCreatePage
|
<WarehouseCreatePage
|
||||||
onBack={() => navigate(warehouseListUrl())}
|
countries={maybe(() => shop.countries, [])}
|
||||||
disabled={createWarehouseOpts.loading}
|
disabled={createWarehouseOpts.loading}
|
||||||
errors={maybe(
|
errors={maybe(
|
||||||
() => createWarehouseOpts.data.createWarehouse.errors,
|
() => createWarehouseOpts.data.createWarehouse.errors,
|
||||||
[]
|
[]
|
||||||
)}
|
)}
|
||||||
shop={shop}
|
saveButtonBarState={createWarehouseTransitionState}
|
||||||
|
onBack={() => navigate(warehouseListUrl())}
|
||||||
onSubmit={data =>
|
onSubmit={data =>
|
||||||
createWarehouse({
|
createWarehouse({
|
||||||
variables: {
|
variables: {
|
||||||
|
@ -62,7 +63,6 @@ const WarehouseCreate: React.FC = () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
saveButtonBarState={createWarehouseTransitionState}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -69,15 +69,15 @@ const WarehouseDetails: React.FC<WarehouseDetailsProps> = ({ id, params }) => {
|
||||||
<>
|
<>
|
||||||
<WindowTitle title={maybe(() => data.warehouse.name)} />
|
<WindowTitle title={maybe(() => data.warehouse.name)} />
|
||||||
<WarehouseDetailsPage
|
<WarehouseDetailsPage
|
||||||
onBack={() => navigate(warehouseListUrl())}
|
countries={maybe(() => shop.countries, [])}
|
||||||
disabled={loading || updateWarehouseOpts.loading}
|
disabled={loading || updateWarehouseOpts.loading}
|
||||||
errors={maybe(
|
errors={maybe(
|
||||||
() => updateWarehouseOpts.data.updateWarehouse.errors,
|
() => updateWarehouseOpts.data.updateWarehouse.errors,
|
||||||
[]
|
[]
|
||||||
)}
|
)}
|
||||||
saveButtonBarState={updateWarehouseTransitionState}
|
saveButtonBarState={updateWarehouseTransitionState}
|
||||||
shop={shop}
|
|
||||||
warehouse={maybe(() => data.warehouse)}
|
warehouse={maybe(() => data.warehouse)}
|
||||||
|
onBack={() => navigate(warehouseListUrl())}
|
||||||
onDelete={() => openModal("delete")}
|
onDelete={() => openModal("delete")}
|
||||||
onShippingZoneClick={id => navigate(shippingZoneUrl(id))}
|
onShippingZoneClick={id => navigate(shippingZoneUrl(id))}
|
||||||
onSubmit={data =>
|
onSubmit={data =>
|
||||||
|
|
Loading…
Reference in a new issue