mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
replacing rematch with zustand (#180)
* replacing rematch with zustand * upgrading dependencies * next release version
This commit is contained in:
committed by
GitHub
parent
28e885f6c7
commit
4f79c5cba2
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useActions, useSelector } from '../../services/state/store';
|
||||
|
||||
import { Divider, TimePicker, Button, Checkbox, Input } from '@douyinfe/semi-ui';
|
||||
import { InputNumber } from '@douyinfe/semi-ui';
|
||||
@@ -36,7 +36,7 @@ function formatFromTBackend(time) {
|
||||
}
|
||||
|
||||
const GeneralSettings = function GeneralSettings() {
|
||||
const dispatch = useDispatch();
|
||||
const actions = useActions();
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
|
||||
const settings = useSelector((state) => state.generalSettings.settings);
|
||||
@@ -51,7 +51,7 @@ const GeneralSettings = function GeneralSettings() {
|
||||
|
||||
React.useEffect(() => {
|
||||
async function init() {
|
||||
await dispatch.generalSettings.getGeneralSettings();
|
||||
await actions.generalSettings.getGeneralSettings();
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
import JobTable from '../../components/table/JobTable';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { useSelector, useActions } from '../../services/state/store';
|
||||
import { xhrDelete, xhrPut } from '../../services/xhr';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import ProcessingTimes from './ProcessingTimes';
|
||||
@@ -13,13 +13,13 @@ export default function Jobs() {
|
||||
const jobs = useSelector((state) => state.jobs.jobs);
|
||||
const processingTimes = useSelector((state) => state.jobs.processingTimes);
|
||||
const navigate = useNavigate();
|
||||
const dispatch = useDispatch();
|
||||
const actions = useActions();
|
||||
|
||||
const onJobRemoval = async (jobId) => {
|
||||
try {
|
||||
await xhrDelete('/api/jobs', { jobId });
|
||||
Toast.success('Job successfully remove');
|
||||
await dispatch.jobs.getJobs();
|
||||
await actions.jobs.getJobs();
|
||||
} catch (error) {
|
||||
Toast.error(error);
|
||||
}
|
||||
@@ -29,7 +29,7 @@ export default function Jobs() {
|
||||
try {
|
||||
await xhrPut(`/api/jobs/${jobId}/status`, { status });
|
||||
Toast.success('Job status successfully changed');
|
||||
await dispatch.jobs.getJobs();
|
||||
await actions.jobs.getJobs();
|
||||
} catch (error) {
|
||||
Toast.error(error);
|
||||
}
|
||||
|
||||
@@ -2,20 +2,20 @@ import React from 'react';
|
||||
|
||||
import { roundToHour } from '../../../services/time/timeService';
|
||||
import Headline from '../../../components/headline/Headline';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useActions, useSelector } from '../../../services/state/store';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import Linechart from './Linechart';
|
||||
|
||||
const JobInsight = function JobInsight() {
|
||||
const dispatch = useDispatch();
|
||||
const actions = useActions();
|
||||
|
||||
const insights = useSelector((state) => state.jobs.insights);
|
||||
const jobs = useSelector((state) => state.jobs.jobs);
|
||||
const params = useParams();
|
||||
|
||||
React.useEffect(() => {
|
||||
dispatch.jobs.getInsightDataForJob(params.jobId);
|
||||
dispatch.jobs.getJobs();
|
||||
actions.jobs.getInsightDataForJob(params.jobId);
|
||||
actions.jobs.getJobs();
|
||||
}, []);
|
||||
|
||||
const getData = () => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import NotificationAdapterTable from '../../../components/table/NotificationAdap
|
||||
import ProviderTable from '../../../components/table/ProviderTable';
|
||||
import ProviderMutator from './components/provider/ProviderMutator';
|
||||
import Headline from '../../../components/headline/Headline';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useActions, useSelector } from '../../../services/state/store';
|
||||
import { xhrPost } from '../../../services/xhr';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { Divider, Input, Switch, Button, TagInput, Toast } from '@douyinfe/semi-ui';
|
||||
@@ -34,7 +34,7 @@ export default function JobMutator() {
|
||||
const [notificationAdapterData, setNotificationAdapterData] = useState(defaultNotificationAdapter);
|
||||
const [enabled, setEnabled] = useState(defaultEnabled);
|
||||
const navigate = useNavigate();
|
||||
const dispatch = useDispatch();
|
||||
const actions = useActions();
|
||||
|
||||
const isSavingEnabled = () => {
|
||||
return Boolean(notificationAdapterData.length && providerData.length && name);
|
||||
@@ -50,7 +50,7 @@ export default function JobMutator() {
|
||||
enabled,
|
||||
jobId: jobToBeEdit?.id || null,
|
||||
});
|
||||
await dispatch.jobs.getJobs();
|
||||
await actions.jobs.getJobs();
|
||||
Toast.success('Job successfully saved...');
|
||||
navigate('/jobs');
|
||||
} catch (Exception) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import React, { useState } from 'react';
|
||||
import { transform } from '../../../../../services/transformer/notificationAdapterTransformer';
|
||||
import { xhrPost } from '../../../../../services/xhr';
|
||||
import Help from './NotificationHelpDisplay';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { useSelector } from '../../../../../services/state/store';
|
||||
import { Banner, Button, Form, Modal, Select, Switch } from '@douyinfe/semi-ui';
|
||||
|
||||
import './NotificationAdapterMutator.less';
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
||||
|
||||
import { Banner, Modal, Select, Input } from '@douyinfe/semi-ui';
|
||||
import { transform } from '../../../../../services/transformer/providerTransformer';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { useSelector } from '../../../../../services/state/store';
|
||||
import { IconLikeHeart } from '@douyinfe/semi-icons';
|
||||
import './ProviderMutator.less';
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@ import cityBackground from '../../assets/city_background.jpg';
|
||||
import Logo from '../../components/logo/Logo';
|
||||
import { xhrPost } from '../../services/xhr';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useActions, useSelector } from '../../services/state/store';
|
||||
import { Input, Button, Banner, Toast } from '@douyinfe/semi-ui';
|
||||
|
||||
import './login.less';
|
||||
import { IconUser, IconLock } from '@douyinfe/semi-icons';
|
||||
|
||||
export default function Login() {
|
||||
const dispatch = useDispatch();
|
||||
const actions = useActions();
|
||||
const [username, setUserName] = React.useState('');
|
||||
const [password, setPassword] = React.useState('');
|
||||
const [error, setError] = React.useState(null);
|
||||
@@ -20,7 +20,7 @@ export default function Login() {
|
||||
|
||||
useEffect(() => {
|
||||
async function init() {
|
||||
await dispatch.demoMode.getDemoMode();
|
||||
await actions.demoMode.getDemoMode();
|
||||
}
|
||||
|
||||
init();
|
||||
@@ -46,7 +46,7 @@ export default function Login() {
|
||||
|
||||
Toast.success('Login successful!');
|
||||
|
||||
await dispatch.user.getCurrentUser();
|
||||
await actions.user.getCurrentUser();
|
||||
navigate('/jobs');
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
|
||||
import { Toast } from '@douyinfe/semi-ui';
|
||||
import UserTable from '../../components/table/UserTable';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useActions, useSelector } from '../../services/state/store';
|
||||
import { IconPlus } from '@douyinfe/semi-icons';
|
||||
import { Button } from '@douyinfe/semi-ui';
|
||||
import UserRemovalModal from './UserRemovalModal';
|
||||
@@ -12,7 +12,7 @@ import { useNavigate } from 'react-router-dom';
|
||||
import './Users.less';
|
||||
|
||||
const Users = function Users() {
|
||||
const dispatch = useDispatch();
|
||||
const actions = useActions();
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
const users = useSelector((state) => state.user.users);
|
||||
const [userIdToBeRemoved, setUserIdToBeRemoved] = React.useState(null);
|
||||
@@ -20,7 +20,7 @@ const Users = function Users() {
|
||||
|
||||
React.useEffect(() => {
|
||||
async function init() {
|
||||
await dispatch.user.getUsers();
|
||||
await actions.user.getUsers();
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ const Users = function Users() {
|
||||
await xhrDelete('/api/admin/users', { userId: userIdToBeRemoved });
|
||||
Toast.success('User successfully remove');
|
||||
setUserIdToBeRemoved(null);
|
||||
await dispatch.jobs.getJobs();
|
||||
await dispatch.user.getUsers();
|
||||
await actions.jobs.getJobs();
|
||||
await actions.user.getUsers();
|
||||
} catch (error) {
|
||||
Toast.error(error);
|
||||
setUserIdToBeRemoved(null);
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
|
||||
import { xhrGet, xhrPost } from '../../../services/xhr';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { useActions } from '../../../services/state/store';
|
||||
import { Divider, Input, Switch, Button, Toast } from '@douyinfe/semi-ui';
|
||||
import './UserMutator.less';
|
||||
import { SegmentPart } from '../../../components/segment/SegmentPart';
|
||||
@@ -16,7 +16,7 @@ const UserMutator = function UserMutator() {
|
||||
const [isAdmin, setIsAdmin] = React.useState(false);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const dispatch = useDispatch();
|
||||
const actions = useActions();
|
||||
|
||||
React.useEffect(() => {
|
||||
async function init() {
|
||||
@@ -48,7 +48,7 @@ const UserMutator = function UserMutator() {
|
||||
password2,
|
||||
isAdmin,
|
||||
});
|
||||
await dispatch.user.getUsers();
|
||||
await actions.user.getUsers();
|
||||
Toast.success('User successfully saved...');
|
||||
navigate('/users');
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user