2019-10-11 12:55:35 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
|
2020-08-03 19:24:57 +00:00
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
2019-10-21 03:11:21 +00:00
|
|
|
import { applyFilters } from '@wordpress/hooks';
|
2020-07-16 15:17:10 +00:00
|
|
|
import {
|
|
|
|
getHistory,
|
|
|
|
getNewPath,
|
|
|
|
updateQueryString,
|
|
|
|
} from '@woocommerce/navigation';
|
2020-07-14 01:40:56 +00:00
|
|
|
import { Fragment } from '@wordpress/element';
|
2020-08-20 04:59:52 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
2019-10-11 12:55:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import Appearance from './tasks/appearance';
|
2020-08-13 02:05:22 +00:00
|
|
|
import { getCategorizedOnboardingProducts } from '../dashboard/utils';
|
2021-01-25 16:52:42 +00:00
|
|
|
import { Products } from './tasks/products';
|
2019-10-11 12:55:35 +00:00
|
|
|
import Shipping from './tasks/shipping';
|
|
|
|
import Tax from './tasks/tax';
|
2021-06-28 18:18:42 +00:00
|
|
|
import { PaymentGatewaySuggestions } from './tasks/PaymentGatewaySuggestions';
|
2021-03-08 14:23:39 +00:00
|
|
|
import {
|
|
|
|
installActivateAndConnectWcpay,
|
|
|
|
isWCPaySupported,
|
2021-06-28 18:18:42 +00:00
|
|
|
} from './tasks/PaymentGatewaySuggestions/components/WCPay';
|
2021-01-06 22:08:57 +00:00
|
|
|
import { groupListOfObjectsBy } from '../lib/collections';
|
2021-04-13 19:49:29 +00:00
|
|
|
import { getLinkTypeAndHref } from '~/store-management-links';
|
2020-07-14 01:40:56 +00:00
|
|
|
|
|
|
|
export function recordTaskViewEvent(
|
|
|
|
taskName,
|
|
|
|
isJetpackConnected,
|
|
|
|
activePlugins,
|
|
|
|
installedPlugins
|
|
|
|
) {
|
|
|
|
recordEvent( 'task_view', {
|
|
|
|
task_name: taskName,
|
|
|
|
wcs_installed: installedPlugins.includes( 'woocommerce-services' ),
|
|
|
|
wcs_active: activePlugins.includes( 'woocommerce-services' ),
|
|
|
|
jetpack_installed: installedPlugins.includes( 'jetpack' ),
|
|
|
|
jetpack_active: activePlugins.includes( 'jetpack' ),
|
|
|
|
jetpack_connected: isJetpackConnected,
|
|
|
|
} );
|
|
|
|
}
|
2019-10-11 12:55:35 +00:00
|
|
|
|
2020-02-14 02:23:21 +00:00
|
|
|
export function getAllTasks( {
|
2020-08-24 13:20:57 +00:00
|
|
|
activePlugins,
|
2020-08-03 08:22:25 +00:00
|
|
|
countryCode,
|
2020-08-24 13:20:57 +00:00
|
|
|
createNotice,
|
|
|
|
installAndActivatePlugins,
|
|
|
|
installedPlugins,
|
|
|
|
isJetpackConnected,
|
|
|
|
onboardingStatus,
|
2020-02-14 02:23:21 +00:00
|
|
|
profileItems,
|
|
|
|
query,
|
|
|
|
toggleCartModal,
|
2020-12-18 13:17:07 +00:00
|
|
|
onTaskSelect,
|
2021-06-01 18:04:21 +00:00
|
|
|
hasCompleteAddress,
|
2020-02-14 02:23:21 +00:00
|
|
|
} ) {
|
2019-10-11 12:55:35 +00:00
|
|
|
const {
|
2020-08-11 12:20:48 +00:00
|
|
|
hasPaymentGateway,
|
2019-10-11 12:55:35 +00:00
|
|
|
hasPhysicalProducts,
|
|
|
|
hasProducts,
|
2020-01-09 02:05:03 +00:00
|
|
|
isAppearanceComplete,
|
2019-10-11 12:55:35 +00:00
|
|
|
isTaxComplete,
|
|
|
|
shippingZonesCount,
|
2020-08-11 12:20:48 +00:00
|
|
|
wcPayIsConnected,
|
2020-08-24 13:20:57 +00:00
|
|
|
} = {
|
2020-08-11 12:20:48 +00:00
|
|
|
hasPaymentGateway: false,
|
2019-10-11 12:55:35 +00:00
|
|
|
hasPhysicalProducts: false,
|
|
|
|
hasProducts: false,
|
2020-01-09 02:05:03 +00:00
|
|
|
isAppearanceComplete: false,
|
2019-10-11 12:55:35 +00:00
|
|
|
isTaxComplete: false,
|
|
|
|
shippingZonesCount: 0,
|
2020-08-11 12:20:48 +00:00
|
|
|
wcPayIsConnected: false,
|
2020-08-24 13:20:57 +00:00
|
|
|
...onboardingStatus,
|
|
|
|
};
|
2019-10-11 12:55:35 +00:00
|
|
|
|
2020-08-03 19:24:57 +00:00
|
|
|
const groupedProducts = getCategorizedOnboardingProducts(
|
2020-05-25 00:26:08 +00:00
|
|
|
profileItems,
|
|
|
|
installedPlugins
|
|
|
|
);
|
2020-08-03 19:24:57 +00:00
|
|
|
const { products, remainingProducts, uniqueItemsList } = groupedProducts;
|
|
|
|
|
2020-07-14 01:40:56 +00:00
|
|
|
const woocommercePaymentsInstalled =
|
|
|
|
installedPlugins.indexOf( 'woocommerce-payments' ) !== -1;
|
2021-06-01 18:04:21 +00:00
|
|
|
const woocommerceServicesActive =
|
|
|
|
activePlugins.indexOf( 'woocommerce-services' ) !== -1;
|
2020-07-16 15:17:10 +00:00
|
|
|
const {
|
|
|
|
completed: profilerCompleted,
|
|
|
|
product_types: productTypes,
|
2021-03-08 14:23:39 +00:00
|
|
|
business_extensions: businessExtensions,
|
2020-07-16 15:17:10 +00:00
|
|
|
} = profileItems;
|
2020-07-14 01:40:56 +00:00
|
|
|
|
2021-03-08 14:23:39 +00:00
|
|
|
const woocommercePaymentsSelectedInProfiler = (
|
|
|
|
businessExtensions || []
|
|
|
|
).includes( 'woocommerce-payments' );
|
|
|
|
|
2021-06-01 18:04:21 +00:00
|
|
|
let purchaseAndInstallTitle = __(
|
2021-05-21 01:13:40 +00:00
|
|
|
'Add paid extensions to my store',
|
2021-01-07 00:20:12 +00:00
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
2021-06-01 18:04:21 +00:00
|
|
|
let purchaseAndInstallContent;
|
2020-08-03 19:24:57 +00:00
|
|
|
|
|
|
|
if ( uniqueItemsList.length === 1 ) {
|
2020-12-01 11:55:27 +00:00
|
|
|
const { name: itemName } = uniqueItemsList[ 0 ];
|
|
|
|
const purchaseAndInstallFormat = __(
|
2021-05-21 01:13:40 +00:00
|
|
|
'Add %s to my store',
|
2020-12-01 11:55:27 +00:00
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
2021-06-01 18:04:21 +00:00
|
|
|
purchaseAndInstallTitle = sprintf( purchaseAndInstallFormat, itemName );
|
|
|
|
purchaseAndInstallContent = products.find(
|
|
|
|
( { label } ) => label === itemName
|
|
|
|
)?.description;
|
|
|
|
} else {
|
|
|
|
const uniqueProductNames = uniqueItemsList.map( ( { name } ) => name );
|
|
|
|
const lastProduct = uniqueProductNames.pop();
|
|
|
|
let firstProducts = uniqueProductNames.join( ', ' );
|
|
|
|
if ( uniqueProductNames.length > 1 ) {
|
|
|
|
firstProducts += ',';
|
|
|
|
}
|
|
|
|
/* translators: %1$s: list of product names comma separated, %2%s the last product name */
|
|
|
|
purchaseAndInstallContent = sprintf(
|
|
|
|
__(
|
|
|
|
'Good choice! You chose to add %1$s and %2$s to your store.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
firstProducts,
|
|
|
|
lastProduct
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const {
|
|
|
|
automatedTaxSupportedCountries = [],
|
|
|
|
taxJarActivated,
|
|
|
|
} = onboardingStatus;
|
|
|
|
|
|
|
|
const isTaxJarSupported =
|
|
|
|
! taxJarActivated && // WCS integration doesn't work with the official TaxJar plugin.
|
|
|
|
automatedTaxSupportedCountries.includes( countryCode );
|
|
|
|
|
|
|
|
const canUseAutomatedTaxes =
|
|
|
|
hasCompleteAddress && woocommerceServicesActive && isTaxJarSupported;
|
|
|
|
|
|
|
|
let taxAction = __( "Let's go", 'woocommerce-admin' );
|
|
|
|
let taxContent = __(
|
|
|
|
'Set your store location and configure tax rate settings.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( canUseAutomatedTaxes ) {
|
|
|
|
taxAction = __( 'Yes please', 'woocommerce-admin' );
|
|
|
|
taxContent = __(
|
|
|
|
'Good news! WooCommerce Services and Jetpack can automate your sales tax calculations for you.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
);
|
2020-08-03 19:24:57 +00:00
|
|
|
}
|
|
|
|
|
2019-10-21 03:11:21 +00:00
|
|
|
const tasks = [
|
2020-05-27 16:08:39 +00:00
|
|
|
{
|
|
|
|
key: 'store_details',
|
2020-09-24 11:53:13 +00:00
|
|
|
title: __( 'Store details', 'woocommerce-admin' ),
|
2021-06-01 18:04:21 +00:00
|
|
|
content: __(
|
|
|
|
'Your store address is required to set the origin country for shipping, currencies, and payment options.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2020-05-27 16:08:39 +00:00
|
|
|
container: null,
|
2021-06-01 18:04:21 +00:00
|
|
|
action: __( "Let's go", 'woocommerce-admin' ),
|
2020-05-27 16:08:39 +00:00
|
|
|
onClick: () => {
|
2020-12-18 13:17:07 +00:00
|
|
|
onTaskSelect( 'store_details' );
|
2020-08-27 12:10:23 +00:00
|
|
|
getHistory().push( getNewPath( {}, '/setup-wizard', {} ) );
|
2020-05-27 16:08:39 +00:00
|
|
|
},
|
2020-07-16 15:17:10 +00:00
|
|
|
completed: profilerCompleted,
|
2020-05-27 16:08:39 +00:00
|
|
|
visible: true,
|
|
|
|
time: __( '4 minutes', 'woocommerce-admin' ),
|
2020-12-03 21:16:04 +00:00
|
|
|
type: 'setup',
|
2020-05-27 16:08:39 +00:00
|
|
|
},
|
2019-12-31 08:50:45 +00:00
|
|
|
{
|
|
|
|
key: 'purchase',
|
2021-06-01 18:04:21 +00:00
|
|
|
title: purchaseAndInstallTitle,
|
|
|
|
content: purchaseAndInstallContent,
|
2019-12-31 08:50:45 +00:00
|
|
|
container: null,
|
2021-06-01 18:04:21 +00:00
|
|
|
action: __( 'Purchase & install now', 'woocommerce-admin' ),
|
2020-07-16 16:54:31 +00:00
|
|
|
onClick: () => {
|
2020-12-18 13:17:07 +00:00
|
|
|
onTaskSelect( 'purchase' );
|
2020-08-03 19:24:57 +00:00
|
|
|
return remainingProducts.length ? toggleCartModal() : null;
|
2020-07-16 16:54:31 +00:00
|
|
|
},
|
2020-08-03 19:24:57 +00:00
|
|
|
visible: products.length,
|
|
|
|
completed: products.length && ! remainingProducts.length,
|
2020-05-27 16:08:39 +00:00
|
|
|
time: __( '2 minutes', 'woocommerce-admin' ),
|
2020-07-14 10:46:25 +00:00
|
|
|
isDismissable: true,
|
2020-12-03 21:16:04 +00:00
|
|
|
type: 'setup',
|
2019-12-31 08:50:45 +00:00
|
|
|
},
|
2019-10-11 12:55:35 +00:00
|
|
|
{
|
|
|
|
key: 'products',
|
2021-05-21 01:13:40 +00:00
|
|
|
title: __( 'Add my products', 'woocommerce-admin' ),
|
2021-06-01 18:04:21 +00:00
|
|
|
content: __(
|
|
|
|
'Start by adding the first product to your store. You can add your products manually, via CSV, or import them from another service.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2019-10-11 12:55:35 +00:00
|
|
|
container: <Products />,
|
2020-07-16 16:54:31 +00:00
|
|
|
onClick: () => {
|
2020-12-18 13:17:07 +00:00
|
|
|
onTaskSelect( 'products' );
|
2020-07-16 16:54:31 +00:00
|
|
|
updateQueryString( { task: 'products' } );
|
|
|
|
},
|
2019-10-11 12:55:35 +00:00
|
|
|
completed: hasProducts,
|
|
|
|
visible: true,
|
2020-05-27 16:08:39 +00:00
|
|
|
time: __( '1 minute per product', 'woocommerce-admin' ),
|
2020-12-03 21:16:04 +00:00
|
|
|
type: 'setup',
|
2019-10-11 12:55:35 +00:00
|
|
|
},
|
2020-07-14 01:40:56 +00:00
|
|
|
{
|
|
|
|
key: 'woocommerce-payments',
|
2021-04-02 03:36:52 +00:00
|
|
|
title: __(
|
|
|
|
'Get paid with WooCommerce Payments',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2021-06-01 18:04:21 +00:00
|
|
|
content: __(
|
|
|
|
"You're only one step away from getting paid. Verify your business details to start managing transactions with WooCommerce Payments.",
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
|
|
|
action: __( 'Finish setup', 'woocommmerce-admin' ),
|
|
|
|
expanded: true,
|
2020-07-14 01:40:56 +00:00
|
|
|
container: <Fragment />,
|
2020-08-11 12:20:48 +00:00
|
|
|
completed: wcPayIsConnected,
|
2020-09-03 02:28:31 +00:00
|
|
|
onClick: async ( e ) => {
|
|
|
|
if ( e.target.nodeName === 'A' ) {
|
|
|
|
// This is a nested link, so don't activate the task.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-07-14 01:40:56 +00:00
|
|
|
await new Promise( ( resolve, reject ) => {
|
|
|
|
// This task doesn't have a view, so the recordEvent call
|
|
|
|
// in TaskDashboard.recordTaskView() is never called. So
|
|
|
|
// record it here.
|
|
|
|
recordTaskViewEvent(
|
|
|
|
'wcpay',
|
|
|
|
isJetpackConnected,
|
|
|
|
activePlugins,
|
|
|
|
installedPlugins
|
|
|
|
);
|
2020-12-18 13:17:07 +00:00
|
|
|
onTaskSelect( 'woocommerce-payments' );
|
2020-07-14 01:40:56 +00:00
|
|
|
return installActivateAndConnectWcpay(
|
|
|
|
reject,
|
|
|
|
createNotice,
|
|
|
|
installAndActivatePlugins
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
visible:
|
2021-03-08 14:23:39 +00:00
|
|
|
woocommercePaymentsSelectedInProfiler &&
|
2020-08-03 08:22:25 +00:00
|
|
|
woocommercePaymentsInstalled &&
|
2021-03-08 14:23:39 +00:00
|
|
|
isWCPaySupported( countryCode ),
|
2020-09-03 02:28:31 +00:00
|
|
|
additionalInfo: __(
|
|
|
|
'By setting up, you are agreeing to the <a href="https://wordpress.com/tos/" target="_blank">Terms of Service</a>',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2020-07-14 01:40:56 +00:00
|
|
|
time: __( '2 minutes', 'woocommerce-admin' ),
|
2020-12-03 21:16:04 +00:00
|
|
|
type: 'setup',
|
2020-07-14 01:40:56 +00:00
|
|
|
},
|
2019-10-11 12:55:35 +00:00
|
|
|
{
|
2020-07-16 18:09:36 +00:00
|
|
|
key: 'payments',
|
2021-05-21 01:13:40 +00:00
|
|
|
title: __( 'Set up payments', 'woocommerce-admin' ),
|
2021-06-01 18:04:21 +00:00
|
|
|
content: __(
|
|
|
|
'Choose payment providers and enable payment methods at checkout.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2021-06-28 18:18:42 +00:00
|
|
|
container: <PaymentGatewaySuggestions query={ query } />,
|
2020-08-11 12:20:48 +00:00
|
|
|
completed: hasPaymentGateway,
|
2020-07-16 16:54:31 +00:00
|
|
|
onClick: () => {
|
2020-12-18 13:17:07 +00:00
|
|
|
onTaskSelect( 'payments' );
|
2020-07-16 18:09:36 +00:00
|
|
|
updateQueryString( { task: 'payments' } );
|
2020-07-16 16:54:31 +00:00
|
|
|
},
|
2021-03-08 14:23:39 +00:00
|
|
|
visible:
|
2021-06-28 18:18:42 +00:00
|
|
|
window.wcAdminFeatures[ 'payment-gateway-suggestions' ] &&
|
|
|
|
( ! woocommercePaymentsInstalled ||
|
|
|
|
! woocommercePaymentsSelectedInProfiler ||
|
|
|
|
! isWCPaySupported( countryCode ) ),
|
2020-05-27 16:08:39 +00:00
|
|
|
time: __( '2 minutes', 'woocommerce-admin' ),
|
2020-12-03 21:16:04 +00:00
|
|
|
type: 'setup',
|
2019-10-11 12:55:35 +00:00
|
|
|
},
|
2020-07-16 18:09:36 +00:00
|
|
|
{
|
|
|
|
key: 'tax',
|
2021-05-21 01:13:40 +00:00
|
|
|
title: __( 'Set up tax', 'woocommerce-admin' ),
|
2021-06-01 18:04:21 +00:00
|
|
|
content: taxContent,
|
2020-07-16 18:09:36 +00:00
|
|
|
container: <Tax />,
|
2021-06-01 18:04:21 +00:00
|
|
|
action: taxAction,
|
|
|
|
onClick: ( e, args = {} ) => {
|
|
|
|
// The expanded item CTA allows us to enable
|
|
|
|
// automated taxes for eligible stores.
|
|
|
|
// Note: this will be initially part of an A/B test.
|
|
|
|
const { isExpanded } = args;
|
2020-12-18 13:17:07 +00:00
|
|
|
onTaskSelect( 'tax' );
|
2021-06-01 18:04:21 +00:00
|
|
|
updateQueryString( {
|
|
|
|
task: 'tax',
|
|
|
|
auto: canUseAutomatedTaxes && isExpanded,
|
|
|
|
} );
|
2020-07-16 18:09:36 +00:00
|
|
|
},
|
|
|
|
completed: isTaxComplete,
|
|
|
|
visible: true,
|
|
|
|
time: __( '1 minute', 'woocommerce-admin' ),
|
2020-12-03 21:16:04 +00:00
|
|
|
type: 'setup',
|
2020-07-16 18:09:36 +00:00
|
|
|
},
|
2019-10-11 12:55:35 +00:00
|
|
|
{
|
|
|
|
key: 'shipping',
|
2021-05-21 01:13:40 +00:00
|
|
|
title: __( 'Set up shipping', 'woocommerce-admin' ),
|
2021-06-01 18:04:21 +00:00
|
|
|
content: __(
|
|
|
|
"Set your store location and where you'll ship to.",
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2019-10-11 12:55:35 +00:00
|
|
|
container: <Shipping />,
|
2021-06-01 18:04:21 +00:00
|
|
|
action: __( "Let's go", 'woocommerce-admin' ),
|
2020-07-16 16:54:31 +00:00
|
|
|
onClick: () => {
|
2021-04-13 19:49:29 +00:00
|
|
|
if ( shippingZonesCount > 0 ) {
|
|
|
|
window.location = getLinkTypeAndHref( {
|
|
|
|
type: 'wc-settings',
|
|
|
|
tab: 'shipping',
|
|
|
|
} ).href;
|
|
|
|
} else {
|
|
|
|
onTaskSelect( 'shipping' );
|
|
|
|
updateQueryString( { task: 'shipping' } );
|
|
|
|
}
|
2020-07-16 16:54:31 +00:00
|
|
|
},
|
2020-10-09 20:28:41 +00:00
|
|
|
completed: shippingZonesCount > 0,
|
2019-10-17 14:39:59 +00:00
|
|
|
visible:
|
2020-07-16 15:17:10 +00:00
|
|
|
( productTypes && productTypes.includes( 'physical' ) ) ||
|
2019-10-17 14:39:59 +00:00
|
|
|
hasPhysicalProducts,
|
2020-05-27 16:08:39 +00:00
|
|
|
time: __( '1 minute', 'woocommerce-admin' ),
|
2020-12-03 21:16:04 +00:00
|
|
|
type: 'setup',
|
2019-10-11 12:55:35 +00:00
|
|
|
},
|
|
|
|
{
|
2020-07-16 18:09:36 +00:00
|
|
|
key: 'appearance',
|
2021-05-21 01:13:40 +00:00
|
|
|
title: __( 'Personalize my store', 'woocommerce-admin' ),
|
2021-06-01 18:04:21 +00:00
|
|
|
content: __(
|
|
|
|
'Add your logo, create a homepage, and start designing your store.',
|
|
|
|
'woocommerce-admin'
|
|
|
|
),
|
2020-07-16 18:09:36 +00:00
|
|
|
container: <Appearance />,
|
2021-06-01 18:04:21 +00:00
|
|
|
action: __( "Let's go", 'woocommerce-admin' ),
|
2020-07-16 16:54:31 +00:00
|
|
|
onClick: () => {
|
2020-12-18 13:17:07 +00:00
|
|
|
onTaskSelect( 'appearance' );
|
2020-07-16 18:09:36 +00:00
|
|
|
updateQueryString( { task: 'appearance' } );
|
2020-07-16 16:54:31 +00:00
|
|
|
},
|
2020-07-16 18:09:36 +00:00
|
|
|
completed: isAppearanceComplete,
|
2019-10-11 12:55:35 +00:00
|
|
|
visible: true,
|
2020-05-27 16:08:39 +00:00
|
|
|
time: __( '2 minutes', 'woocommerce-admin' ),
|
2020-12-03 21:16:04 +00:00
|
|
|
type: 'setup',
|
2019-10-11 12:55:35 +00:00
|
|
|
},
|
|
|
|
];
|
2021-05-05 17:43:46 +00:00
|
|
|
const filteredTasks = applyFilters(
|
|
|
|
'woocommerce_admin_onboarding_task_list',
|
|
|
|
tasks,
|
|
|
|
query
|
2020-02-14 02:23:21 +00:00
|
|
|
);
|
2021-05-05 17:43:46 +00:00
|
|
|
for ( const task of filteredTasks ) {
|
|
|
|
task.level = task.level ? parseInt( task.level, 10 ) : 3;
|
|
|
|
}
|
|
|
|
return groupListOfObjectsBy( filteredTasks, 'type', 'extension' );
|
|
|
|
}
|
|
|
|
|
|
|
|
export function taskSort( a, b ) {
|
|
|
|
if ( a.completed || b.completed ) {
|
|
|
|
return a.completed ? 1 : -1;
|
|
|
|
}
|
|
|
|
// Three is the lowest level.
|
|
|
|
const aLevel = a.level || 3;
|
|
|
|
const bLevel = b.level || 3;
|
|
|
|
if ( aLevel === bLevel ) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return aLevel > bLevel ? 1 : -1;
|
2019-10-11 12:55:35 +00:00
|
|
|
}
|