mirror of https://gitee.com/answerdev/answer.git
feat(Users): Add user unsubscribe result
This commit is contained in:
parent
14b21d5187
commit
f4f2e05482
|
@ -838,6 +838,11 @@ ui:
|
|||
confirm_new_email_invalid: >-
|
||||
Sorry, this confirmation link is no longer valid. Perhaps your email was
|
||||
already changed?
|
||||
unsubscribe:
|
||||
page_title: Unsubscribe
|
||||
success_title: Unsubscribe Successful
|
||||
success_desc: You have been successfully removed from this subscriber list and won’t receive any further emails from us.
|
||||
link: Change settings
|
||||
question:
|
||||
following_tags: Following Tags
|
||||
edit: Edit
|
||||
|
|
|
@ -31,13 +31,15 @@ const Index = () => {
|
|||
|
||||
const getProfile = () => {
|
||||
getLoggedUserInfo().then((res) => {
|
||||
setFormData({
|
||||
notice_switch: {
|
||||
value: res.notice_status === 1,
|
||||
isInvalid: false,
|
||||
errorMsg: '',
|
||||
},
|
||||
});
|
||||
if (res) {
|
||||
setFormData({
|
||||
notice_switch: {
|
||||
value: res.notice_status === 1,
|
||||
isInvalid: false,
|
||||
errorMsg: '',
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -43,12 +43,14 @@ const Index: React.FC = () => {
|
|||
});
|
||||
const getProfile = () => {
|
||||
getLoggedUserInfo().then((res) => {
|
||||
formData.display_name.value = res.display_name;
|
||||
formData.bio.value = res.bio;
|
||||
formData.avatar.value = res.avatar;
|
||||
formData.location.value = res.location;
|
||||
formData.website.value = res.website;
|
||||
setFormData({ ...formData });
|
||||
if (res) {
|
||||
formData.display_name.value = res.display_name;
|
||||
formData.bio.value = res.bio;
|
||||
formData.avatar.value = res.avatar;
|
||||
formData.location.value = res.location;
|
||||
formData.website.value = res.website;
|
||||
setFormData({ ...formData });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import { FC, memo } from 'react';
|
||||
import { Container, Row, Col } from 'react-bootstrap';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { usePageTags } from '@/hooks';
|
||||
|
||||
const Index: FC = () => {
|
||||
const { t } = useTranslation('translation', { keyPrefix: 'unsubscribe' });
|
||||
usePageTags({
|
||||
title: t('page_title'),
|
||||
});
|
||||
return (
|
||||
<Container className="pt-4 mt-2 mb-5">
|
||||
<Row className="justify-content-center">
|
||||
<Col lg={6}>
|
||||
<h3 className="text-center mt-3 mb-5">{t('success_title')}</h3>
|
||||
<p className="text-center">{t('success_desc')}</p>
|
||||
<div className="text-center">
|
||||
<Link to="/users/settings/notify">{t('link')}</Link>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
export default memo(Index);
|
|
@ -337,6 +337,10 @@ const routes: RouteNode[] = [
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/users/unsubscribe',
|
||||
page: 'pages/Users/Unsubscribe',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -8,12 +8,23 @@ const differentCurrent = (target: string, base?: string) => {
|
|||
return targetUrl.toString() !== window.location.href;
|
||||
};
|
||||
|
||||
const storageLoginRedirect = () => {
|
||||
const { pathname } = window.location;
|
||||
if (pathname !== RouteAlias.login && pathname !== RouteAlias.register) {
|
||||
const loc = window.location;
|
||||
const redirectUrl = loc.href.replace(loc.origin, '');
|
||||
Storage.set(REDIRECT_PATH_STORAGE_KEY, redirectUrl);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* only navigate if not same as current url
|
||||
* @param pathname
|
||||
* @param callback
|
||||
*/
|
||||
const navigate = (pathname: string, callback: Function) => {
|
||||
if (pathname === RouteAlias.login) {
|
||||
storageLoginRedirect();
|
||||
}
|
||||
if (differentCurrent(pathname)) {
|
||||
callback();
|
||||
}
|
||||
|
@ -23,12 +34,7 @@ const navigate = (pathname: string, callback: Function) => {
|
|||
* auto navigate to login page with redirect info
|
||||
*/
|
||||
const navigateToLogin = () => {
|
||||
const { pathname } = window.location;
|
||||
if (pathname !== RouteAlias.login && pathname !== RouteAlias.register) {
|
||||
const loc = window.location;
|
||||
const redirectUrl = loc.href.replace(loc.origin, '');
|
||||
Storage.set(REDIRECT_PATH_STORAGE_KEY, redirectUrl);
|
||||
}
|
||||
storageLoginRedirect();
|
||||
navigate(RouteAlias.login, () => {
|
||||
window.location.replace(RouteAlias.login);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue