feat: add API function to retrieve all notifications
This commit is contained in:
9
src/api/notification.jsx
Normal file
9
src/api/notification.jsx
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { SendRequest } from '../components/Global/ApiRequest';
|
||||||
|
|
||||||
|
export const getAllNotification = async () => {
|
||||||
|
const response = await SendRequest({
|
||||||
|
method: 'get',
|
||||||
|
prefix: 'notification',
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { memo, useState, useEffect } from 'react';
|
import React, { memo, useState, useEffect } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useBreadcrumb } from '../../layout/LayoutBreadcrumb';
|
import { useBreadcrumb } from '../../layout/LayoutBreadcrumb';
|
||||||
import { Form, Typography } from 'antd';
|
import { Typography } from 'antd';
|
||||||
import ListNotification from './component/ListNotification';
|
import ListNotification from './component/ListNotification';
|
||||||
import DetailNotification from './component/DetailNotification';
|
import DetailNotification from './component/DetailNotification';
|
||||||
|
|
||||||
@@ -10,7 +10,6 @@ const { Text } = Typography;
|
|||||||
const IndexNotification = memo(function IndexNotification() {
|
const IndexNotification = memo(function IndexNotification() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { setBreadcrumbItems } = useBreadcrumb();
|
const { setBreadcrumbItems } = useBreadcrumb();
|
||||||
const [form] = Form.useForm();
|
|
||||||
|
|
||||||
const [actionMode, setActionMode] = useState('list');
|
const [actionMode, setActionMode] = useState('list');
|
||||||
const [selectedData, setSelectedData] = useState(null);
|
const [selectedData, setSelectedData] = useState(null);
|
||||||
@@ -36,19 +35,14 @@ const IndexNotification = memo(function IndexNotification() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (actionMode === 'preview') {
|
if (actionMode === 'preview') {
|
||||||
setIsModalVisible(true);
|
setIsModalVisible(true);
|
||||||
if (selectedData) {
|
|
||||||
form.setFieldsValue(selectedData);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
setIsModalVisible(false);
|
setIsModalVisible(false);
|
||||||
form.resetFields();
|
|
||||||
}
|
}
|
||||||
}, [actionMode, selectedData, form]);
|
}, [actionMode]);
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setActionMode('list');
|
setActionMode('list');
|
||||||
setSelectedData(null);
|
setSelectedData(null);
|
||||||
form.resetFields();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -62,7 +56,6 @@ const IndexNotification = memo(function IndexNotification() {
|
|||||||
<DetailNotification
|
<DetailNotification
|
||||||
visible={isModalVisible}
|
visible={isModalVisible}
|
||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
form={form}
|
|
||||||
selectedData={selectedData}
|
selectedData={selectedData}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user