Use eslint instead of tslint

This commit is contained in:
dominik-zeglen 2019-12-02 11:49:14 +01:00
parent 9e30bb7231
commit 421da92cb3
38 changed files with 1701 additions and 667 deletions

175
.eslintrc.json Normal file
View file

@ -0,0 +1,175 @@
{
"env": {
"browser": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"@typescript-eslint/tslint",
"import",
"prefer-arrow"
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": [
"error",
{
"default": "array-simple"
}
],
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-delimiter-style": [
"off",
"error",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-use-before-declare": "off",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/quotes": "off",
"@typescript-eslint/semi": ["off", null],
"@typescript-eslint/space-within-parens": ["off", "never"],
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "off",
"@typescript-eslint/unified-signatures": "error",
"arrow-body-style": "error",
"arrow-parens": ["off", "as-needed"],
"camelcase": "off",
"capitalized-comments": "off",
"comma-dangle": "off",
"complexity": "off",
"constructor-super": "error",
"curly": "error",
"dot-notation": "error",
"eol-last": "off",
"eqeqeq": ["error", "smart"],
"guard-for-in": "error",
"id-blacklist": "off",
"import/no-extraneous-dependencies": "off",
"import/no-internal-modules": "off",
"import/order": "error",
"linebreak-style": "off",
"max-classes-per-file": "off",
"max-len": "off",
"new-parens": "off",
"newline-per-chained-call": "off",
"no-bitwise": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": [
"error",
{
"allow": [
"warn",
"dir",
"time",
"timeEnd",
"timeLog",
"trace",
"assert",
"clear",
"count",
"countReset",
"group",
"groupEnd",
"table",
"debug",
"info",
"dirxml",
"error",
"groupCollapsed",
"Console",
"profile",
"profileEnd",
"timeStamp",
"context"
]
}
],
"no-debugger": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-empty": "error",
"no-eval": "error",
"no-extra-bind": "error",
"no-extra-semi": "off",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-irregular-whitespace": "off",
"no-multiple-empty-lines": "off",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-redeclare": "error",
"no-return-await": "error",
"no-sequences": "error",
"no-shadow": [
"off",
{
"hoist": "all"
}
],
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "off",
"no-undef-init": "error",
"no-underscore-dangle": "off",
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-var": "error",
"object-shorthand": "error",
"one-var": ["error", "never"],
"prefer-arrow/prefer-arrow-functions": "off",
"prefer-const": "error",
"prefer-object-spread": "error",
"quote-props": "off",
"radix": "error",
"sort-keys": "warn",
"space-before-function-paren": "off",
"spaced-comment": "error",
"use-isnan": "error",
"valid-typeof": "off",
"@typescript-eslint/tslint/config": [
"error",
{
"rules": {
"jsdoc-format": [true, "check-multiline-start"],
"no-reference-import": true,
"object-literal-sort-keys": true,
"prefer-conditional-expression": true
}
}
]
},
"ignorePatterns": ["node_modules/", "**/types/**/*"]
}

