feat(Unsubscribe): Access the unsubscribe API

This commit is contained in:
haitao(lj) 2022-12-27 18:10:31 +08:00
parent 2b65141625
commit 6ef3182473
2 changed files with 15 additions and 2 deletions

View File

@ -1,8 +1,9 @@
import { FC, memo } from 'react'; import { FC, memo, useEffect } from 'react';
import { Container, Row, Col } from 'react-bootstrap'; import { Container, Row, Col } from 'react-bootstrap';
import { Link } from 'react-router-dom'; import { Link, useSearchParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { unsubscribe } from '@/services';
import { usePageTags } from '@/hooks'; import { usePageTags } from '@/hooks';
const Index: FC = () => { const Index: FC = () => {
@ -10,6 +11,13 @@ const Index: FC = () => {
usePageTags({ usePageTags({
title: t('page_title'), title: t('page_title'),
}); });
const [searchParams] = useSearchParams();
const code = searchParams.get('code');
useEffect(() => {
if (code) {
unsubscribe(code);
}
}, [code]);
return ( return (
<Container className="pt-4 mt-2 mb-5"> <Container className="pt-4 mt-2 mb-5">
<Row className="justify-content-center"> <Row className="justify-content-center">

View File

@ -257,3 +257,8 @@ export const getAppSettings = () => {
export const reopenQuestion = (params: { question_id: string }) => { export const reopenQuestion = (params: { question_id: string }) => {
return request.put('/answer/api/v1/question/reopen', params); return request.put('/answer/api/v1/question/reopen', params);
}; };
export const unsubscribe = (code: string) => {
const apiUrl = '/answer/api/v1/user/email/notification';
return request.put(apiUrl, { code });
};