Skip to content

Commit

Permalink
Remove password and email editing
Browse files Browse the repository at this point in the history
Will just cause multiple data source issues.
  • Loading branch information
henrikhorluck committed Feb 4, 2024
1 parent fcb0f2d commit 3e82c24
Show file tree
Hide file tree
Showing 17 changed files with 7 additions and 462 deletions.
1 change: 0 additions & 1 deletion src/core/appUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const getProfileSettingsUrl = () => url`/profile/settings`;
export const getProfileSettingsAccessCardUrl = () => url`/profile/settings/access-card`;
export const getProfileSettingsMailUrl = () => url`/profile/settings/mail`;
export const getProfileSettingsNotificationsUrl = () => url`/profile/settings/notifications`;
export const getProfileSettingsPasswordUrl = () => url`/profile/settings/password`;
export const getProfileSettingsPenaltiesUrl = () => url`/profile/settings/penalties`;
export const getProfileSettingsPrivacyUrl = () => url`/profile/settings/privacy`;
export const getProfileAppConnectionsUrl = () => url`/profile/settings/apps`;
Expand Down
17 changes: 0 additions & 17 deletions src/pages/profile/settings/password.tsx

This file was deleted.

34 changes: 1 addition & 33 deletions src/profile/api/mail.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getUser } from 'authentication/api';
import { get, IAPIData, patch, deleteR, post } from 'common/utils/api';
import { get, IAPIData } from 'common/utils/api';

import { IMail } from '../models/Mail';

Expand All @@ -12,35 +12,3 @@ export const getMails = async (): Promise<IMail[]> => {
const data = await get<IAPIData<IMail>>(API_URL, { format: 'json' }, { user });
return data.results;
};

export const patchMails = async (addressId: number, data: Partial<IMail>): Promise<IMail> => {
const user = await getUser();
const response = await patch<IMail, Partial<IMail>>({
query: `${API_URL}${addressId}/`,
data,
parameters: { format: 'json' },
options: { user },
});

return response;
};

export const deleteMail = async (mailId: number) => {
const user = await getUser();
try {
const ret = await deleteR(`${API_URL}${mailId}`, undefined, { user });
return ret;
} catch (err) {
throw new Error(`Kunne ikke slette mail ${err.statusText}`);
}
};

export const postMail = async (mail: Partial<IMail>) => {
const user = await getUser();
try {
const res = await post<IMail>(API_URL, mail, undefined, { user });
return res;
} catch (err) {
throw new Error(`Kunne ikke legge til ny mail ${err.statusText}`);
}
};
22 changes: 0 additions & 22 deletions src/profile/api/password.ts

This file was deleted.

28 changes: 2 additions & 26 deletions src/profile/components/Settings/Mails/Mail.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,18 @@
import React, { useState } from 'react';
import React from 'react';
import { IMail } from '../../../models/Mail';
import style from './mail.less';
import { Icon } from '@dotkomonline/design-system';
import { deleteMail } from 'profile/api/mail';
import { useToast } from 'core/utils/toast/useToast';

