Skip to content
Open
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
1 change: 0 additions & 1 deletion .ebstalk.apps.env/webapp.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ GOOGLE_OAUTH_CLIENT_SECRET_SENSITIVE="{{pull:secretsmanager:/io.cv.app/prd/googl
GOOGLE_OAUTH_ENCRYPTION_SECRET="{{pull:secretsmanager:/io.cv.app/prd/google-auth:SecretString:google_oauth_encryption_secret}}"
FIREBASE_PRIVATE_KEY="{{pull:secretsmanager:/io.cv.app/prd/firebase:SecretString:private_key}}"
FIREBASE_CLIENT_EMAIL="{{pull:secretsmanager:/io.cv.app/prd/firebase:SecretString:client_email}}"
LOOPS_EMAIL_API_KEY="{{pull:secretsmanager:/io.cv.app/prd/loops-email:SecretString:loops_email_api_key}}"
MAILGUN_DOMAIN="{{pull:secretsmanager:/io.cv.app/prd/mailgun:SecretString:mailgun_domain}}"
MAILGUN_API_KEY="{{pull:secretsmanager:/io.cv.app/prd/mailgun:SecretString:mailgun_api_key}}"
MIXPANEL_API_KEY="{{pull:secretsmanager:/io.cv.app/prd/mixpanel:SecretString:webapp_api_key}}"
Expand Down
15 changes: 4 additions & 11 deletions apps/webapp/components/_app/components/OnboardingEmailForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import { useUser } from 'hooks/useUser';
const emailSchema = yup.string().email().ensure().trim();

