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