Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/github_actions/actions/setup-n…
Browse files Browse the repository at this point in the history
…ode-4
  • Loading branch information
kyleecodes committed Jul 9, 2024
2 parents dff2d77 + e68c1fb commit 6edf37c
Show file tree
Hide file tree
Showing 47 changed files with 991 additions and 184 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cypress-release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Cypress release tests

on:
push:
branches: [develop, fix-auth-tests, dependabot/**]
branches: [develop, dependabot/**]

jobs:
# vercel will redeploy the develop/staging app on creating a PR to main
Expand Down Expand Up @@ -48,6 +48,7 @@ jobs:
parallel: true
env:
NEXT_PUBLIC_ROLLBAR_ENV: CI
NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA: ci
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN: ${{ secrets.NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN }}
NEXT_PUBLIC_STORYBLOK_TOKEN: ${{ secrets.NEXT_PUBLIC_STORYBLOK_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cypress-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
run: yarn build
env:
NEXT_PUBLIC_ROLLBAR_ENV: CI
NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA: ci
NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}
NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN: ${{ secrets.NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN }}
NEXT_PUBLIC_STORYBLOK_TOKEN: ${{ secrets.NEXT_PUBLIC_STORYBLOK_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
uses: actions/dependency-review-action@v4
with:
# fails when moderate vulnerabilities are deteched
fail-on-severity: moderate
fail-on-severity: high
4 changes: 2 additions & 2 deletions .github/workflows/newrelic-release-tracking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: echo "COMMIT_REF=${{ github.ref_name }}" >> $GITHUB_ENV
# This step creates a new Change Tracking Marker for the APM entity
- name: New Relic Application Deployment Marker
uses: newrelic/deployment-marker-action@v2.2.0
uses: newrelic/deployment-marker-action@v2.5.0
with:
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
region: 'EU'
Expand All @@ -23,7 +23,7 @@ jobs:
user: '${{ github.actor }}'
# This step creates a new Change Tracking Marker for the Browser entity
- name: New Relic Browser Deployment Marker
uses: newrelic/deployment-marker-action@v2.2.0
uses: newrelic/deployment-marker-action@v2.5.0
with:
apiKey: ${{ secrets.NEW_RELIC_API_KEY }}
region: 'EU'
Expand Down
9 changes: 9 additions & 0 deletions app/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export const api = createApi({
};
},
}),

subscribeToWhatsapp: builder.mutation<Subscription, { subscriptionInfo: string }>({
query(body) {
return {
Expand All @@ -206,6 +207,13 @@ export const api = createApi({
}),
},
),
updatePartnerAdmin: builder.mutation<PartnerAdmin, { id: string; active: boolean }>({
query: ({ id, active }) => ({
url: `partner-admin/${id}`,
method: 'PATCH',
body: { active },
}),
}),
createEventLog: builder.mutation<EventLog, { event: EVENT_LOG_NAME }>({
query(body) {
return {
Expand Down Expand Up @@ -235,5 +243,6 @@ export const {
useSubscribeToWhatsappMutation,
useUnsubscribeFromWhatsappMutation,
useUpdatePartnerAccessMutation,
useUpdatePartnerAdminMutation,
useCreateEventLogMutation,
} = api;
2 changes: 2 additions & 0 deletions app/userSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { EMAIL_REMINDERS_FREQUENCY, LANGUAGES } from '../constants/enums';
import { api, GetUserResponse } from './api';
import { PartnerAccesses } from './partnerAccessSlice';
import { PartnerAdmin } from './partnerAdminSlice';

export interface User {
loading: boolean;
Expand Down Expand Up @@ -42,6 +43,7 @@ export interface GetUserDto {
activeSubscriptions?: ActiveSubscription[];
};
partnerAccesses: PartnerAccesses;
partnerAdmin?: PartnerAdmin;
}

export interface Subscription {
Expand Down
121 changes: 121 additions & 0 deletions components/cards/AccountActionsCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { Box, Button, Card, CardContent, Link, Typography, lighten } from '@mui/material';
import { getAuth, signOut } from 'firebase/auth';
import { useTranslations } from 'next-intl';
import { useRouter } from 'next/router';
import { useState } from 'react';
import { useDeleteUserMutation } from '../../app/api';
import { ErrorDisplay } from '../../constants/common';
import theme from '../../styles/theme';
import ConfirmDialog from '../forms/ConfirmDialog';

const cardStyle = {
width: { xs: '100%', md: 'auto' },
flex: { xs: 'auto', md: 1 },
} as const;

const AccountActionsCard = () => {
const t = useTranslations('Account.accountSettings');
const tS = useTranslations('Shared');
const router = useRouter();
const [deleteUser, { isLoading }] = useDeleteUserMutation();
const [error, setError] = useState<ErrorDisplay>();

const [resetPasswordConfirmationRequired, setResetPasswordConfirmationRequired] =
useState<boolean>(false);
const [deleteAccountConfirmationRequired, setDeleteAccountConfirmationRequired] =
useState<boolean>(false);

const passwordResetConfirmHandler = (confirmed: boolean) => {
if (confirmed) {
router.push('/auth/reset-password');
} else {
setResetPasswordConfirmationRequired(false);
}
};

const deleteAccountConfirmHandler = async (confirmed: boolean) => {
if (confirmed) {
const response = await deleteUser({});

if ((response as any)?.data?.id) {
setError(undefined);
router.push('/').then(() => {
const auth = getAuth();
signOut(auth);
});
} else {
setError(
t.rich('updateError', {
link: (children) => <Link href={tS('feedbackTypeform')}>{children}</Link>,
}),
);
}
setDeleteAccountConfirmationRequired(false);
} else {
setDeleteAccountConfirmationRequired(false);
}
};

return (
<Card sx={cardStyle}>
<CardContent>
<Box sx={{ mb: 2 }}>
<Typography variant="h2" component="h2">
{t('actions.title')}
</Typography>
<Typography>{t('actions.description')}</Typography>
{error && <Typography color="error.main">{error}</Typography>}
</Box>
<Box display={['flex']} flexWrap="wrap" gap={2} rowGap={2}>
<Button
sx={{
background: theme.palette.secondary.dark,
'&:hover': { background: lighten(theme.palette.secondary.dark, 0.2) },
}}
variant="contained"
onClick={() => {
setResetPasswordConfirmationRequired(true);
}}
>
{t('actions.button.resetPassword')}
</Button>
<Button
id="delete-account-button"
variant="outlined"
sx={{
border: `solid 2px ${theme.palette.primary.dark}`,
color: theme.palette.primary.dark,
'&:hover': {
border: `solid 2px ${theme.palette.primary.dark}`,
background: theme.palette.primary.dark,
color: theme.palette.common.white,
},
}}
onClick={() => {
setDeleteAccountConfirmationRequired(true);
}}
>
{t('actions.button.deleteAccount')}
</Button>
</Box>
<ConfirmDialog
title={t('actions.resetPasswordConfirmDialogTitle')}
cancelLabel={t('actions.confirmDialogCancel')}
submitLabel={t('actions.button.resetPassword')}
isOpen={resetPasswordConfirmationRequired}
onConfirm={passwordResetConfirmHandler}
/>
<ConfirmDialog
title={t('actions.deleteAccountConfirmDialogTitle')}
text={t('actions.deleteAccountConfirmDialogDescription')}
cancelLabel={t('actions.confirmDialogCancel')}
submitLabel={t('actions.button.deleteAccount')}
isOpen={deleteAccountConfirmationRequired}
onConfirm={deleteAccountConfirmHandler}
/>
</CardContent>
</Card>
);
};

export default AccountActionsCard;
4 changes: 2 additions & 2 deletions components/cards/ProfileSettingsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const ProfileSettingsCard = () => {
<Card sx={cardStyle}>
<CardContent>
<Typography variant="h2" component="h2">
{t('profile.title')}
{t('profileSettings.title')}
</Typography>
<Typography>
{t.rich('profile.description', {
{t.rich('profileSettings.description', {
link: (children) => <Link href={tS('feedbackTypeform')}>{children}</Link>,
})}
</Typography>
Expand Down
50 changes: 50 additions & 0 deletions components/forms/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { DialogContent, DialogContentText } from '@mui/material';
import Button from '@mui/material/Button';
import Dialog from '@mui/material/Dialog';
import DialogActions from '@mui/material/DialogActions';
import DialogTitle from '@mui/material/DialogTitle';
import * as React from 'react';

export default function ConfirmDialog({
isOpen,
onConfirm,
title,
text,
submitLabel,
cancelLabel,
}: {
isOpen: boolean;
onConfirm: (confirmed: boolean) => void;
title: string;
text?: string;
submitLabel: string;
cancelLabel: string;
}) {
const handleClose = (confirmAction: boolean) => () => {
onConfirm(confirmAction);
};

return (
<React.Fragment>
<Dialog
open={isOpen}
onClose={handleClose(false)}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">{title}</DialogTitle>
{text && (
<DialogContent>
<DialogContentText>{text}</DialogContentText>
</DialogContent>
)}
<DialogActions>
<Button onClick={handleClose(false)}>{cancelLabel}</Button>
<Button id="confirm-dialog-submit" onClick={handleClose(true)} autoFocus>
{submitLabel}
</Button>
</DialogActions>
</Dialog>
</React.Fragment>
);
}
1 change: 1 addition & 0 deletions components/forms/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const LoginForm = () => {
)}

<LoadingButton
id="login-submit"
sx={{ mt: 2, mr: 1.5 }}
variant="contained"
fullWidth
Expand Down
Loading

0 comments on commit 6edf37c

Please sign in to comment.