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

A4A: add forms for new signup flow #99186

Merged
merged 5 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion client/a8c-for-agencies/sections/signup/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { isEnabled } from '@automattic/calypso-config';
import page from '@automattic/calypso-router';
import { makeLayout, render as clientRender } from 'calypso/controller';
import * as controller from './controller';

export default function () {
page( '/signup', controller.signUpContext, makeLayout, clientRender );
page( '/signup/finish', controller.finishSignUpContext, makeLayout, clientRender );
page( '/signup/wc-asia', controller.wcAsiaSignupContext, makeLayout, clientRender );
if ( isEnabled( 'a4a-wc-asia-signup-enabled' ) ) {
page( '/signup/wc-asia', controller.wcAsiaSignupContext, makeLayout, clientRender );
}
page( '/signup/oauth/token', controller.tokenRedirect, makeLayout, clientRender );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
import { Button } from '@wordpress/components';
import { useTranslate } from 'i18n-calypso';
import { useState } from 'react';
import Form from 'calypso/a8c-for-agencies/components/form';
import FormField from 'calypso/a8c-for-agencies/components/form/field';
import FormRadio from 'calypso/components/forms/form-radio';
import FormTextarea from 'calypso/components/forms/form-textarea';
import { preventWidows } from 'calypso/lib/formatting';

type Props = {
onContinue: () => void;
};

type FormData = {
topGoal: string;
mainGoal2025: string;
workModel: string;
specificApproach: string;
};

const BlueprintForm: React.FC< Props > = ( { onContinue } ) => {
const translate = useTranslate();
const [ formData, setFormData ] = useState< FormData >( {
topGoal: '',
mainGoal2025: '',
workModel: '',
specificApproach: '',
} );

const handleSubmit = ( e: React.FormEvent ) => {
e.preventDefault();
onContinue();
};

return (
<Form
className="blueprint-form"
title={ preventWidows( translate( "Let's build your blurprint" ) ) }
description={ translate(
"We'll send you a custom blueprint to grow your business based on your answers below."
) }
>
<div className="blueprint-form__fields">
<FormField
label={ translate( 'What is your top goal when partnering with a technology provider?' ) }
isRequired
>
<div className="blueprint-form__radio-group">
<FormRadio
label={ translate( 'Access to cutting-edge technology' ) }
checked={ formData.topGoal === 'cutting_edge_tech' }
onChange={ () => setFormData( { ...formData, topGoal: 'cutting_edge_tech' } ) }
/>
Comment on lines +49 to +53
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add htmlFor and id to all the fields to make the text clickable to check/uncheck the radio.

Suggested change
<FormRadio
label={ translate( 'Access to cutting-edge technology' ) }
checked={ formData.topGoal === 'cutting_edge_tech' }
onChange={ () => setFormData( { ...formData, topGoal: 'cutting_edge_tech' } ) }
/>
<FormRadio
htmlFor="cutting_edge_tech"
id="cutting_edge_tech"
label={ translate( 'Access to cutting-edge technology' ) }
checked={ formData.topGoal === 'cutting_edge_tech' }
onChange={ () => setFormData( { ...formData, topGoal: 'cutting_edge_tech' } ) }
/>

<FormRadio
label={ translate( 'Comprehensive support and troubleshooting' ) }
checked={ formData.topGoal === 'comprehensive_support' }
onChange={ () => setFormData( { ...formData, topGoal: 'comprehensive_support' } ) }
/>
<FormRadio
label={ translate( 'Lead generation and new business opportunities' ) }
checked={ formData.topGoal === 'lead_generation' }
onChange={ () => setFormData( { ...formData, topGoal: 'lead_generation' } ) }
/>
<FormRadio
label={ translate( 'Training and education for your team' ) }
checked={ formData.topGoal === 'training_education' }
onChange={ () => setFormData( { ...formData, topGoal: 'training_education' } ) }
/>
<FormRadio
label={ translate( 'Exclusive discounts or revenue-sharing options' ) }
checked={ formData.topGoal === 'exclusive_discounts' }
onChange={ () => setFormData( { ...formData, topGoal: 'exclusive_discounts' } ) }
/>
Comment on lines +49 to +73
Copy link
Contributor

Choose a reason for hiding this comment

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

[Non-blocker] Maybe we could thinking of creating an array with all the radio fields and map through it and render instead of repeating it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, think it's great idea. This is just a quickly bootstrapped version so I could start testing out the backend endpoints. I think we could address these in specific tasks for each page

</div>
</FormField>

<FormField
label={ translate( 'What is the main goal you hope to achieve in 2025?' ) }
isRequired
>
<div className="blueprint-form__radio-group">
<FormRadio
label={ translate( 'Scaling the agency significantly' ) }
checked={ formData.mainGoal2025 === 'scaling_agency' }
onChange={ () => setFormData( { ...formData, mainGoal2025: 'scaling_agency' } ) }
/>
<FormRadio
label={ translate( 'Diversifying offered services' ) }
checked={ formData.mainGoal2025 === 'diversifying_services' }
onChange={ () =>
setFormData( { ...formData, mainGoal2025: 'diversifying_services' } )
}
/>
<FormRadio
label={ translate( 'Increasing the number of long-term clients' ) }
checked={ formData.mainGoal2025 === 'increasing_clients' }
onChange={ () => setFormData( { ...formData, mainGoal2025: 'increasing_clients' } ) }
/>
<FormRadio
label={ translate( 'Expanding into new markets or territories' ) }
checked={ formData.mainGoal2025 === 'expanding_markets' }
onChange={ () => setFormData( { ...formData, mainGoal2025: 'expanding_markets' } ) }
/>
<FormRadio
label={ translate( "Strengthening the agency's brand and reputation" ) }
checked={ formData.mainGoal2025 === 'strengthening_brand' }
onChange={ () => setFormData( { ...formData, mainGoal2025: 'strengthening_brand' } ) }
/>
</div>
</FormField>

<FormField
label={ translate(
"How does your agency typically work with clients regarding Automattic's solutions?"
) }
isRequired
>
<div className="blueprint-form__radio-group">
<FormRadio
label={ translate(
'We refer customers to Automattic products/services to purchase on their own'
) }
checked={ formData.workModel === 'refer_customers' }
onChange={ () => setFormData( { ...formData, workModel: 'refer_customers' } ) }
/>
<FormRadio
label={ translate(
"We purchase on our clients' behalf and resell Automattic products/services"
) }
checked={ formData.workModel === 'purchase_resell' }
onChange={ () => setFormData( { ...formData, workModel: 'purchase_resell' } ) }
/>
<FormRadio
label={ translate( 'A combination of referring and reselling' ) }
checked={ formData.workModel === 'combination' }
onChange={ () => setFormData( { ...formData, workModel: 'combination' } ) }
/>
<FormRadio
label={ translate( 'Other models (please explain)' ) }
checked={ formData.workModel === 'other' }
onChange={ () => setFormData( { ...formData, workModel: 'other' } ) }
/>
{ formData.workModel === 'other' && (
<FormTextarea
value={ formData.specificApproach }
onChange={ () => {
// TODO: form data
return;
} }
placeholder={ translate( 'Add your explanation' ) }
/>
) }
</div>
</FormField>

<FormField
label={ translate(
`Is there anything specific about your agency's approach or any challenges you face that you would like us to consider when creating your blueprint?`
) }
>
<FormTextarea
value={ formData.specificApproach }
onChange={ ( e: React.ChangeEvent< HTMLTextAreaElement > ) =>
setFormData( { ...formData, specificApproach: e.target.value } )
}
placeholder={ translate( 'Add your approach' ) }
/>
</FormField>

<div className="blueprint-form__controls">
<Button variant="primary" onClick={ handleSubmit } className="blueprint-form__submit">
{ translate( 'Continue' ) }
</Button>
</div>
</div>
</Form>
);
};

export default BlueprintForm;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Button } from '@wordpress/components';
import { useTranslate } from 'i18n-calypso';
import Form from 'calypso/a8c-for-agencies/components/form';
import { preventWidows } from 'calypso/lib/formatting';