export const schema = yup.object({
email: emailSchema.when(['emailNewsletter', 'emailNotifications'], {
is: (emailNewsletter: boolean, emailNotifications: boolean) => emailNewsletter || emailNotifications,
email: emailSchema.when(['emailNotifications'], {
is: (emailNotifications: boolean) => emailNotifications,
then: () => emailSchema.required('Unselect email options to proceed without email'),
otherwise: () => emailSchema
}),
emailNotifications: yup.boolean(),
emailNewsletter: yup.boolean(),
agreeTermsConditions: yup.boolean().oneOf([true], 'You must agree to the terms and privacy policy to continue')
});

Expand All @@ -46,7 +45,6 @@ export function OnboardingEmailForm({ onClick, spaceId }: { onClick: VoidFunctio
resolver: yupResolver(schema)
});

const emailNewsletter = getValues('emailNewsletter');
const emailNotifications = getValues('emailNotifications');
const agreeTermsConditions = getValues('agreeTermsConditions');

Expand All @@ -58,14 +56,13 @@ export function OnboardingEmailForm({ onClick, spaceId }: { onClick: VoidFunctio

const onSubmit = async (values: FormValues) => {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { email, emailNewsletter, emailNotifications } = values;
const { email, emailNotifications } = values;
await saveForm({
email: email || undefined,
emailNewsletter,
emailNotifications,
spaceId
});
updateUser({ ...user, email, emailNewsletter, emailNotifications });
updateUser({ ...user, email, emailNotifications });
onClick();
};

Expand Down Expand Up @@ -97,10 +94,6 @@ export function OnboardingEmailForm({ onClick, spaceId }: { onClick: VoidFunctio
}
label='Notify me about key activities (e.g., proposal feedback, reward status, mentions, comments)'
/>
<FormControlLabel
control={<Checkbox {...register('emailNewsletter')} checked={emailNewsletter} onChange={onChange} />}
label='Receive tips and examples how to use CharmVerse.'
/>
<Button
variant='outlined'
color='inherit'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ import Legend from '../../components/Legend';

export const schema = yup.object({
email: yup.string().ensure().trim().email(),
emailNotifications: yup.boolean(),
emailNewsletter: yup.boolean()
emailNotifications: yup.boolean()
});

export type FormValues = yup.InferType<typeof schema>;
Expand All @@ -49,7 +48,6 @@ export function AccountPreferences() {
} = useSWRMutation('/api/profile', (_url, { arg }: Readonly<{ arg: Partial<User> }>) => charmClient.updateUser(arg), {
onSuccess: (data) => {
updateUser({
emailNewsletter: data.emailNewsletter,
emailNotifications: data.emailNotifications,
email: data.email
});
Expand All @@ -64,7 +62,6 @@ export function AccountPreferences() {
} = useForm<FormValues>({
defaultValues: {
email: user?.email || '',
emailNewsletter: user?.emailNewsletter || false,
emailNotifications: user?.emailNotifications || false
},
mode: 'onChange',
Expand Down Expand Up @@ -131,13 +128,6 @@ export function AccountPreferences() {
}
label='Receive email updates on mentions, comments, post and other things in CharmVerse.'
/>
<FormControlLabel
disabled={!user?.email || isMutating}
control={
<Checkbox {...register('emailNewsletter')} checked={!!user?.emailNewsletter} onChange={onChange} />
}
label='Receive tips and examples how to use CharmVerse.'
/>
</FormGroup>
<Button
variant='outlined'
Expand Down
15 changes: 0 additions & 15 deletions apps/webapp/pages/api/profile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { log } from '@charmverse/core/log';
import { prisma } from '@charmverse/core/prisma-client';
import type { SignatureVerificationPayload } from '@packages/lib/blockchain/signAndVerify';
import { updateGuildRolesForUser } from '@packages/lib/guild-xyz/server/updateGuildRolesForUser';
import { deleteLoopsContact } from '@packages/lib/loopsEmail/deleteLoopsContact';
import { registerLoopsContact } from '@packages/lib/loopsEmail/registerLoopsContact';
import { onError, onNoMatch, requireUser } from '@packages/lib/middleware';
import { requireWalletSignature } from '@packages/lib/middleware/requireWalletSignature';
import { withSessionRoute } from '@packages/lib/session/withSession';
Expand Down Expand Up @@ -100,19 +98,6 @@ async function updateUser(req: NextApiRequest, res: NextApiResponse<LoggedInUser

updateTrackUserProfile(updatedUser);

if (original.email !== updatedUser.email || original.emailNewsletter !== updatedUser.emailNewsletter) {
try {
if (!updatedUser.email) {
// remove from Loops
await deleteLoopsContact({ email: original.email! });
} else {
await registerLoopsContact(updatedUser, original.email);
}
} catch (error) {
log.error('Error updating contact with Loop', { error, userId });
}
}

return res.status(200).json(updatedUser);
}

Expand Down
28 changes: 0 additions & 28 deletions apps/webapp/pages/api/profile/onboarding-email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import type { UserDetails } from '@charmverse/core/prisma';
import { prisma } from '@charmverse/core/prisma-client';
import { magicLinkEmailCookie } from '@packages/config/constants';
import { sendMagicLink } from '@packages/lib/google/sendMagicLink';
import { registerLoopsContact } from '@packages/lib/loopsEmail/registerLoopsContact';
import { sendSignupEvent as sendLoopSignupEvent } from '@packages/lib/loopsEmail/sendSignupEvent';
import { onError, onNoMatch, requireUser } from '@packages/lib/middleware';
import { withSessionRoute } from '@packages/lib/session/withSession';
import { updateUserProfile } from '@packages/users/updateUserProfile';
Expand All @@ -20,7 +18,6 @@ handler.use(requireUser).put(saveOnboardingEmail);

export type EmailPreferences = {
email?: string;
emailNewsletter?: boolean;
emailNotifications?: boolean;
spaceId?: string; // the current space id
};
Expand All @@ -33,31 +30,6 @@ async function saveOnboardingEmail(req: NextApiRequest, res: NextApiResponse<Use

const cookies = new Cookies(req, res);

if (updatedUser.email && updatedUser.emailNewsletter && payload.spaceId) {
try {
// retrieve space template used via cookie
const spaceTemplate = cookies.get(spaceTemplateCookie);

const space = await prisma.space.findUniqueOrThrow({
where: {
id: payload.spaceId
}
});
const isAdmin = updatedUser.spaceRoles.some((role) => role.spaceId === payload.spaceId && role.isAdmin);
const result = await registerLoopsContact(updatedUser);
if (result.isNewContact) {
await sendLoopSignupEvent({
email: updatedUser.email,
isAdmin,
spaceName: space.name,
spaceTemplate
});
log.info('Sent signup to Loop', { userId });
}
} catch (error) {
log.error('Could not register user with Loop', { error, userId });
}
}
if (updatedUser.email) {
const verifiedEmail = await prisma.verifiedEmail.count({
where: {
Expand Down
201 changes: 0 additions & 201 deletions apps/webapp/scripts/loopsEmail.js

This file was deleted.

Loading
Loading