Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding simple customer promt screen #382

Merged
merged 31 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c27cfdc
initial commit
girish-lokapure Nov 30, 2023
89b0a61
ui changes
girish-lokapure Nov 30, 2023
64359df
Merge branch 'enhance/ai-onboarding' of github.com:newfold-labs/wp-mo…
girish-lokapure Nov 30, 2023
230ee7e
layout changes
girish-lokapure Dec 4, 2023
e59c86f
storing data in store and db
girish-lokapure Dec 5, 2023
f4f7bcc
code cleanup
girish-lokapure Dec 5, 2023
fc638dc
lint fixes
girish-lokapure Dec 5, 2023
04981f8
merged ai-onboarding
girish-lokapure Dec 6, 2023
616fe15
fixed lint issues
girish-lokapure Dec 6, 2023
2a33861
PRESS2-1913 | replaced filename casing
Dec 7, 2023
e5340c1
questionnaire from api
girish-lokapure Dec 12, 2023
bf45801
lint fixes
girish-lokapure Dec 12, 2023
a4fc45c
resetting build
girish-lokapure Dec 13, 2023
bd6a2cc
resetting build
girish-lokapure Dec 13, 2023
dbfc279
resetting build
girish-lokapure Dec 13, 2023
fc18656
PR changes
girish-lokapure Dec 18, 2023
1364820
lint fixes
girish-lokapure Dec 18, 2023
e77db69
Merge branch 'enhance/ai-onboarding' of github.com:newfold-labs/wp-mo…
girish-lokapure Dec 18, 2023
288e2a3
Update stylesheet.scss
girish-lokapure Dec 18, 2023
1780d4f
Update stylesheet.scss
girish-lokapure Dec 18, 2023
80b1ae3
New screen changes
girish-lokapure Dec 21, 2023
cfecccc
Update stylesheet.scss
girish-lokapure Dec 21, 2023
c170c26
Update stylesheet.scss
girish-lokapure Dec 27, 2023
0f0a804
Merge branch 'enhance/ai-onboarding' of https://github.com/newfold-la…
arunshenoy99 Jan 9, 2024
fc44851
Merge branch 'enhance/ai-onboarding' of https://github.com/newfold-la…
arunshenoy99 Jan 9, 2024
59c579d
PR changes
girish-lokapure Jan 9, 2024
a3b4d5b
Merge branch 'add/sitedetails/simple' of github.com:newfold-labs/wp-m…
girish-lokapure Jan 9, 2024
5fa6c96
Merge branch 'enhance/ai-onboarding' of github.com:newfold-labs/wp-mo…
girish-lokapure Jan 10, 2024
147a026
lint fixes
girish-lokapure Jan 10, 2024
d3044f5
Update stylesheet.scss
girish-lokapure Jan 10, 2024
863cabb
Merge branch 'enhance/ai-onboarding' of github.com:newfold-labs/wp-mo…
girish-lokapure Jan 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions includes/RestApi/SiteGenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ public function register_routes() {
'args' => $this->sitegen_meta_args(),
)
);
\register_rest_route(
$this->namespace,
$this->rest_base . '/get-site-details-meta',
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
array(
'methods' => \WP_REST_Server::READABLE,
'callback' => array( $this, 'get_site_details_meta' ),
'permission_callback' => array( Permissions::class, 'rest_is_authorized_admin' ),
)
);
}

/**
Expand Down Expand Up @@ -106,4 +115,42 @@ public function generate_sitegen_meta( \WP_REST_Request $request ) {
array( 'status' => 404 )
);
}

/**
* Generate Sitegen Site Details meta data.
*
* @param \WP_REST_Request $request Request model.
*
* @return array|WP_Error
*/
public function get_site_details_meta( \WP_REST_Request $request ) {

return json_encode(
[
[
"question" => "1. Do you have a business name or website title?",
"field" => "businessName",
"prompt" => "My business name is ",
],
[
"question" => "2. What type of website are you making?",
"field" => "websiteType",
"placeholder" => "e.g. Graphic design portfolio",
"prompt" => "I am making a website type of ",
],
[
"question" => "3. Which writing style do you like better?",
"field" => "writeStyle",
"placeholder" => "e.g. Graphic design portfolio",
"prompt" => "I like the wirting style ",
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
],
[
"question" => "4. Is there anything unique about your business or brand?",
"field" => "uniqueBusiness",
"placeholder" => "e.g. Unique product, amazing customer service, customizations, etc.",
"prompt" => "Unique about my business is ",
],
]
);
}
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
}
16 changes: 16 additions & 0 deletions src/OnboardingSPA/components/Button/ButtonWhite/SiteGen/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Button } from '@wordpress/components';
import classNames from 'classnames';

const ButtonSiteGen = ( { className, value, text, onClick } ) => {
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
return (
<Button
className={ classNames( className ) }
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
value={ value }
onClick={ typeof onClick === 'function' && onClick }
>
{ text }
</Button>
);
};

export default ButtonSiteGen;
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { useRef, memo } from '@wordpress/element';