import './style.scss';

type Props = {
onContinue: () => void;
onSkip: () => void;
};

const ChoiceBlueprint: React.FC< Props > = ( { onContinue, onSkip } ) => {
const translate = useTranslate();

return (
<Form
className="choice-blueprint-form"
title={ preventWidows(
translate( 'Grow your business with a free personalized blueprint' )
) }
description={ translate(
`By answering a few simple questions, we'll provide tips on maximizing your agency's impact.`
) }
>
<p className="choice-blueprint__text">{ translate( 'Ready?' ) }</p>

<div className="choice-blueprint__buttons">
<Button className="choice-blueprint__button" variant="primary" onClick={ onContinue }>
{ translate( 'Yes' ) }
</Button>
<Button className="choice-blueprint__button" variant="secondary" onClick={ onSkip }>
{ translate( 'Not right now' ) }
</Button>
</div>
</Form>
);
};

export default ChoiceBlueprint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.choice-blueprint__text {
font-size: 1rem;
font-weight: 400;
Comment on lines +2 to +3
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use A4A Typography here? This will make it easy for us to migrate to Core Typography.

color: var(--color-neutral-60);
max-width: 460px;
}

.choice-blueprint__buttons {
display: flex;
gap: 24px;

.components-button {
width: 180px;
justify-content: center;
}
}
Loading