From 412b865c47bb7eeccf2feb4cd166845c3da3814a Mon Sep 17 00:00:00 2001 From: Jason Conroy Date: Thu, 12 Nov 2020 13:01:36 +1030 Subject: [PATCH] Example options --- js/src/get-started-page/index.js | 52 +++++++++++- package-lock.json | 134 +++++++++++++++++++++++++++++++ package.json | 3 + 3 files changed, 187 insertions(+), 2 deletions(-) diff --git a/js/src/get-started-page/index.js b/js/src/get-started-page/index.js index 1cf614a0ae..d4d8a4b5a8 100644 --- a/js/src/get-started-page/index.js +++ b/js/src/get-started-page/index.js @@ -2,18 +2,66 @@ * External dependencies */ import { __ } from '@wordpress/i18n'; +import { compose } from '@wordpress/compose'; +import { withDispatch, withSelect } from '@wordpress/data'; +import { OPTIONS_STORE_NAME } from '@woocommerce/data'; +import { Button } from '@wordpress/components'; /** * Internal dependencies */ import './index.scss'; -const GetStartedPage = ( { query } ) => { +const GetStartedPage = ( { query, optionView, updateOptions } ) => { + + const updateTest = () => { + + let temp = optionView; + + if (temp == 'yes') { + temp = 'no'; + } else { + temp = 'yes'; + } + + console.log(temp); + + updateOptions( { + gla_started: temp, + } ); + }; + return (
Hello World! +
+ +
); }; -export default GetStartedPage; +export { GetStartedPage }; + +// default export +export default compose( + withSelect( ( select ) => { + const { getOption, isOptionsUpdating } = select( OPTIONS_STORE_NAME ); + const isUpdateRequesting = isOptionsUpdating(); + + return { + optionView: getOption( 'gla_started' ), + }; + } ), + withDispatch( ( dispatch ) => { + const { updateOptions } = dispatch( OPTIONS_STORE_NAME ); + return { + updateOptions, + }; + } ) +)( GetStartedPage ); diff --git a/package-lock.json b/package-lock.json index 1025b03676..3babb488b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3005,6 +3005,75 @@ "@xtuc/long": "4.2.2" } }, + "@woocommerce/data": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@woocommerce/data/-/data-1.1.1.tgz", + "integrity": "sha512-grmCllxDV/0PB8Mc+w9TQFJkAzO/yjjdDmaOzNk2ICuoz2ZhUGiFXnvZmWLyZr9BDtoYK+/jBIsM2ezr34b3ww==", + "requires": { + "@babel/runtime-corejs2": "7.11.2" + } + }, + "@woocommerce/date": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@woocommerce/date/-/date-2.1.0.tgz", + "integrity": "sha512-gZutoGaeKtalq5DQFc1751CyyMDIDVahfp+f2NAuafeWC8q/5KjqjdAPFDl3qSQGe+yZmdYiQHSwMPFOjfzSEg==", + "requires": { + "@babel/runtime-corejs2": "7.10.5", + "@wordpress/date": "3.9.0", + "@wordpress/i18n": "3.11.0", + "lodash": "4.17.15", + "moment": "2.27.0" + }, + "dependencies": { + "@babel/runtime-corejs2": { + "version": "7.10.5", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.10.5.tgz", + "integrity": "sha512-LJwyb1ac//Jr2zrGTTaNJhrP1wYCgVw9rzHbQPogKXCTLQ60EEWgeNtuqs6cLsq64O557SYzziCrOxNp0rRi8w==", + "requires": { + "core-js": "^2.6.5", + "regenerator-runtime": "^0.13.4" + } + }, + "@wordpress/date": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/@wordpress/date/-/date-3.9.0.tgz", + "integrity": "sha512-V4+k6Ipkm/JX1TzRcwo96v0Lk1m1NGAHwO9JsnUCCXlG1Qxgl+MxRkWpgmUwgdCDjVvevS/4bU+LvndDWQIzVA==", + "requires": { + "@babel/runtime": "^7.9.2", + "moment": "^2.22.1", + "moment-timezone": "^0.5.16" + } + }, + "@wordpress/i18n": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/@wordpress/i18n/-/i18n-3.11.0.tgz", + "integrity": "sha512-wcu8NBxaSu8b4Bj+Nt4dMQvziQrfdgTeEGSRy9GzJChTVpFdyZT88zAaPbK+W8yqFaX3zMSf4rHpZSP6QvWkQg==", + "requires": { + "@babel/runtime": "^7.9.2", + "gettext-parser": "^1.3.1", + "lodash": "^4.17.15", + "memize": "^1.1.0", + "sprintf-js": "^1.1.1", + "tannin": "^1.2.0" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + }, + "moment": { + "version": "2.27.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz", + "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==" + }, + "sprintf-js": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==" + } + } + }, "@woocommerce/eslint-plugin": { "version": "1.0.0-beta.0", "resolved": "https://registry.npmjs.org/@woocommerce/eslint-plugin/-/eslint-plugin-1.0.0-beta.0.tgz", @@ -3018,6 +3087,38 @@ "requireindex": "^1.2.0" } }, + "@woocommerce/navigation": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@woocommerce/navigation/-/navigation-5.2.0.tgz", + "integrity": "sha512-tDtDZjqqw5LtSqHhx3PDGx/kt4l45qzRNJ0sZZwJMbM/If2Y8WfRr7ceXVGuuypH0vLC7T9TGHnEcMK1iXKXqw==", + "requires": { + "@babel/runtime-corejs2": "7.12.5", + "history": "4.10.1", + "lodash": "4.17.15", + "qs": "6.9.4" + }, + "dependencies": { + "@babel/runtime-corejs2": { + "version": "7.12.5", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.12.5.tgz", + "integrity": "sha512-kt5YpZ7F5A05LOgQuaMXXmcxakK/qttf5C/E1BJPA3Kf5PanbjPzDoXN+PIslUnjUxpuKblCsXyP0QfMiqyKqA==", + "requires": { + "core-js": "^2.6.5", + "regenerator-runtime": "^0.13.4" + } + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + }, + "qs": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==" + } + } + }, "@woocommerce/tracks": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@woocommerce/tracks/-/tracks-1.0.0.tgz", @@ -8990,6 +9091,19 @@ "minimalistic-assert": "^1.0.1" } }, + "history": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", + "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", + "requires": { + "@babel/runtime": "^7.1.2", + "loose-envify": "^1.2.0", + "resolve-pathname": "^3.0.0", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0", + "value-equal": "^1.0.1" + } + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -15778,6 +15892,11 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==" }, + "resolve-pathname": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-3.0.0.tgz", + "integrity": "sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==" + }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", @@ -17748,6 +17867,11 @@ "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" }, + "tiny-invariant": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.1.0.tgz", + "integrity": "sha512-ytxQvrb1cPc9WBEI/HSeYYoGD0kWnGEOR8RY6KomWLBVhqz0RgTwVO9dLrGz7dC+nN9llyI7OKAgRq8Vq4ZBSw==" + }, "tiny-lr": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/tiny-lr/-/tiny-lr-1.1.1.tgz", @@ -17773,6 +17897,11 @@ } } }, + "tiny-warning": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz", + "integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==" + }, "tinycolor2": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.4.2.tgz", @@ -18408,6 +18537,11 @@ "spdx-expression-parse": "^3.0.0" } }, + "value-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/value-equal/-/value-equal-1.0.1.tgz", + "integrity": "sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==" + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", diff --git a/package.json b/package.json index 00ffba82a6..fa702481d9 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,9 @@ "stylelint-config-wordpress": "^17.0.0" }, "dependencies": { + "@woocommerce/data": "^1.1.1", + "@woocommerce/date": "^2.1.0", + "@woocommerce/navigation": "^5.2.0", "@woocommerce/tracks": "^1.0.0", "@wordpress/components": "^11.1.1", "@wordpress/icons": "^2.8.0"