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 20 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
41 changes: 41 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,36 @@ 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 array(
'businessName' => array(
'question' => "1. Do you have a business name or website title?",
'prompt' => "My business name is",
),
'websiteType' => array(
"question" => "2. What type of website are you making?",
"placeholder" => "e.g. Graphic design portfolio",
"prompt" => "I am making a website type of",
),
'writeStyle' => array(
"question" => "3. Which writing style do you like better?",
"placeholder" => "e.g. Graphic design portfolio",
"prompt" => "I like the writing style",
),
'uniqueBusiness' => array(
"question" => "4. Is there anything unique about your business or brand?",
"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 ButtonSiteGenPrompt = ( { className, value, text, onClick } ) => {
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 ButtonSiteGenPrompt;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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>
<div className="nfd-sg-simple-input">
{ 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 );
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


.nfd-sg-simple-input {
margin-top: 20px;

}
13 changes: 13 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,19 @@ 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'
),
walkThroughlink: __( 'click here', '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
89 changes: 67 additions & 22 deletions src/OnboardingSPA/steps/SiteGen/SiteDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
import TextInputSiteGen from '../../../components/TextInput/TextInputSiteGen';
import NextButtonSiteGen from '../../../components/Button/NextButtonSiteGen';

import SiteGenSiteDetailsWalkthrough from '../SiteDetails/walkthrough';
import { getSiteDetailsQuestionare } from '../../../utils/api/siteGen';

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

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

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

Check warning on line 49 in src/OnboardingSPA/steps/SiteGen/SiteDetails/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'currentData.sitegen.siteDetails.prompt', 'setDrawerActiveView', 'setFooterNavEnabled', 'setHeaderActiveView', 'setIsHeaderEnabled', and 'setSidebarActiveView'. Either include them or remove the dependency array

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

Check warning on line 56 in src/OnboardingSPA/steps/SiteGen/SiteDetails/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'currentData', 'setCurrentOnboardingData', and 'setFooterNavEnabled'. Either include them or remove the dependency array

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

useEffect( () => {
getSiteDetails();
}, [] );

async function getSiteDetails() {
try {
let siteDetailsmetas = await getSiteDetailsQuestionare();
siteDetailsmetas = siteDetailsmetas.body;
setSiteDetailsmeta( siteDetailsmetas );
} catch ( err ) {
// eslint-disable-next-line no-console
console.error( 'Error fetching data:', err );
}
}

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 }
{ isWalkthrough ? (
<SiteGenSiteDetailsWalkthrough
siteDetailsmeta={ siteDetailsmeta }
/>
{ isLargeViewport && (
<div className={ 'nfd-sg-site-details-endrow' }>
<NextButtonSiteGen
className={ 'nfd-sg-site-details--next-btn' }
text={ content.buttonText }
disabled={
customerInput === undefined ||
customerInput === ''
}
/>
) : (
<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"
>
{ content.walkThroughlink }
</span>
</div>
) }
</div>
</div>
) }
</Animate>
</CommonLayout>
);
Expand Down
Loading