Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
feat: remove unnecessary hook and update enable analytics label
Browse files Browse the repository at this point in the history
  • Loading branch information
ReidyT committed Apr 11, 2024
1 parent 0cf9f1a commit 72db00a
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 40 deletions.
4 changes: 0 additions & 4 deletions cypress/e2e/SignUp.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('SignUp', () => {
describe('Must Accept All Terms To Sign Up', () => {
beforeEach(() => {
cy.visit(SIGN_UP_PATH);
// eslint-disable-next-line arrow-body-style
cy.intercept({ method: 'post', pathname: '/register' }, ({ reply }) => {
return reply({
statusCode: StatusCodes.NO_CONTENT,
Expand All @@ -36,8 +35,6 @@ describe('SignUp', () => {
it('Sign Up', () => {
const { GRAASP, WRONG_NAME, WRONG_EMAIL } = MEMBERS;
cy.visit(SIGN_UP_PATH);

// eslint-disable-next-line arrow-body-style
cy.intercept({ method: 'post', pathname: '/register' }, ({ reply }) => {
return reply({
statusCode: StatusCodes.NO_CONTENT,
Expand Down Expand Up @@ -108,7 +105,6 @@ describe('SignUp', () => {

beforeEach(() => {
cy.visit(SIGN_UP_PATH);
// eslint-disable-next-line arrow-body-style
cy.intercept({ method: 'post', pathname: '/register' }, ({ reply }) => {
return reply({
statusCode: StatusCodes.NO_CONTENT,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"@emotion/cache": "11.11.0",
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.0",
"@graasp/query-client": "github:graasp/graasp-query-client#717-add-enable-save-actions-on-member-sign-up-and-update",
"@graasp/sdk": "github:graasp/graasp-sdk#467-includes-save-actions-and-user-agreements-in-complete-member",
"@graasp/query-client": "3.4.0",
"@graasp/sdk": "4.7.0",
"@graasp/translations": "1.25.3",
"@graasp/ui": "4.11.0",
"@mui/icons-material": "5.15.14",
Expand Down
3 changes: 2 additions & 1 deletion src/components/AgreementForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Typography,
} from '@mui/material';

import { MAX_CHECKBOX_LABEL_WITH_PX_SIGN_UP } from '../config/constants';
import { useAuthTranslation } from '../config/i18n';
import { SIGN_UP_AGREEMENTS_CHECKBOX_ID } from '../config/selectors';
import { UseAgreementForm } from '../hooks/useAgreementForm';
Expand All @@ -29,7 +30,7 @@ export const AgreementForm = ({ useAgreementForm }: Props) => {
const errorColor = 'error';

return (
<FormGroup sx={{ maxWidth: '330px' }}>
<FormGroup sx={{ maxWidth: `${MAX_CHECKBOX_LABEL_WITH_PX_SIGN_UP}px` }}>
<FormControlLabel
checked={userHasAcceptedAllTerms}
onChange={(_, checked) => updateUserAgreements(checked)}
Expand Down
15 changes: 9 additions & 6 deletions src/components/EnableAnalyticsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,33 @@ import {
Typography,
} from '@mui/material';

import { MAX_CHECKBOX_LABEL_WITH_PX_SIGN_UP } from '../config/constants';
import { useAuthTranslation } from '../config/i18n';
import { SIGN_UP_SAVE_ACTIONS_ID } from '../config/selectors';
import { UseEnableAnalyticsForm } from '../hooks/useEnableAnalyticsForm';
import { AUTH } from '../langs/constants';

type Props = {
useEnableAnalyticsForm: UseEnableAnalyticsForm;
enableSaveActions: boolean;
onUpdateSaveActions: (enabled: boolean) => void;
};

export const EnableAnalyticsForm = ({ useEnableAnalyticsForm }: Props) => {
export const EnableAnalyticsForm = ({
enableSaveActions,
onUpdateSaveActions,
}: Props) => {
const { SIGN_UP_SAVE_ACTIONS_TOOLTIP, SIGN_UP_SAVE_ACTIONS_LABEL } = AUTH;
const { t } = useAuthTranslation();
const { enableSaveActions, updateSaveActions } = useEnableAnalyticsForm;

return (
<Tooltip title={t(SIGN_UP_SAVE_ACTIONS_TOOLTIP)} placement="right">
<FormGroup sx={{ maxWidth: 'max-content' }}>
<FormGroup sx={{ maxWidth: `${MAX_CHECKBOX_LABEL_WITH_PX_SIGN_UP}px` }}>
<FormControlLabel
control={
<Checkbox
id={SIGN_UP_SAVE_ACTIONS_ID}
size="small"
checked={enableSaveActions}
onChange={(_, checked) => updateSaveActions(checked)}
onChange={(_, checked) => onUpdateSaveActions(checked)}
/>
}
label={
Expand Down
8 changes: 3 additions & 5 deletions src/components/SignUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { useRecaptcha } from '../context/RecaptchaContext';
import { useMobileAppLogin } from '../hooks/mobile';
import { useRedirection } from '../hooks/searchParams';
import { useAgreementForm } from '../hooks/useAgreementForm';
import { useEnableAnalyticsForm } from '../hooks/useEnableAnalyticsForm';
import { AUTH } from '../langs/constants';
import { emailValidator, nameValidator } from '../utils/validation';
import { AgreementForm } from './AgreementForm';
Expand All @@ -48,9 +47,7 @@ const SignUp = () => {
const [successView, setSuccessView] = useState(false);
// enable validation after first click
const [shouldValidate, setShouldValidate] = useState(false);

const enableAnalyticsFormHook = useEnableAnalyticsForm();
const { enableSaveActions } = enableAnalyticsFormHook;
const [enableSaveActions, setEnableSaveActions] = useState<boolean>(true);

const agreementFormHook = useAgreementForm();
const { verifyUserAgreements, userHasAcceptedAllTerms } = agreementFormHook;
Expand Down Expand Up @@ -151,7 +148,8 @@ const SignUp = () => {
shouldValidate={shouldValidate}
/>
<EnableAnalyticsForm
useEnableAnalyticsForm={enableAnalyticsFormHook}
enableSaveActions={enableSaveActions}
onUpdateSaveActions={(enabled) => setEnableSaveActions(enabled)}
/>
<AgreementForm useAgreementForm={agreementFormHook} />
<Button
Expand Down
2 changes: 2 additions & 0 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export const AVATAR_ICON_HEIGHT = 30;

export const MEMBER_PROFILE_PATH = `${GRAASP_BUILDER_HOST}/profile`;
export const SIGN_IN_PATH = buildSignInPath({ host: AUTHENTICATION_HOST });

export const MAX_CHECKBOX_LABEL_WITH_PX_SIGN_UP = 330;
19 changes: 0 additions & 19 deletions src/hooks/useEnableAnalyticsForm.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/langs/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"SIGN_UP_BUTTON": "Sign Up",
"SIGN_UP_HEADER": "Sign Up",
"SIGN_UP_LINK_TEXT": "Not registered? Click here to register",
"SIGN_UP_SAVE_ACTIONS_LABEL": "Enable Analytics",
"SIGN_UP_SAVE_ACTIONS_TOOLTIP": "We collect analytics data to improve your user experience while browsing Graasp.",
"SIGN_UP_SAVE_ACTIONS_LABEL": "Activate data-driven insights saving for enhanced analytics dashboards",
"SIGN_UP_SAVE_ACTIONS_TOOLTIP": "We collect analytic data to improve your user experience while browsing Graasp.",
"SIGN_UP_SUCCESS_TITLE": "Welcome!",
"SWITCH_ACCOUNT_TEXT": "Switch to another account",
"API_UNAVAILABLE_TITLE": "Server Connection Error",
Expand Down
2 changes: 1 addition & 1 deletion src/langs/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"SIGN_UP_HEADER": "S'enregistrer",
"SIGN_UP_LINK_TEXT": "Pas encore enregistré ? Cliquez ici pour vous enregistrer",
"SIGN_UP_SAVE_ACTIONS_LABEL": "Activer les statistiques d'utilisation",
"SIGN_UP_SAVE_ACTIONS_TOOLTIP": "Nous recueillons des données analytiques afin d'améliorer votre expérience d'utilisateur lorsque vous naviguez sur Graasp.",
"SIGN_UP_SAVE_ACTIONS_TOOLTIP": "Nous recueillons des données analytiques afin d'améliorer votre expérience utilisateur lorsque vous naviguez sur Graasp.",
"SIGN_UP_SUCCESS_TITLE": "Bienvenue !",
"SWITCH_ACCOUNT_TEXT": "Utiliser un autre compte",
"USER_AGREEMENTS_TERMS_OF_SERVICE": "conditions d'utilisation",
Expand Down

0 comments on commit 72db00a

Please sign in to comment.