Skip to content

Commit

Permalink
fix: improve form (#120)
Browse files Browse the repository at this point in the history
* Make checkboxes false by default

* Add privacy policy
  • Loading branch information
zivkovicmilos authored Sep 24, 2023
1 parent bca4d58 commit 1ac88b3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
8 changes: 4 additions & 4 deletions signup/functions/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { CONFIG } from './config';
import { SubscribeRequest } from './types';
import subscribeUserSchema from './schemas/users.schema';
import { RedisClient } from './services/redis';
import RequestHelper from './helpers/requests.helper';
import getRandomToken from './helpers/token.helper';

const ajv = new Ajv();
Expand All @@ -34,7 +33,7 @@ export async function handler(event: HandlerEvent): Handler {
if (!isValid) {
return {
statusCode: 400,
body: JSON.stringify({ errors: ajv.errors })
body: JSON.stringify({ errors: 'Bad request' })
};
}

Expand Down Expand Up @@ -63,7 +62,6 @@ export async function handler(event: HandlerEvent): Handler {
MMERGE9: subscribeRequest.receiveNews ? 'Yes' : 'No',
MMERGE10: subscribeRequest.termsAndConditions ? 'Yes' : 'No'
}
// TODO add tags
});

await redisClient.storeUserToken(subscribeRequest.email, token);
Expand All @@ -81,6 +79,7 @@ export async function handler(event: HandlerEvent): Handler {
if (journeyResponse != null) {
throw new Error(journeyResponse);
}

// Success return
return {
statusCode: 200,
Expand All @@ -91,9 +90,10 @@ export async function handler(event: HandlerEvent): Handler {
req: event.body,
message: err
});

return {
statusCode: 500,
body: JSON.stringify({ errors: { message: 'Unabled to subsribe user' } })
body: JSON.stringify({ errors: { message: 'Unable to subscribe user' } })
};
}
}
11 changes: 11 additions & 0 deletions signup/functions/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface SubscribeRequest {
firstName: string;
lastName: string;
email: string;
githubHandle: string;
socialHandle: string;
interests: string;
receiveNews: boolean;
participate: boolean;
termsAndConditions: boolean;
}
22 changes: 16 additions & 6 deletions signup/src/components/pages/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const Home: FC<IHomeProps> = () => {
githubHandle: '',
socialHandle: '',
interests: 'General Gno.land',
receiveNews: true,
participate: true,
receiveNews: false,
participate: false,
termsAndConditions: false
},
enableReinitialize: true,
Expand Down Expand Up @@ -283,13 +283,23 @@ const Home: FC<IHomeProps> = () => {
>
Please confirm you accept the{' '}
<a
href={'https://hackmd.io'}
href={'https://gnochess.com/docs/gnochess-terms-and-conditions-9-21-23.pdf'}
target={'_blank'}
style={{
textDecoration: 'underline'
}}
>
Terms and Conditions{' '}
Terms and Conditions
</a>
{' '}and the{' '}
<a
href={'https://gnochess.com/docs/gnochess-privacy-policy-9-21-23.pdf'}
target={'_blank'}
style={{
textDecoration: 'underline'
}}
>
Privacy Policy
</a>
</Checkbox>
<FormHelperText>
Expand All @@ -303,11 +313,11 @@ const Home: FC<IHomeProps> = () => {
<Box>
<Button
rightIcon={<BsSend />}
variant="outline"
variant='outline'
padding={6}
isLoading={submitting}
loadingText={'Submitting'}
spinner={<Spinner size={'md'} color="green" />}
spinner={<Spinner size={'md'} color='green' />}
spinnerPlacement={'end'}
type={'submit'}
>
Expand Down

0 comments on commit 1ac88b3

Please sign in to comment.