interface IProps extends IMail {
callback: () => Promise<void>;
}
const Mail = ({ email, primary, verified, id, callback }: IProps) => {
const [confirm, setConfirm] = useState(false);
const [addMessage, cancelToast] = useToast({ type: 'info', duration: 5000 });
const handleClick = async () => {
if (primary) {
cancelToast();
addMessage('Du kan ikke slette primær-mailen din, venligst velg en annen mail først', { type: 'error' });
} else if (confirm) {
try {
await deleteMail(id);
addMessage(`Mailen: "${email}" har blitt slettet`);
callback();
} catch (err) {
cancelToast();
addMessage('Kunne ikke slette mailen din', { type: 'error' });
throw err;
}
} else {
setConfirm(true);
}
};
const Mail = ({ email, primary, verified }: IProps) => {
return (
<li className={style.mail} tabIndex={0}>
<h4 title={`Denne mailen er ${!verified ? 'ikke ' : ''}verifisert`}>
{email}
{verified ? <Icon name="verified" /> : null}
{primary ? <span className={style.primary}> - Primær</span> : null}
</h4>
<button onClick={handleClick}>{confirm ? 'Bekreft' : <Icon name="delete" />}</button>
</li>
);
};
Expand Down
37 changes: 0 additions & 37 deletions src/profile/components/Settings/Mails/MailForm/AddMailField.tsx

This file was deleted.

This file was deleted.

29 changes: 0 additions & 29 deletions src/profile/components/Settings/Mails/MailForm/form.less

This file was deleted.

40 changes: 4 additions & 36 deletions src/profile/components/Settings/Mails/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { Pane } from 'common/components/Panes';
import React, { FC, useEffect, useState } from 'react';
import { getMails, patchMails, postMail } from '../../../api/mail';
import { getMails } from '../../../api/mail';
import { IMail } from '../../../models/Mail';
import Mail from './Mail';
import { Spinner, Card, Markdown } from '@dotkomonline/design-system';
import { Card, Markdown, Spinner } from '@dotkomonline/design-system';
import style from './mail.less';
import { MAIL_INFO, PRIMARY_MAIL_INFO } from './mailInformation';
import AddMailField from './MailForm/AddMailField';
import SelectPrimaryField from './MailForm/SelectPrimaryField';
import { useToast } from 'core/utils/toast/useToast';
import { MAIL_INFO } from './mailInformation';
import EmailSubscription from './EmailSubscription';

export interface IState {
Expand All @@ -17,7 +14,6 @@ export interface IState {

const Mails: FC = () => {
const [mails, setMails] = useState<IMail[]>();
const [addMessage, cancelToast] = useToast({ type: 'success', duration: 15000 });

const fetchMails = async () => {
const mails = await getMails();
Expand All @@ -28,30 +24,6 @@ const Mails: FC = () => {
fetchMails();
}, []);

const saveNewPrimaryMail = async (mail: IMail) => {
try {
await patchMails(mail.id, { primary: true });
addMessage(PRIMARY_MAIL_INFO);
fetchMails();
} catch (err) {
cancelToast();
addMessage('En feil skjedde: Vi kunne ikke lagre din nye primær-epost');
// This throw is for Sentry to catchup
throw err;
}
};

const addNewMail = async (mail: Partial<IMail>) => {
try {
await postMail(mail);
fetchMails();
} catch (err) {
cancelToast();
addMessage('En feil skjedde: Vi kunne ikke legge til din nye mail');
throw err;
}
};

if (!mails) {
return <Spinner />;
}
Expand All @@ -66,11 +38,7 @@ const Mails: FC = () => {
<Mail {...mail} key={mail.email} callback={fetchMails} />
))}
</ul>
</Card>
<div>
<SelectPrimaryField mails={mails} onSubmit={saveNewPrimaryMail} />
<AddMailField onSubmit={addNewMail} />
</div>
</Card>
</Pane>
<EmailSubscription />
</>
Expand Down
4 changes: 0 additions & 4 deletions src/profile/components/Settings/Mails/mailInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ export const MAIL_INFO = `
Her er en oversikt over e-postadresser som er tilknyttet din konto. Adressen som er markert som primær brukes til alle våre e-postlister, gjenoppretning av passord og andre varsler som sendes fra oss.
`;

export const PRIMARY_MAIL_INFO = `
Din primær e-post har blitt endret. Det ta opptil én time før endringen er registert i alle mailinglister, mens adresse for andre varsler og gjenoppretning oppdateres umiddelbart.
`;

export const SUBSCRIPTION_INFO = `
### Infomail
Her velger du om du ønsker/ikke ønsker Her velger du om du ønsker/ikke ønsker å motta periodiske oppdateringer om hva som skjer i Online fremover.
Expand Down
1 change: 0 additions & 1 deletion src/profile/components/Settings/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const Menu = () => (
<div className={style.menu}>
<Tab text="Informasjon" {...appUrls.getProfileSettingsUrl()} />
<Tab text="E-Post" {...appUrls.getProfileSettingsMailUrl()} />
<Tab text="Passord" {...appUrls.getProfileSettingsPasswordUrl()} />
<Tab text="Prikker og suspensjoner" {...appUrls.getProfileSettingsPenaltiesUrl()} />
<Tab text="Personvern" {...appUrls.getProfileSettingsPrivacyUrl()} />
<Tab text="Medlemskap" {...appUrls.getProfileMembershipUrl()} />
Expand Down
20 changes: 0 additions & 20 deletions src/profile/components/Settings/Password/ErrorMessage.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions src/profile/components/Settings/Password/PasswordInput.tsx

This file was deleted.

Loading

0 comments on commit 3e82c24

Please sign in to comment.