-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/1610-streamlined-onboarding
- Loading branch information
Showing
29 changed files
with
1,225 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
Button, | ||
CheckboxControl, | ||
Panel, | ||
PanelBody, | ||
PanelRow, | ||
} from '@wordpress/components'; | ||
import { recordEvent } from '@woocommerce/tracks'; | ||
import { useRef } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './index.scss'; | ||
|
||
const getPanelToggleHandler = ( id ) => ( isOpened ) => { | ||
recordEvent( 'pre-launch-checklist', { | ||
id, | ||
action: isOpened ? 'expand' : 'collapse', | ||
} ); | ||
}; | ||
|
||
export default function PreLaunchCheckItem( { | ||
formProps, | ||
fieldName, | ||
firstPersonTitle, | ||
secondPersonTitle, | ||
children, | ||
} ) { | ||
const { getInputProps, setValue, values } = formProps; | ||
const checked = values[ fieldName ]; | ||
const initialCheckedRef = useRef( checked ); | ||
|
||
if ( checked ) { | ||
return ( | ||
<CheckboxControl | ||
label={ | ||
initialCheckedRef.current | ||
? firstPersonTitle | ||
: secondPersonTitle | ||
} | ||
{ ...getInputProps( fieldName ) } | ||
disabled | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="gla-pre-launch-checklist__checkbox"> | ||
<CheckboxControl { ...getInputProps( fieldName ) } /> | ||
<Panel> | ||
<PanelBody | ||
title={ secondPersonTitle } | ||
initialOpen={ false } | ||
onToggle={ getPanelToggleHandler( fieldName ) } | ||
> | ||
<PanelRow> | ||
{ children } | ||
<Button | ||
isPrimary | ||
onClick={ () => setValue( fieldName, true ) } | ||
> | ||
{ __( 'Confirm', 'google-listings-and-ads' ) } | ||
</Button> | ||
</PanelRow> | ||
</PanelBody> | ||
</Panel> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.gla-pre-launch-checklist { | ||
.components-panel { | ||
flex: 1 1; | ||
|
||
&__row { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
gap: 1em; | ||
} | ||
|
||
.components-panel__body-title { | ||
.components-panel__body-toggle.components-button { | ||
color: #007cba; | ||
} | ||
} | ||
} | ||
.gla-pre-launch-checklist__checkbox { | ||
display: flex; | ||
justify-content: stretch; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import useAppSelectDispatch from './useAppSelectDispatch'; | ||
|
||
/** | ||
* Get policy detail info from calling `useAppSelectDispatch` with `getPolicyCheck`. | ||
* Returns `{ hasFinishedResolution, data, invalidateResolution }`. | ||
* | ||
* `data` is an object of policy check mapping. e.g.: | ||
* | ||
* ```json | ||
* { | ||
* "allowed_countries": true, | ||
* "robots_restriction": false, | ||
* "page_not_found_error": false, | ||
* "page_redirects": false, | ||
* "store_ssl": true, | ||
* "payment_gateways": true, | ||
* "refund_returns": true | ||
* } | ||
* ``` | ||
*/ | ||
const usePolicyCheck = () => { | ||
return useAppSelectDispatch( 'getPolicyCheck' ); | ||
}; | ||
|
||
export default usePolicyCheck; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.