875
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -104,6 +104,9 @@
"@types/storybook__react": "^4.0.2",
"@types/url-join": "^0.8.3",
"@types/webappsec-credential-management": "^0.5.1",
"@typescript-eslint/eslint-plugin": "^2.9.0",
"@typescript-eslint/eslint-plugin-tslint": "^2.9.0",
"@typescript-eslint/parser": "^2.9.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.6",
@ -115,6 +118,10 @@
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.3.5",
"eslint": "^6.7.1",
"eslint-loader": "^3.0.2",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prefer-arrow": "^1.1.6",
"file-loader": "^1.1.11",
"fork-ts-checker-webpack-plugin": "^0.5.2",
"html-webpack-plugin": "^3.2.0",
@ -171,7 +178,7 @@
},
"lint-staged": {
"*.{ts,tsx}": [
"tslint --fix",
"eslint --fix",
"prettier --write",
"git add"
]

View file

@ -6,12 +6,12 @@ import {
saveCredentials
} from "@saleor/utils/credentialsManagement";
import { MutationFunction, MutationResult } from "react-apollo";
import { UserContext } from "./";
import { TypedTokenAuthMutation, TypedVerifyTokenMutation } from "./mutations";
import { TokenAuth, TokenAuthVariables } from "./types/TokenAuth";
import { User } from "./types/User";
import { VerifyToken, VerifyTokenVariables } from "./types/VerifyToken";
import { getAuthToken, removeAuthToken, setAuthToken } from "./utils";
import { UserContext } from "./";
interface AuthProviderOperationsProps {
children: (props: {
@ -24,21 +24,19 @@ interface AuthProviderOperationsProps {
}
const AuthProviderOperations: React.FC<AuthProviderOperationsProps> = ({
children
}) => {
return (
<TypedTokenAuthMutation>
{(...tokenAuth) => (
<TypedVerifyTokenMutation>
{(...tokenVerify) => (
<AuthProvider tokenAuth={tokenAuth} tokenVerify={tokenVerify}>
{children}
</AuthProvider>
)}
</TypedVerifyTokenMutation>
)}
</TypedTokenAuthMutation>
);
};
}) => (
<TypedTokenAuthMutation>
{(...tokenAuth) => (
<TypedVerifyTokenMutation>
{(...tokenVerify) => (
<AuthProvider tokenAuth={tokenAuth} tokenVerify={tokenVerify}>
{children}
</AuthProvider>
)}
</TypedVerifyTokenMutation>
)}
</TypedTokenAuthMutation>
);
interface AuthProviderProps {
children: (props: {
@ -69,7 +67,7 @@ class AuthProvider extends React.Component<
> {
constructor(props) {
super(props);
this.state = { user: undefined, persistToken: false };
this.state = { persistToken: false, user: undefined };
}
componentWillReceiveProps(props: AuthProviderProps) {

View file

@ -40,15 +40,11 @@ interface CategoryCreateRouteParams {
}
const CategoryCreate: React.FC<
RouteComponentProps<CategoryCreateRouteParams>
> = ({ match }) => {
return (
<CategoryCreateView
parentId={
match.params.id ? decodeURIComponent(match.params.id) : undefined
}
/>
);
};
> = ({ match }) => (
<CategoryCreateView
parentId={match.params.id ? decodeURIComponent(match.params.id) : undefined}
/>
);
const CategoryList: React.FC<RouteComponentProps<{}>> = ({ location }) => {
const qs = parseQs(location.search.substr(1));

View file

@ -1,11 +1,5 @@
import { categoryListUrl } from "../../categories/urls";
import { collectionListUrl } from "../../collections/urls";
import { customerListUrl } from "../../customers/urls";
import { saleListUrl, voucherListUrl } from "../../discounts/urls";
import { orderDraftListUrl, orderListUrl } from "../../orders/urls";
import { productListUrl } from "../../products/urls";
import { languageListUrl } from "../../translations/urls";
import { PermissionEnum } from "../../types/globalTypes";
import { commonMessages, sectionNames } from "@saleor/intl";
import { IntlShape } from "react-intl";
import catalogIcon from "@assets/images/menu-catalog-icon.svg";
import customerIcon from "@assets/images/menu-customers-icon.svg";
@ -13,8 +7,14 @@ import discountsIcon from "@assets/images/menu-discounts-icon.svg";
import homeIcon from "@assets/images/menu-home-icon.svg";
import ordersIcon from "@assets/images/menu-orders-icon.svg";
import translationIcon from "@assets/images/menu-translation-icon.svg";
import { commonMessages, sectionNames } from "@saleor/intl";
import { IntlShape } from "react-intl";
import { categoryListUrl } from "../../categories/urls";
import { collectionListUrl } from "../../collections/urls";
import { customerListUrl } from "../../customers/urls";
import { orderDraftListUrl, orderListUrl } from "../../orders/urls";
import { productListUrl } from "../../products/urls";
import { saleListUrl, voucherListUrl } from "../../discounts/urls";
import { languageListUrl } from "../../translations/urls";
import { PermissionEnum } from "../../types/globalTypes";
export interface IMenuItem {
ariaLabel: string;

View file

@ -104,80 +104,76 @@ const AutocompleteSelectMenu: React.FC<AutocompleteSelectMenuProps> = props => {
itemToString={item => (item ? item.label : "")}
onSelect={handleChange}
>
{({ getItemProps, isOpen, openMenu, closeMenu, selectItem }) => {
return (
<div className={classes.container}>
<TextField
InputProps={{
endAdornment: loading && <CircularProgress size={16} />,
id: undefined,
onBlur: () => {
closeMenu();
setMenuPath([]);
setInputValue(displayValue);
},
onChange: event => {
debounceFn(event.target.value);
setInputValue(event.target.value);
},
onFocus: () => openMenu(),
placeholder
}}
disabled={disabled}
error={error}
helperText={helperText}
label={label}
fullWidth={true}
value={inputValue}
/>
{isOpen && (
<Paper className={classes.paper} square>
{options.length ? (
<>
{menuPath.length > 0 && (
<MenuItem
component="div"
{...getItemProps({
item: null
})}
onClick={() =>
setMenuPath(
menuPath.slice(0, menuPath.length - 2)
)
}
>
<ArrowBack className={classes.menuBack} />
<FormattedMessage {...buttonMessages.back} />
</MenuItem>
)}
{(menuPath.length
? getMenuItemByPath(options, menuPath).children
: options
).map((suggestion, index) => (
<MenuItem
key={suggestion.value}
component="div"
{...getItemProps({ item: suggestion })}
onClick={() =>
suggestion.value
? selectItem(suggestion.value)
: setMenuPath([...menuPath, index])
}
>
{suggestion.label}
</MenuItem>
))}
</>
) : (
<MenuItem disabled component="div">
<FormattedMessage defaultMessage="No results" />
</MenuItem>
)}
</Paper>
)}
</div>
);
}}
{({ getItemProps, isOpen, openMenu, closeMenu, selectItem }) => (
<div className={classes.container}>
<TextField
InputProps={{
endAdornment: loading && <CircularProgress size={16} />,
id: undefined,
onBlur: () => {
closeMenu();
setMenuPath([]);
setInputValue(displayValue);
},
onChange: event => {
debounceFn(event.target.value);
setInputValue(event.target.value);
},
onFocus: () => openMenu(),
placeholder
}}
disabled={disabled}
error={error}
helperText={helperText}
label={label}
fullWidth={true}
value={inputValue}
/>
{isOpen && (
<Paper className={classes.paper} square>
{options.length ? (
<>
{menuPath.length > 0 && (
<MenuItem
component="div"
{...getItemProps({
item: null
})}
onClick={() =>
setMenuPath(menuPath.slice(0, menuPath.length - 2))
}
>
<ArrowBack className={classes.menuBack} />
<FormattedMessage {...buttonMessages.back} />
</MenuItem>
)}
{(menuPath.length
? getMenuItemByPath(options, menuPath).children
: options
).map((suggestion, index) => (
<MenuItem
key={suggestion.value}
component="div"
{...getItemProps({ item: suggestion })}
onClick={() =>
suggestion.value
? selectItem(suggestion.value)
: setMenuPath([...menuPath, index])
}
>
{suggestion.label}
</MenuItem>
))}
</>
) : (
<MenuItem disabled component="div">
<FormattedMessage defaultMessage="No results" />
</MenuItem>
)}
</Paper>
)}
</div>
)}
</Downshift>
)}
</DebounceAutocomplete>

View file

@ -75,6 +75,11 @@ const ConfirmButton = withStyles(styles)(
>,
ConfirmButtonState
> {
state: ConfirmButtonState = {
displayCompletedActionState: false
};
timeout = null;
static getDerivedStateFromProps(
nextProps: ConfirmButtonProps,
prevState: ConfirmButtonState
@ -87,11 +92,6 @@ const ConfirmButton = withStyles(styles)(
return prevState;
}
state: ConfirmButtonState = {
displayCompletedActionState: false
};
timeout = null;
componentDidUpdate(prevProps: ConfirmButtonProps) {
const { transitionState } = this.props;
if (prevProps.transitionState !== transitionState) {

View file

@ -10,9 +10,9 @@ import classNames from "classnames";
import React from "react";
import { FormattedMessage } from "react-intl";
import { FilterContent } from ".";
import { FilterContentSubmitData } from "./FilterContent";
import { IFilter } from "./types";
import { FilterContent } from ".";
export interface FilterProps<TFilterKeys = string> {
currencySymbol: string;

View file

@ -33,7 +33,7 @@ class MenuToggle extends React.Component<MenuToggleProps, MenuToggleState> {
const { open } = this.state;
return children({
actions: { open: this.handleClick, close: this.handleClose },
actions: { close: this.handleClose, open: this.handleClick },
open
});
}

View file

@ -12,12 +12,12 @@ export interface MoneyProps {
export const Money: React.FC<MoneyProps> = ({ money }) => (
<LocaleConsumer>
{({ locale }) => {
return money.amount.toLocaleString(locale, {
{({ locale }) =>
money.amount.toLocaleString(locale, {
currency: money.currency,
style: "currency"
});
}}
})
}
</LocaleConsumer>
);

View file

@ -8,12 +8,12 @@ interface PercentProps {
const Percent: React.FC<PercentProps> = ({ amount }) => (
<LocaleConsumer>
{({ locale }) => {
return (amount / 100).toLocaleString(locale, {
{({ locale }) =>
(amount / 100).toLocaleString(locale, {
maximumFractionDigits: 2,
style: "percent"
});
}}
})
}
</LocaleConsumer>
);
Percent.displayName = "Percent";

View file

@ -12,20 +12,17 @@ import {
import isEqual from "lodash-es/isEqual";
import React from "react";
import { ChangeEvent } from "@saleor/hooks/useForm";
import BoldIcon from "../../icons/BoldIcon";
import HeaderOne from "../../icons/HeaderOne";
import HeaderThree from "../../icons/HeaderThree";
import HeaderTwo from "../../icons/HeaderTwo";
import HeaderThree from "../../icons/HeaderThree";
import ItalicIcon from "../../icons/ItalicIcon";
import LinkIcon from "../../icons/LinkIcon";
import OrderedListIcon from "../../icons/OrderedListIcon";
import HeaderOne from "../../icons/HeaderOne";
import QuotationIcon from "../../icons/QuotationIcon";
import StrikethroughIcon from "../../icons/StrikethroughIcon";
import UnorderedListIcon from "../../icons/UnorderedListIcon";
// import ImageEntity from "./ImageEntity";
// import ImageSource from "./ImageSource";
import { ChangeEvent } from "@saleor/hooks/useForm";
import LinkEntity from "./LinkEntity";
import LinkSource from "./LinkSource";
@ -33,10 +30,10 @@ export interface RichTextEditorProps {
disabled: boolean;
error: boolean;
helperText: string;
initial?: RawDraftContentState;
label: string;
name: string;
scroll?: boolean;
initial?: RawDraftContentState;
onChange: (event: React.ChangeEvent<any>) => void;
}

View file

@ -4,14 +4,14 @@ import TextField from "@material-ui/core/TextField";
import Downshift from "downshift";
import { filter } from "fuzzaldrin";
import React from "react";
import SingleAutocompleteSelectFieldContent, {
SingleAutocompleteChoiceType
} from "./SingleAutocompleteSelectFieldContent";
import useStateFromProps from "@saleor/hooks/useStateFromProps";
import { FetchMoreProps } from "@saleor/types";
import ArrowDropdownIcon from "../../icons/ArrowDropdown";
import Debounce, { DebounceProps } from "../Debounce";
import SingleAutocompleteSelectFieldContent, {
SingleAutocompleteChoiceType
} from "./SingleAutocompleteSelectFieldContent";
const useStyles = makeStyles({
container: {

View file

@ -17,7 +17,7 @@ interface MessageManagerState {
export class MessageManager extends React.Component<{}, MessageManagerState> {
state: MessageManagerState = {
message: { text: "", key: "0", onUndo: undefined },
message: { key: "0", onUndo: undefined, text: "" },
opened: false
};
queue = [];

View file

@ -987,8 +987,6 @@ export const customer: CustomerDetails_user & CustomerAddresses_user = {
}
],
dateJoined: "2017-05-07T09:37:30.124154+00:00",
firstName: "Tom",
defaultBillingAddress: {
__typename: "Address",
city: "Port Danielshire",
@ -1028,6 +1026,7 @@ export const customer: CustomerDetails_user & CustomerAddresses_user = {
streetAddress2: ""
},
email: "elizabeth.vaughn@example.com",
firstName: "Tom",
id: "VXNlcjoy",
isActive: true,
lastLogin: "2018-05-07T09:37:30.124154+00:00",

View file

@ -9,6 +9,7 @@ import Form from "@saleor/components/Form";
import Grid from "@saleor/components/Grid";
import PageHeader from "@saleor/components/PageHeader";
import SaveButtonBar from "@saleor/components/SaveButtonBar";
import { sectionNames } from "@saleor/intl";
import { UserError } from "../../../types";
import {
DiscountValueTypeEnum,
@ -21,7 +22,6 @@ import VoucherLimits from "../VoucherLimits";
import VoucherRequirements from "../VoucherRequirements";
import VoucherTypes from "../VoucherTypes";
import { sectionNames } from "@saleor/intl";
import VoucherValue from "../VoucherValue";
export interface FormData {
applyOncePerCustomer: boolean;

View file

@ -44,249 +44,249 @@ export const listActionsProps: ListActions = {
};
export const countries = [
{ name: "Afghanistan", code: "AF" },
{ name: "Åland Islands", code: "AX" },
{ name: "Albania", code: "AL" },
{ name: "Algeria", code: "DZ" },
{ name: "American Samoa", code: "AS" },
{ name: "AndorrA", code: "AD" },
{ name: "Angola", code: "AO" },
{ name: "Anguilla", code: "AI" },
{ name: "Antarctica", code: "AQ" },
{ name: "Antigua and Barbuda", code: "AG" },
{ name: "Argentina", code: "AR" },
{ name: "Armenia", code: "AM" },
{ name: "Aruba", code: "AW" },
{ name: "Australia", code: "AU" },
{ name: "Austria", code: "AT" },
{ name: "Azerbaijan", code: "AZ" },
{ name: "Bahamas", code: "BS" },
{ name: "Bahrain", code: "BH" },
{ name: "Bangladesh", code: "BD" },
{ name: "Barbados", code: "BB" },
{ name: "Belarus", code: "BY" },
{ name: "Belgium", code: "BE" },
{ name: "Belize", code: "BZ" },
{ name: "Benin", code: "BJ" },
{ name: "Bermuda", code: "BM" },
{ name: "Bhutan", code: "BT" },
{ name: "Bolivia", code: "BO" },
{ name: "Bosnia and Herzegovina", code: "BA" },
{ name: "Botswana", code: "BW" },
{ name: "Bouvet Island", code: "BV" },
{ name: "Brazil", code: "BR" },
{ name: "British Indian Ocean Territory", code: "IO" },
{ name: "Brunei Darussalam", code: "BN" },
{ name: "Bulgaria", code: "BG" },
{ name: "Burkina Faso", code: "BF" },
{ name: "Burundi", code: "BI" },
{ name: "Cambodia", code: "KH" },
{ name: "Cameroon", code: "CM" },
{ name: "Canada", code: "CA" },
{ name: "Cape Verde", code: "CV" },
{ name: "Cayman Islands", code: "KY" },
{ name: "Central African Republic", code: "CF" },
{ name: "Chad", code: "TD" },
{ name: "Chile", code: "CL" },
{ name: "China", code: "CN" },
{ name: "Christmas Island", code: "CX" },
{ name: "Cocos (Keeling) Islands", code: "CC" },
{ name: "Colombia", code: "CO" },
{ name: "Comoros", code: "KM" },
{ name: "Congo", code: "CG" },
{ name: "Congo, The Democratic Republic of the", code: "CD" },
{ name: "Cook Islands", code: "CK" },
{ name: "Costa Rica", code: "CR" },
{ name: "Cote D'Ivoire", code: "CI" },
{ name: "Croatia", code: "HR" },
{ name: "Cuba", code: "CU" },
{ name: "Cyprus", code: "CY" },
{ name: "Czech Republic", code: "CZ" },
{ name: "Denmark", code: "DK" },
{ name: "Djibouti", code: "DJ" },
{ name: "Dominica", code: "DM" },
{ name: "Dominican Republic", code: "DO" },
{ name: "Ecuador", code: "EC" },
{ name: "Egypt", code: "EG" },
{ name: "El Salvador", code: "SV" },
{ name: "Equatorial Guinea", code: "GQ" },
{ name: "Eritrea", code: "ER" },
{ name: "Estonia", code: "EE" },
{ name: "Ethiopia", code: "ET" },
{ name: "Falkland Islands (Malvinas)", code: "FK" },
{ name: "Faroe Islands", code: "FO" },
{ name: "Fiji", code: "FJ" },
{ name: "Finland", code: "FI" },
{ name: "France", code: "FR" },
{ name: "French Guiana", code: "GF" },
{ name: "French Polynesia", code: "PF" },
{ name: "French Southern Territories", code: "TF" },
{ name: "Gabon", code: "GA" },
{ name: "Gambia", code: "GM" },
{ name: "Georgia", code: "GE" },
{ name: "Germany", code: "DE" },
{ name: "Ghana", code: "GH" },
{ name: "Gibraltar", code: "GI" },
{ name: "Greece", code: "GR" },
{ name: "Greenland", code: "GL" },
{ name: "Grenada", code: "GD" },
{ name: "Guadeloupe", code: "GP" },
{ name: "Guam", code: "GU" },
{ name: "Guatemala", code: "GT" },
{ name: "Guernsey", code: "GG" },
{ name: "Guinea", code: "GN" },
{ name: "Guinea-Bissau", code: "GW" },
{ name: "Guyana", code: "GY" },
{ name: "Haiti", code: "HT" },
{ name: "Heard Island and Mcdonald Islands", code: "HM" },
{ name: "Holy See (Vatican City State)", code: "VA" },
{ name: "Honduras", code: "HN" },
{ name: "Hong Kong", code: "HK" },
{ name: "Hungary", code: "HU" },
{ name: "Iceland", code: "IS" },
{ name: "India", code: "IN" },
{ name: "Indonesia", code: "ID" },
{ name: "Iran, Islamic Republic Of", code: "IR" },
{ name: "Iraq", code: "IQ" },
{ name: "Ireland", code: "IE" },
{ name: "Isle of Man", code: "IM" },
{ name: "Israel", code: "IL" },
{ name: "Italy", code: "IT" },
{ name: "Jamaica", code: "JM" },
{ name: "Japan", code: "JP" },
{ name: "Jersey", code: "JE" },
{ name: "Jordan", code: "JO" },
{ name: "Kazakhstan", code: "KZ" },
{ name: "Kenya", code: "KE" },
{ name: "Kiribati", code: "KI" },
{ name: "Korea, Democratic People'S Republic of", code: "KP" },
{ name: "Korea, Republic of", code: "KR" },
{ name: "Kuwait", code: "KW" },
{ name: "Kyrgyzstan", code: "KG" },
{ name: "Lao People'S Democratic Republic", code: "LA" },
{ name: "Latvia", code: "LV" },
{ name: "Lebanon", code: "LB" },
{ name: "Lesotho", code: "LS" },
{ name: "Liberia", code: "LR" },
{ name: "Libyan Arab Jamahiriya", code: "LY" },
{ name: "Liechtenstein", code: "LI" },
{ name: "Lithuania", code: "LT" },
{ name: "Luxembourg", code: "LU" },
{ name: "Macao", code: "MO" },
{ name: "Macedonia, The Former Yugoslav Republic of", code: "MK" },
{ name: "Madagascar", code: "MG" },
{ name: "Malawi", code: "MW" },
{ name: "Malaysia", code: "MY" },
{ name: "Maldives", code: "MV" },
{ name: "Mali", code: "ML" },
{ name: "Malta", code: "MT" },
{ name: "Marshall Islands", code: "MH" },
{ name: "Martinique", code: "MQ" },
{ name: "Mauritania", code: "MR" },
{ name: "Mauritius", code: "MU" },
{ name: "Mayotte", code: "YT" },
{ name: "Mexico", code: "MX" },
{ name: "Micronesia, Federated States of", code: "FM" },
{ name: "Moldova, Republic of", code: "MD" },
{ name: "Monaco", code: "MC" },
{ name: "Mongolia", code: "MN" },
{ name: "Montserrat", code: "MS" },
{ name: "Morocco", code: "MA" },
{ name: "Mozambique", code: "MZ" },
{ name: "Myanmar", code: "MM" },
{ name: "Namibia", code: "NA" },
{ name: "Nauru", code: "NR" },
{ name: "Nepal", code: "NP" },
{ name: "Netherlands", code: "NL" },
{ name: "Netherlands Antilles", code: "AN" },
{ name: "New Caledonia", code: "NC" },
{ name: "New Zealand", code: "NZ" },
{ name: "Nicaragua", code: "NI" },
{ name: "Niger", code: "NE" },
{ name: "Nigeria", code: "NG" },
{ name: "Niue", code: "NU" },
{ name: "Norfolk Island", code: "NF" },
{ name: "Northern Mariana Islands", code: "MP" },
{ name: "Norway", code: "NO" },
{ name: "Oman", code: "OM" },
{ name: "Pakistan", code: "PK" },
{ name: "Palau", code: "PW" },
{ name: "Palestinian Territory, Occupied", code: "PS" },
{ name: "Panama", code: "PA" },
{ name: "Papua New Guinea", code: "PG" },
{ name: "Paraguay", code: "PY" },
{ name: "Peru", code: "PE" },
{ name: "Philippines", code: "PH" },
{ name: "Pitcairn", code: "PN" },
{ name: "Poland", code: "PL" },
{ name: "Portugal", code: "PT" },
{ name: "Puerto Rico", code: "PR" },
{ name: "Qatar", code: "QA" },
{ name: "Reunion", code: "RE" },
{ name: "Romania", code: "RO" },
{ name: "Russian Federation", code: "RU" },
{ name: "RWANDA", code: "RW" },
{ name: "Saint Helena", code: "SH" },
{ name: "Saint Kitts and Nevis", code: "KN" },
{ name: "Saint Lucia", code: "LC" },
{ name: "Saint Pierre and Miquelon", code: "PM" },
{ name: "Saint Vincent and the Grenadines", code: "VC" },
{ name: "Samoa", code: "WS" },
{ name: "San Marino", code: "SM" },
{ name: "Sao Tome and Principe", code: "ST" },
{ name: "Saudi Arabia", code: "SA" },
{ name: "Senegal", code: "SN" },
{ name: "Serbia and Montenegro", code: "CS" },
{ name: "Seychelles", code: "SC" },
{ name: "Sierra Leone", code: "SL" },
{ name: "Singapore", code: "SG" },
{ name: "Slovakia", code: "SK" },
{ name: "Slovenia", code: "SI" },
{ name: "Solomon Islands", code: "SB" },
{ name: "Somalia", code: "SO" },
{ name: "South Africa", code: "ZA" },
{ name: "South Georgia and the South Sandwich Islands", code: "GS" },
{ name: "Spain", code: "ES" },
{ name: "Sri Lanka", code: "LK" },
{ name: "Sudan", code: "SD" },
{ name: "Suriname", code: "SR" },
{ name: "Svalbard and Jan Mayen", code: "SJ" },
{ name: "Swaziland", code: "SZ" },
{ name: "Sweden", code: "SE" },
{ name: "Switzerland", code: "CH" },
{ name: "Syrian Arab Republic", code: "SY" },
{ name: "Taiwan, Province of China", code: "TW" },
{ name: "Tajikistan", code: "TJ" },
{ name: "Tanzania, United Republic of", code: "TZ" },
{ name: "Thailand", code: "TH" },
{ name: "Timor-Leste", code: "TL" },
{ name: "Togo", code: "TG" },
{ name: "Tokelau", code: "TK" },
{ name: "Tonga", code: "TO" },
{ name: "Trinidad and Tobago", code: "TT" },
{ name: "Tunisia", code: "TN" },
{ name: "Turkey", code: "TR" },
{ name: "Turkmenistan", code: "TM" },
{ name: "Turks and Caicos Islands", code: "TC" },
{ name: "Tuvalu", code: "TV" },
{ name: "Uganda", code: "UG" },
{ name: "Ukraine", code: "UA" },
{ name: "United Arab Emirates", code: "AE" },
{ name: "United Kingdom", code: "GB" },
{ name: "United States", code: "US" },
{ name: "United States Minor Outlying Islands", code: "UM" },
{ name: "Uruguay", code: "UY" },
{ name: "Uzbekistan", code: "UZ" },
{ name: "Vanuatu", code: "VU" },
{ name: "Venezuela", code: "VE" },
{ name: "Viet Nam", code: "VN" },
{ name: "Virgin Islands, British", code: "VG" },
{ name: "Virgin Islands, U.S.", code: "VI" },
{ name: "Wallis and Futuna", code: "WF" },
{ name: "Western Sahara", code: "EH" },
{ name: "Yemen", code: "YE" },
{ name: "Zambia", code: "ZM" },
{ name: "Zimbabwe", code: "ZW" }
{ code: "AF", name: "Afghanistan" },
{ code: "AX", name: "Åland Islands" },
{ code: "AL", name: "Albania" },
{ code: "DZ", name: "Algeria" },
{ code: "AS", name: "American Samoa" },
{ code: "AD", name: "AndorrA" },
{ code: "AO", name: "Angola" },
{ code: "AI", name: "Anguilla" },
{ code: "AQ", name: "Antarctica" },
{ code: "AG", name: "Antigua and Barbuda" },
{ code: "AR", name: "Argentina" },
{ code: "AM", name: "Armenia" },
{ code: "AW", name: "Aruba" },
{ code: "AU", name: "Australia" },
{ code: "AT", name: "Austria" },
{ code: "AZ", name: "Azerbaijan" },
{ code: "BS", name: "Bahamas" },
{ code: "BH", name: "Bahrain" },
{ code: "BD", name: "Bangladesh" },
{ code: "BB", name: "Barbados" },
{ code: "BY", name: "Belarus" },
{ code: "BE", name: "Belgium" },
{ code: "BZ", name: "Belize" },
{ code: "BJ", name: "Benin" },
{ code: "BM", name: "Bermuda" },
{ code: "BT", name: "Bhutan" },
{ code: "BO", name: "Bolivia" },
{ code: "BA", name: "Bosnia and Herzegovina" },
{ code: "BW", name: "Botswana" },
{ code: "BV", name: "Bouvet Island" },
{ code: "BR", name: "Brazil" },
{ code: "IO", name: "British Indian Ocean Territory" },
{ code: "BN", name: "Brunei Darussalam" },
{ code: "BG", name: "Bulgaria" },
{ code: "BF", name: "Burkina Faso" },
{ code: "BI", name: "Burundi" },
{ code: "KH", name: "Cambodia" },
{ code: "CM", name: "Cameroon" },
{ code: "CA", name: "Canada" },
{ code: "CV", name: "Cape Verde" },
{ code: "KY", name: "Cayman Islands" },
{ code: "CF", name: "Central African Republic" },
{ code: "TD", name: "Chad" },
{ code: "CL", name: "Chile" },
{ code: "CN", name: "China" },
{ code: "CX", name: "Christmas Island" },
{ code: "CC", name: "Cocos (Keeling) Islands" },
{ code: "CO", name: "Colombia" },
{ code: "KM", name: "Comoros" },
{ code: "CG", name: "Congo" },
{ code: "CD", name: "Congo, The Democratic Republic of the" },
{ code: "CK", name: "Cook Islands" },
{ code: "CR", name: "Costa Rica" },
{ code: "CI", name: "Cote D'Ivoire" },
{ code: "HR", name: "Croatia" },
{ code: "CU", name: "Cuba" },
{ code: "CY", name: "Cyprus" },
{ code: "CZ", name: "Czech Republic" },
{ code: "DK", name: "Denmark" },
{ code: "DJ", name: "Djibouti" },
{ code: "DM", name: "Dominica" },
{ code: "DO", name: "Dominican Republic" },
{ code: "EC", name: "Ecuador" },
{ code: "EG", name: "Egypt" },
{ code: "SV", name: "El Salvador" },
{ code: "GQ", name: "Equatorial Guinea" },
{ code: "ER", name: "Eritrea" },
{ code: "EE", name: "Estonia" },
{ code: "ET", name: "Ethiopia" },
{ code: "FK", name: "Falkland Islands (Malvinas)" },
{ code: "FO", name: "Faroe Islands" },
{ code: "FJ", name: "Fiji" },
{ code: "FI", name: "Finland" },
{ code: "FR", name: "France" },
{ code: "GF", name: "French Guiana" },
{ code: "PF", name: "French Polynesia" },
{ code: "TF", name: "French Southern Territories" },
{ code: "GA", name: "Gabon" },
{ code: "GM", name: "Gambia" },
{ code: "GE", name: "Georgia" },
{ code: "DE", name: "Germany" },
{ code: "GH", name: "Ghana" },
{ code: "GI", name: "Gibraltar" },
{ code: "GR", name: "Greece" },
{ code: "GL", name: "Greenland" },
{ code: "GD", name: "Grenada" },
{ code: "GP", name: "Guadeloupe" },
{ code: "GU", name: "Guam" },
{ code: "GT", name: "Guatemala" },
{ code: "GG", name: "Guernsey" },
{ code: "GN", name: "Guinea" },
{ code: "GW", name: "Guinea-Bissau" },
{ code: "GY", name: "Guyana" },
{ code: "HT", name: "Haiti" },
{ code: "HM", name: "Heard Island and Mcdonald Islands" },
{ code: "VA", name: "Holy See (Vatican City State)" },
{ code: "HN", name: "Honduras" },
{ code: "HK", name: "Hong Kong" },
{ code: "HU", name: "Hungary" },
{ code: "IS", name: "Iceland" },
{ code: "IN", name: "India" },
{ code: "ID", name: "Indonesia" },
{ code: "IR", name: "Iran, Islamic Republic Of" },
{ code: "IQ", name: "Iraq" },
{ code: "IE", name: "Ireland" },
{ code: "IM", name: "Isle of Man" },
{ code: "IL", name: "Israel" },
{ code: "IT", name: "Italy" },
{ code: "JM", name: "Jamaica" },
{ code: "JP", name: "Japan" },
{ code: "JE", name: "Jersey" },
{ code: "JO", name: "Jordan" },
{ code: "KZ", name: "Kazakhstan" },
{ code: "KE", name: "Kenya" },
{ code: "KI", name: "Kiribati" },
{ code: "KP", name: "Korea, Democratic People'S Republic of" },
{ code: "KR", name: "Korea, Republic of" },
{ code: "KW", name: "Kuwait" },
{ code: "KG", name: "Kyrgyzstan" },
{ code: "LA", name: "Lao People'S Democratic Republic" },
{ code: "LV", name: "Latvia" },
{ code: "LB", name: "Lebanon" },
{ code: "LS", name: "Lesotho" },
{ code: "LR", name: "Liberia" },
{ code: "LY", name: "Libyan Arab Jamahiriya" },
{ code: "LI", name: "Liechtenstein" },
{ code: "LT", name: "Lithuania" },
{ code: "LU", name: "Luxembourg" },
{ code: "MO", name: "Macao" },
{ code: "MK", name: "Macedonia, The Former Yugoslav Republic of" },
{ code: "MG", name: "Madagascar" },
{ code: "MW", name: "Malawi" },
{ code: "MY", name: "Malaysia" },
{ code: "MV", name: "Maldives" },
{ code: "ML", name: "Mali" },
{ code: "MT", name: "Malta" },
{ code: "MH", name: "Marshall Islands" },
{ code: "MQ", name: "Martinique" },
{ code: "MR", name: "Mauritania" },
{ code: "MU", name: "Mauritius" },
{ code: "YT", name: "Mayotte" },
{ code: "MX", name: "Mexico" },
{ code: "FM", name: "Micronesia, Federated States of" },
{ code: "MD", name: "Moldova, Republic of" },
{ code: "MC", name: "Monaco" },
{ code: "MN", name: "Mongolia" },
{ code: "MS", name: "Montserrat" },
{ code: "MA", name: "Morocco" },
{ code: "MZ", name: "Mozambique" },
{ code: "MM", name: "Myanmar" },
{ code: "NA", name: "Namibia" },
{ code: "NR", name: "Nauru" },
{ code: "NP", name: "Nepal" },
{ code: "NL", name: "Netherlands" },
{ code: "AN", name: "Netherlands Antilles" },
{ code: "NC", name: "New Caledonia" },
{ code: "NZ", name: "New Zealand" },
{ code: "NI", name: "Nicaragua" },
{ code: "NE", name: "Niger" },
{ code: "NG", name: "Nigeria" },
{ code: "NU", name: "Niue" },
{ code: "NF", name: "Norfolk Island" },
{ code: "MP", name: "Northern Mariana Islands" },
{ code: "NO", name: "Norway" },
{ code: "OM", name: "Oman" },
{ code: "PK", name: "Pakistan" },
{ code: "PW", name: "Palau" },
{ code: "PS", name: "Palestinian Territory, Occupied" },
{ code: "PA", name: "Panama" },
{ code: "PG", name: "Papua New Guinea" },
{ code: "PY", name: "Paraguay" },
{ code: "PE", name: "Peru" },
{ code: "PH", name: "Philippines" },
{ code: "PN", name: "Pitcairn" },
{ code: "PL", name: "Poland" },
{ code: "PT", name: "Portugal" },
{ code: "PR", name: "Puerto Rico" },
{ code: "QA", name: "Qatar" },
{ code: "RE", name: "Reunion" },
{ code: "RO", name: "Romania" },
{ code: "RU", name: "Russian Federation" },
{ code: "RW", name: "RWANDA" },
{ code: "SH", name: "Saint Helena" },
{ code: "KN", name: "Saint Kitts and Nevis" },
{ code: "LC", name: "Saint Lucia" },
{ code: "PM", name: "Saint Pierre and Miquelon" },
{ code: "VC", name: "Saint Vincent and the Grenadines" },
{ code: "WS", name: "Samoa" },
{ code: "SM", name: "San Marino" },
{ code: "ST", name: "Sao Tome and Principe" },
{ code: "SA", name: "Saudi Arabia" },
{ code: "SN", name: "Senegal" },
{ code: "CS", name: "Serbia and Montenegro" },
{ code: "SC", name: "Seychelles" },
{ code: "SL", name: "Sierra Leone" },
{ code: "SG", name: "Singapore" },
{ code: "SK", name: "Slovakia" },
{ code: "SI", name: "Slovenia" },
{ code: "SB", name: "Solomon Islands" },
{ code: "SO", name: "Somalia" },
{ code: "ZA", name: "South Africa" },
{ code: "GS", name: "South Georgia and the South Sandwich Islands" },
{ code: "ES", name: "Spain" },
{ code: "LK", name: "Sri Lanka" },
{ code: "SD", name: "Sudan" },
{ code: "SR", name: "Suriname" },
{ code: "SJ", name: "Svalbard and Jan Mayen" },
{ code: "SZ", name: "Swaziland" },
{ code: "SE", name: "Sweden" },
{ code: "CH", name: "Switzerland" },
{ code: "SY", name: "Syrian Arab Republic" },
{ code: "TW", name: "Taiwan, Province of China" },
{ code: "TJ", name: "Tajikistan" },
{ code: "TZ", name: "Tanzania, United Republic of" },
{ code: "TH", name: "Thailand" },
{ code: "TL", name: "Timor-Leste" },
{ code: "TG", name: "Togo" },
{ code: "TK", name: "Tokelau" },
{ code: "TO", name: "Tonga" },
{ code: "TT", name: "Trinidad and Tobago" },
{ code: "TN", name: "Tunisia" },
{ code: "TR", name: "Turkey" },
{ code: "TM", name: "Turkmenistan" },
{ code: "TC", name: "Turks and Caicos Islands" },
{ code: "TV", name: "Tuvalu" },
{ code: "UG", name: "Uganda" },
{ code: "UA", name: "Ukraine" },
{ code: "AE", name: "United Arab Emirates" },
{ code: "GB", name: "United Kingdom" },
{ code: "US", name: "United States" },
{ code: "UM", name: "United States Minor Outlying Islands" },
{ code: "UY", name: "Uruguay" },
{ code: "UZ", name: "Uzbekistan" },
{ code: "VU", name: "Vanuatu" },
{ code: "VE", name: "Venezuela" },
{ code: "VN", name: "Viet Nam" },
{ code: "VG", name: "Virgin Islands, British" },
{ code: "VI", name: "Virgin Islands, U.S." },
{ code: "WF", name: "Wallis and Futuna" },
{ code: "EH", name: "Western Sahara" },
{ code: "YE", name: "Yemen" },
{ code: "ZM", name: "Zambia" },
{ code: "ZW", name: "Zimbabwe" }
];
export const tabPageProps: TabPageProps = {

View file

@ -25,7 +25,11 @@ function useListActions<TData>(
}
function toggle(data: TData) {
isSelected(data) ? remove(data) : add(data);
if (isSelected(data)) {
remove(data);
} else {
add(data);
}
}
function set(data: TData[]) {

View file

@ -13,8 +13,13 @@ function useNavigator(): UseNavigatorResult {
return (url: string, replace = false, preserveQs = false) => {
const targetUrl = preserveQs ? url + search : url;
replace ? history.replace(targetUrl) : history.push(targetUrl);
window.scrollTo({ top: 0, behavior: "smooth" });
if (replace) {
history.replace(targetUrl);
} else {
history.push(targetUrl);
}
window.scrollTo({ behavior: "smooth", top: 0 });
};
}

View file

@ -171,7 +171,7 @@ describe("Properly computes trees", () => {
[{ id: "2accessories", type: "remove" }],
[
{ id: "2accessories", type: "remove" },
{ id: "4apparel", type: "move", sortOrder: 0 },
{ id: "4apparel", sortOrder: 0, type: "move" },
{ id: "3groceries", type: "remove" }
]
];

View file

@ -6,9 +6,9 @@ export const menuList: MenuList_menus_edges_node[] = [
__typename: "Menu",
id: "TWVudTox",
items: [
{ id: "TWVudUl0ZW06MQ==", __typename: "MenuItem" },
{ id: "TWVudUl0ZW06Mg==", __typename: "MenuItem" },
{ id: "TWVudUl0ZW06Mw==", __typename: "MenuItem" }
{ __typename: "MenuItem", id: "TWVudUl0ZW06MQ==" },
{ __typename: "MenuItem", id: "TWVudUl0ZW06Mg==" },
{ __typename: "MenuItem", id: "TWVudUl0ZW06Mw==" }
],
name: "navbar"
},
@ -16,8 +16,8 @@ export const menuList: MenuList_menus_edges_node[] = [
__typename: "Menu",
id: "TWVudToy",
items: [
{ id: "TWVudUl0ZW06NA==", __typename: "MenuItem" },
{ id: "TWVudUl0ZW06Nw==", __typename: "MenuItem" }
{ __typename: "MenuItem", id: "TWVudUl0ZW06NA==" },
{ __typename: "MenuItem", id: "TWVudUl0ZW06Nw==" }
],
name: "footer"
}

View file

@ -1160,8 +1160,8 @@ export const countries = [
{ code: "AS", label: "American Samoa" }
];
export const shippingMethods = [
{ id: "s1", name: "DHL", country: "whole world", price: {} },
{ id: "s2", name: "UPS", country: "Afghanistan" }
{ country: "whole world", id: "s1", name: "DHL", price: {} },
{ country: "Afghanistan", id: "s2", name: "UPS" }
];
export const orderLineSearch = (placeholderImage: string) => [
{
@ -1177,21 +1177,21 @@ export const orderLineSearch = (placeholderImage: string) => [
__typename: "ProductVariant" as "ProductVariant",
id: "UHJvZHVjdFZhcmlhbnQ6MjAy",
name: "500ml",
price: { amount: 3.0, currency: "USD", __typename: "Money" as "Money" },
price: { __typename: "Money" as "Money", amount: 3.0, currency: "USD" },
sku: "93855755"
},
{
__typename: "ProductVariant" as "ProductVariant",
id: "UHJvZHVjdFZhcmlhbnQ6MjAz",
name: "1l",
price: { amount: 5.0, currency: "USD", __typename: "Money" as "Money" },
price: { __typename: "Money" as "Money", amount: 5.0, currency: "USD" },
sku: "43226647"
},
{
__typename: "ProductVariant" as "ProductVariant",
id: "UHJvZHVjdFZhcmlhbnQ6MjA0",
name: "2l",
price: { amount: 7.0, currency: "USD", __typename: "Money" as "Money" },
price: { __typename: "Money" as "Money", amount: 7.0, currency: "USD" },
sku: "80884671"
}
]
@ -1209,21 +1209,21 @@ export const orderLineSearch = (placeholderImage: string) => [
__typename: "ProductVariant" as "ProductVariant",
id: "UHJvZHVjdFZhcmlhbnQ6MjEx",
name: "500ml",
price: { amount: 3.0, currency: "USD", __typename: "Money" as "Money" },
price: { __typename: "Money" as "Money", amount: 3.0, currency: "USD" },
sku: "43200242"
},
{
__typename: "ProductVariant" as "ProductVariant",
id: "UHJvZHVjdFZhcmlhbnQ6MjEy",
name: "1l",
price: { amount: 5.0, currency: "USD", __typename: "Money" as "Money" },
price: { __typename: "Money" as "Money", amount: 5.0, currency: "USD" },
sku: "79129513"
},
{
__typename: "ProductVariant" as "ProductVariant",
id: "UHJvZHVjdFZhcmlhbnQ6MjEz",
name: "2l",
price: { amount: 7.0, currency: "USD", __typename: "Money" as "Money" },
price: { __typename: "Money" as "Money", amount: 7.0, currency: "USD" },
sku: "75799450"
}
]

View file

@ -99,11 +99,13 @@ const PageDetailsPage: React.FC<PageDetailsPageProps> = ({
<SeoForm
description={data.seoDescription}
disabled={disabled}
descriptionPlaceholder={maybe(() => {
return convertFromRaw(data.content)
.getPlainText()
.slice(0, 300);
}, "")}
descriptionPlaceholder={maybe(
() =>
convertFromRaw(data.content)
.getPlainText()
.slice(0, 300),
""
)}
onChange={change}
title={data.seoTitle}
titlePlaceholder={data.title}

View file

@ -19,23 +19,21 @@ export interface PageDetailsProps {
params: PageUrlQueryParams;
}
const createPageInput = (data: FormData): PageInput => {
return {
contentJson: JSON.stringify(data.content),
isPublished: data.isPublished,
publicationDate: data.isPublished
? null
: data.publicationDate === ""
? null
: data.publicationDate,
seo: {
description: data.seoDescription,
title: data.seoTitle
},
slug: data.slug === "" ? null : data.slug,
title: data.title
};
};
const createPageInput = (data: FormData): PageInput => ({
contentJson: JSON.stringify(data.content),
isPublished: data.isPublished,
publicationDate: data.isPublished
? null
: data.publicationDate === ""
? null
: data.publicationDate,
seo: {
description: data.seoDescription,
title: data.seoTitle
},
slug: data.slug === "" ? null : data.slug,
title: data.title
});
export const PageDetails: React.FC<PageDetailsProps> = ({ id, params }) => {
const navigate = useNavigator();

View file

@ -80,14 +80,12 @@ const PluginsDetailsPage: React.FC<PluginsDetailsPageProps> = props => {
<Form errors={errors} initial={initialForm} onSubmit={onSubmit}>
{({ data, errors, hasChanged, submit, set, triggerChange }) => {
const onChange = (event: ChangeEvent) => {
const { name, value } = event.target;
const newData = {
active: data.active,
active: name === "active" ? value : data.active,
configuration: data.configuration
};
const { name, value } = event.target;
name === "active"
? (newData.active = value)
: (newData.active = data.active);
if (newData.configuration) {
newData.configuration.map(item => {
if (item.name === name) {

View file

@ -98,36 +98,34 @@ const PluginList: React.FC<PluginListProps> = props => {
<TableBody>
{renderCollection(
plugins,
plugin => {
return (
<TableRow
hover={!!plugin}
className={!!plugin ? classes.link : undefined}
onClick={plugin ? onRowClick(plugin.id) : undefined}
key={plugin ? plugin.id : "skeleton"}
>
<TableCell className={classes.colName}>
{maybe<React.ReactNode>(() => plugin.name, <Skeleton />)}
</TableCell>
<TableCell className={classes.colActive}>
{maybe<React.ReactNode>(
() => (
<StatusLabel
label={translateBoolean(plugin.active, intl)}
status={plugin.active ? "success" : "error"}
/>
),
<Skeleton />
)}
</TableCell>
<TableCell className={classes.colAction}>
<div onClick={plugin ? onRowClick(plugin.id) : undefined}>
<EditIcon />
</div>
</TableCell>
</TableRow>
);
},
plugin => (
<TableRow
hover={!!plugin}
className={!!plugin ? classes.link : undefined}
onClick={plugin ? onRowClick(plugin.id) : undefined}
key={plugin ? plugin.id : "skeleton"}
>
<TableCell className={classes.colName}>
{maybe<React.ReactNode>(() => plugin.name, <Skeleton />)}
</TableCell>
<TableCell className={classes.colActive}>
{maybe<React.ReactNode>(
() => (
<StatusLabel
label={translateBoolean(plugin.active, intl)}
status={plugin.active ? "success" : "error"}
/>
),
<Skeleton />
)}
</TableCell>
<TableCell className={classes.colAction}>
<div onClick={plugin ? onRowClick(plugin.id) : undefined}>
<EditIcon />
</div>
</TableCell>
</TableRow>
),
() => (
<TableRow>
<TableCell colSpan={numberOfColumns}>

View file

@ -98,88 +98,84 @@ const ProductTypeOperations: React.FC<ProductTypeOperationsProps> = ({
onProductTypeAttributeReorder,
onProductTypeDelete,
onProductTypeUpdate
}) => {
return (
<TypedProductTypeDeleteMutation onCompleted={onProductTypeDelete}>
{(...deleteProductType) => (
<TypedProductTypeUpdateMutation onCompleted={onProductTypeUpdate}>
{(...updateProductType) => (
<TypedAssignAttributeMutation onCompleted={onAssignAttribute}>
{(...assignAttribute) => (
<TypedUnassignAttributeMutation
onCompleted={onUnassignAttribute}
>
{(...unassignAttribute) => (
<ProductTypeAttributeReorderMutation
onCompleted={onProductTypeAttributeReorder}
>
{(
reorderAttributeMutation,
reorderAttributeMutationResult
) => {
const reorderAttributeMutationFn: MutationFunction<
ProductTypeAttributeReorder,
ProductTypeAttributeReorderVariables
> = opts => {
const optimisticResponse: ProductTypeAttributeReorder = {
productTypeReorderAttributes: {
__typename: "ProductTypeReorderAttributes" as "ProductTypeReorderAttributes",
errors: [],
productType: {
...productType,
productAttributes:
opts.variables.type ===
AttributeTypeEnum.PRODUCT
? moveAttribute(
productType.productAttributes,
opts.variables.move
)
: productType.productAttributes,
variantAttributes:
opts.variables.type ===
AttributeTypeEnum.VARIANT
? moveAttribute(
productType.variantAttributes,
opts.variables.move
)
: productType.variantAttributes
}
}) => (
<TypedProductTypeDeleteMutation onCompleted={onProductTypeDelete}>
{(...deleteProductType) => (
<TypedProductTypeUpdateMutation onCompleted={onProductTypeUpdate}>
{(...updateProductType) => (
<TypedAssignAttributeMutation onCompleted={onAssignAttribute}>
{(...assignAttribute) => (
<TypedUnassignAttributeMutation onCompleted={onUnassignAttribute}>
{(...unassignAttribute) => (
<ProductTypeAttributeReorderMutation
onCompleted={onProductTypeAttributeReorder}
>
{(
reorderAttributeMutation,
reorderAttributeMutationResult
) => {
const reorderAttributeMutationFn: MutationFunction<
ProductTypeAttributeReorder,
ProductTypeAttributeReorderVariables
> = opts => {
const optimisticResponse: ProductTypeAttributeReorder = {
productTypeReorderAttributes: {
__typename: "ProductTypeReorderAttributes" as "ProductTypeReorderAttributes",
errors: [],
productType: {
...productType,
productAttributes:
opts.variables.type ===
AttributeTypeEnum.PRODUCT
? moveAttribute(
productType.productAttributes,
opts.variables.move
)
: productType.productAttributes,
variantAttributes:
opts.variables.type ===
AttributeTypeEnum.VARIANT
? moveAttribute(
productType.variantAttributes,
opts.variables.move
)
: productType.variantAttributes
}
};
return reorderAttributeMutation({
...opts,
optimisticResponse
});
}
};
return children({
assignAttribute: getMutationProviderData(
...assignAttribute
),
deleteProductType: getMutationProviderData(
...deleteProductType
),
reorderAttribute: getMutationProviderData(
reorderAttributeMutationFn,
reorderAttributeMutationResult
),
unassignAttribute: getMutationProviderData(
...unassignAttribute
),
updateProductType: getMutationProviderData(
...updateProductType
)
return reorderAttributeMutation({
...opts,
optimisticResponse
});
}}
</ProductTypeAttributeReorderMutation>
)}
</TypedUnassignAttributeMutation>
)}
</TypedAssignAttributeMutation>
)}
</TypedProductTypeUpdateMutation>
)}
</TypedProductTypeDeleteMutation>
);
};
};
return children({
assignAttribute: getMutationProviderData(
...assignAttribute
),
deleteProductType: getMutationProviderData(
...deleteProductType
),
reorderAttribute: getMutationProviderData(
reorderAttributeMutationFn,
reorderAttributeMutationResult
),
unassignAttribute: getMutationProviderData(
...unassignAttribute
),
updateProductType: getMutationProviderData(
...updateProductType
)
});
}}
</ProductTypeAttributeReorderMutation>
)}
</TypedUnassignAttributeMutation>
)}
</TypedAssignAttributeMutation>
)}
</TypedProductTypeUpdateMutation>
)}
</TypedProductTypeDeleteMutation>
);
export default ProductTypeOperations;

View file

@ -1,4 +1,3 @@
//#region
import {
add,
remove,
@ -36,7 +35,7 @@ export interface ProductVariantCreateReducerAction {
valueId?: string;
variantIndex?: number;
}
//#endregion
function selectValue(
prevState: ProductVariantCreateFormData,
attributeId: string,

View file

@ -50,30 +50,28 @@ const VariantUpdateOperations: React.FC<VariantDeleteOperationsProps> = ({
onUpdate,
onImageAssign,
onImageUnassign
}) => {
return (
<TypedVariantImageAssignMutation onCompleted={onImageAssign}>
{(...assignImage) => (
<TypedVariantImageUnassignMutation onCompleted={onImageUnassign}>
{(...unassignImage) => (
<TypedVariantUpdateMutation onCompleted={onUpdate}>
{(...updateVariant) => (
<TypedVariantDeleteMutation onCompleted={onDelete}>
{(...deleteVariant) =>
children({
assignImage: getMutationProviderData(...assignImage),
deleteVariant: getMutationProviderData(...deleteVariant),
unassignImage: getMutationProviderData(...unassignImage),
updateVariant: getMutationProviderData(...updateVariant)
})
}
</TypedVariantDeleteMutation>
)}
</TypedVariantUpdateMutation>
)}
</TypedVariantImageUnassignMutation>
)}
</TypedVariantImageAssignMutation>
);
};
}) => (
<TypedVariantImageAssignMutation onCompleted={onImageAssign}>
{(...assignImage) => (
<TypedVariantImageUnassignMutation onCompleted={onImageUnassign}>
{(...unassignImage) => (
<TypedVariantUpdateMutation onCompleted={onUpdate}>
{(...updateVariant) => (
<TypedVariantDeleteMutation onCompleted={onDelete}>
{(...deleteVariant) =>
children({
assignImage: getMutationProviderData(...assignImage),
deleteVariant: getMutationProviderData(...deleteVariant),
unassignImage: getMutationProviderData(...unassignImage),
updateVariant: getMutationProviderData(...updateVariant)
})
}
</TypedVariantDeleteMutation>
)}
</TypedVariantUpdateMutation>
)}
</TypedVariantImageUnassignMutation>
)}
</TypedVariantImageAssignMutation>
);
export default VariantUpdateOperations;

View file

@ -82,13 +82,11 @@ const ProductImage: React.FC<RouteComponentProps<any>> = ({
const ProductVariantCreate: React.FC<RouteComponentProps<any>> = ({
match
}) => {
return (
<ProductVariantCreateComponent
productId={decodeURIComponent(match.params.id)}
/>
);
};
}) => (
<ProductVariantCreateComponent
productId={decodeURIComponent(match.params.id)}
/>
);
const Component = () => {
const intl = useIntl();

View file

@ -49,80 +49,78 @@ export const ProductImage: React.FC<ProductImageProps> = ({
}}
require={["product"]}
>
{({ data, loading }) => {
return (
<TypedProductImageUpdateMutation onCompleted={handleUpdateSuccess}>
{(updateImage, updateResult) => (
<TypedProductImageDeleteMutation onCompleted={handleBack}>
{(deleteImage, deleteResult) => {
const handleDelete = () =>
deleteImage({ variables: { id: imageId } });
const handleImageClick = (id: string) => () =>
navigate(productImageUrl(productId, id));
const handleUpdate = (formData: { description: string }) => {
updateImage({
variables: {
alt: formData.description,
id: imageId
}
});
};
const image = data && data.product && data.product.mainImage;
{({ data, loading }) => (
<TypedProductImageUpdateMutation onCompleted={handleUpdateSuccess}>
{(updateImage, updateResult) => (
<TypedProductImageDeleteMutation onCompleted={handleBack}>
{(deleteImage, deleteResult) => {
const handleDelete = () =>
deleteImage({ variables: { id: imageId } });
const handleImageClick = (id: string) => () =>
navigate(productImageUrl(productId, id));
const handleUpdate = (formData: { description: string }) => {
updateImage({
variables: {
alt: formData.description,
id: imageId
}
});
};
const image = data && data.product && data.product.mainImage;
const formTransitionState = getMutationState(
updateResult.called,
updateResult.loading,
maybe(() => updateResult.data.productImageUpdate.errors)
);
const deleteTransitionState = getMutationState(
deleteResult.called,
deleteResult.loading,
[]
);
return (
<>
<ProductImagePage
disabled={loading}
product={maybe(() => data.product.name)}
image={image || null}
images={maybe(() => data.product.images)}
onBack={handleBack}
onDelete={() =>
navigate(
productImageUrl(productId, imageId, {
action: "remove"
})
)
}
onRowClick={handleImageClick}
onSubmit={handleUpdate}
saveButtonBarState={formTransitionState}
/>
<ActionDialog
onClose={() =>
navigate(productImageUrl(productId, imageId), true)
}
onConfirm={handleDelete}
open={params.action === "remove"}
title={intl.formatMessage({
defaultMessage: "Delete Image",
description: "dialog header"
})}
variant="delete"
confirmButtonState={deleteTransitionState}
>
<DialogContentText>
<FormattedMessage defaultMessage="Are you sure you want to delete this image?" />
</DialogContentText>
</ActionDialog>
</>
);
}}
</TypedProductImageDeleteMutation>
)}
</TypedProductImageUpdateMutation>
);
}}
const formTransitionState = getMutationState(
updateResult.called,
updateResult.loading,
maybe(() => updateResult.data.productImageUpdate.errors)
);
const deleteTransitionState = getMutationState(
deleteResult.called,
deleteResult.loading,
[]
);
return (
<>
<ProductImagePage
disabled={loading}
product={maybe(() => data.product.name)}
image={image || null}
images={maybe(() => data.product.images)}
onBack={handleBack}
onDelete={() =>
navigate(
productImageUrl(productId, imageId, {
action: "remove"
})
)
}
onRowClick={handleImageClick}
onSubmit={handleUpdate}
saveButtonBarState={formTransitionState}
/>
<ActionDialog
onClose={() =>
navigate(productImageUrl(productId, imageId), true)
}
onConfirm={handleDelete}
open={params.action === "remove"}
title={intl.formatMessage({
defaultMessage: "Delete Image",
description: "dialog header"
})}
variant="delete"
confirmButtonState={deleteTransitionState}
>
<DialogContentText>
<FormattedMessage defaultMessage="Are you sure you want to delete this image?" />
</DialogContentText>
</ActionDialog>
</>
);
}}
</TypedProductImageDeleteMutation>
)}
</TypedProductImageUpdateMutation>
)}
</TypedProductImageQuery>
);
};

View file

@ -12,7 +12,7 @@ const SiteSettings: React.FC<RouteComponentProps<{}>> = ({ location }) => {
return <SiteSettingsComponent params={params} />;
};
export const SiteSettingsSection: React.FC = () => {
return <Route path={siteSettingsPath} component={SiteSettings} />;
};
export const SiteSettingsSection: React.FC = () => (
<Route path={siteSettingsPath} component={SiteSettings} />
);
export default SiteSettingsSection;

View file

@ -7,10 +7,10 @@ import CardDecorator from "../../CardDecorator";
import Decorator from "../../Decorator";
const choices = [
{ value: "1", label: "Apparel" },
{ value: "2", label: "Groceries" },
{ value: "3", label: "Books" },
{ value: "4", label: "Accessories" }
{ label: "Apparel", value: "1" },
{ label: "Groceries", value: "2" },
{ label: "Books", value: "3" },
{ label: "Accessories", value: "4" }
];
storiesOf("Generics / MultiSelectField", module)

View file

@ -12,7 +12,7 @@ export const content: RawDraftContentState = {
data: {},
depth: 0,
entityRanges: [],
inlineStyleRanges: [{ offset: 0, length: 4, style: "BOLD" }],
inlineStyleRanges: [{ length: 4, offset: 0, style: "BOLD" }],
key: "rosn",
text: "bold",
type: "unstyled"
@ -21,7 +21,7 @@ export const content: RawDraftContentState = {
data: {},
depth: 0,
entityRanges: [],
inlineStyleRanges: [{ offset: 0, length: 6, style: "ITALIC" }],
inlineStyleRanges: [{ length: 6, offset: 0, style: "ITALIC" }],
key: "6tbch",
text: "italic",
type: "unstyled"
@ -30,7 +30,7 @@ export const content: RawDraftContentState = {
data: {},
depth: 0,
entityRanges: [],
inlineStyleRanges: [{ offset: 0, length: 13, style: "STRIKETHROUGH" }],
inlineStyleRanges: [{ length: 13, offset: 0, style: "STRIKETHROUGH" }],
key: "1p044",
text: "strikethrough",
type: "unstyled"
@ -92,7 +92,7 @@ export const content: RawDraftContentState = {
{
data: {},
depth: 0,
entityRanges: [{ offset: 0, length: 4, key: 0 }],
entityRanges: [{ key: 0, length: 4, offset: 0 }],
inlineStyleRanges: [],
key: "5aejo",
text: "link",
@ -100,7 +100,7 @@ export const content: RawDraftContentState = {
}
],
entityMap: {
"0": { type: "LINK", mutability: "MUTABLE", data: { url: "#" } }
"0": { data: { url: "#" }, mutability: "MUTABLE", type: "LINK" }
}
};
storiesOf("Generics / Rich text editor", module)

View file

@ -6,10 +6,10 @@ import CardDecorator from "../../CardDecorator";
import Decorator from "../../Decorator";
const choices = [
{ value: "1", label: "Apparel" },
{ value: "2", label: "Groceries" },
{ value: "3", label: "Books" },
{ value: "4", label: "Accessories" }
{ label: "Apparel", value: "1" },
{ label: "Groceries", value: "2" },
{ label: "Books", value: "3" },
{ label: "Accessories", value: "4" }
];
storiesOf("Generics / SingleSelectField", module)

View file

@ -5,7 +5,7 @@ import placeholder from "@assets/images/placeholder1080x1080.png";
import ProductImagePage from "../../../products/components/ProductImagePage";
import Decorator from "../../Decorator";
const image = { id: "", url: placeholder, alt: "Lorem ipsum" };
const image = { alt: "Lorem ipsum", id: "", url: placeholder };
const images = (Array(8) as any)
.fill({ id: "img", url: placeholder })
.map((image, imageIndex) => ({ ...image, id: image.id + imageIndex }));

View file

@ -9,11 +9,10 @@ import classNames from "classnames";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { ListProps } from "../../../types";
import ResponsiveTable from "@saleor/components/ResponsiveTable";
import Skeleton from "@saleor/components/Skeleton";
import TablePagination from "@saleor/components/TablePagination";
import Skeleton from "@saleor/components/Skeleton";
import { ListProps } from "../../../types";
import { maybe, renderCollection } from "../../../misc";
export interface TranslatableEntity {