const TextInputSiteGenSimple = ( {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it good practice to split this into two components, TextInputSiteGen and TextAreaSiteGen? The component naming structure we follow is components//index.js. Can we eliminate the use of terms such as 'simple,' 'complex,' etc.? Any component directory name should be pascal cased

type,
labelText,
placeholder,
customerInput,
callback = null,
} ) => {
const textareaRef = useRef( null );

return (
<div>
<label htmlFor={ labelText }>{ labelText }</label>
<br></br>
<br></br>
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
<div>
{ type === 'textarea' ? (
<textarea
type="text"
ref={ textareaRef }
placeholder={ placeholder }
value={ customerInput }
onChange={ ( e ) => {
if ( callback && typeof callback === 'function' ) {
callback( e );
}
} }
/>
) : (
<input
type="text"
placeholder={ placeholder }
value={ customerInput }
onChange={ ( e ) => {
if ( callback && typeof callback === 'function' ) {
callback( e );
}
} }
/>
) }
</div>
</div>
);
};

export default memo( TextInputSiteGenSimple );
12 changes: 12 additions & 0 deletions src/OnboardingSPA/steps/SiteGen/SiteDetails/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ const getContents = () => {
),
inputHint: __( 'The more detail the better', 'wp-module-onboarding' ),
buttonText: __( 'Next', 'wp-module-onboarding' ),
walkThroughText: __(
'Not sure what to say? We can walk you through it.',
'wp-module-onboarding'
),
writeStyleOption1: __(
'We craft awesome goodies!',
'wp-module-onboarding'
),
writeStyleOption2: __(
'We manufacture quality products',
'wp-module-onboarding'
),
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
};
};

Expand Down
92 changes: 68 additions & 24 deletions src/OnboardingSPA/steps/SiteGen/SiteDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import CommonLayout from '../../../components/Layouts/Common';
import TextInputSiteGen from '../../../components/TextInput/TextInputSiteGen';
import NextButtonSiteGen from '../../../components/Button/NextButtonSiteGen';

import SiteGenSiteDetailsWalkthrough from '../SiteDetails/walkthrough';

const SiteGenSiteDetails = () => {
const content = getContents();
const isLargeViewport = useViewportMatch( 'small' );
const [ customerInput, setCustomerInput ] = useState();

const [ isWalkthrough, setIsWalkthrough ] = useState( false );
const { currentData } = useSelect( ( select ) => {
return {
currentData:
Expand All @@ -39,42 +41,84 @@ const SiteGenSiteDetails = () => {
setDrawerActiveView( false );

if ( currentData.sitegen.siteDetails?.prompt !== '' ) {
return setCustomerInput( currentData.sitegen.siteDetails.prompt );
setCustomerInput( currentData.sitegen.siteDetails.prompt );
}
setFooterNavEnabled( false );
}, [] );

useEffect( () => {
setFooterNavEnabled( customerInput !== '' );
currentData.sitegen.siteDetails.prompt = customerInput;
currentData.sitegen.siteDetails.mode = 'simple';
setCurrentOnboardingData( currentData );
}, [ customerInput ] );

const handleClickWalkThrough = () => {
setIsWalkthrough( true );
};

return (
<CommonLayout isCentered>
<Animate type={ 'fade-in' }>
<div className={ 'nfd-sg-site-details' }>
<AIHeading title={ content.heading } />
<TextInputSiteGen
placeholder={ content.inputPlaceholder }
hint={ content.inputHint }
height={ '40px' }
customerInput={ customerInput }
setCustomerInput={ setCustomerInput }
/>
{ isLargeViewport && (
<div className={ 'nfd-sg-site-details-endrow' }>
<NextButtonSiteGen
className={ 'nfd-sg-site-details--next-btn' }
text={ content.buttonText }
disabled={
customerInput === undefined ||
customerInput === ''
}
/>
</div>
) }
</div>
{ isWalkthrough ? (
<SiteGenSiteDetailsWalkthrough />
) : (
<div className={ 'nfd-sg-site-details' }>
<AIHeading title={ content.heading } />
<TextInputSiteGen
placeholder={ content.inputPlaceholder }
hint={ content.inputHint }
height={ '40px' }
customerInput={ customerInput }
setCustomerInput={ setCustomerInput }
/>
{ isLargeViewport ? (
<>
<div className={ 'nfd-sg-site-details-endrow' }>
<NextButtonSiteGen
className={
'nfd-sg-site-details--next-btn'
}
text={ content.buttonText }
disabled={
customerInput === undefined ||
customerInput === ''
}
/>
</div>
<div
className={
'nfd-sg-site-details-walkThrough'
}
>
{ content.walkThroughText }
<span
onClick={ handleClickWalkThrough }
onKeyDown={ handleClickWalkThrough }
role="button"
tabIndex="0"
>
click here
</span>
</div>
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
</>
) : (
<div
className={ 'nfd-sg-site-details-walkThrough' }
>
{ content.walkThroughText }
<span
onClick={ handleClickWalkThrough }
onKeyDown={ handleClickWalkThrough }
role="button"
tabIndex="0"
>
click here
</span>
girish-lokapure marked this conversation as resolved.
Show resolved Hide resolved
</div>
) }
</div>
) }
</Animate>
</CommonLayout>
);
Expand Down
Loading