mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
upgrading to react 18
This commit is contained in:
@@ -27,14 +27,17 @@ export default function FredyApp() {
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
const currentUser = useSelector((state) => state.user.currentUser);
|
||||
|
||||
useEffect(async () => {
|
||||
await dispatch.provider.getProvider();
|
||||
await dispatch.jobs.getJobs();
|
||||
await dispatch.jobs.getProcessingTimes();
|
||||
await dispatch.notificationAdapter.getAdapter();
|
||||
await dispatch.user.getCurrentUser();
|
||||
useEffect(() => {
|
||||
async function init() {
|
||||
await dispatch.provider.getProvider();
|
||||
await dispatch.jobs.getJobs();
|
||||
await dispatch.jobs.getProcessingTimes();
|
||||
await dispatch.notificationAdapter.getAdapter();
|
||||
await dispatch.user.getCurrentUser();
|
||||
|
||||
setLoading(false);
|
||||
setLoading(false);
|
||||
}
|
||||
init();
|
||||
}, [currentUser?.userId]);
|
||||
|
||||
const needsLogin = () => {
|
||||
|
||||
@@ -4,7 +4,9 @@ import { reduxStore } from './services/rematch/store';
|
||||
import { HashRouter } from 'react-router-dom';
|
||||
import { createHashHistory } from 'history';
|
||||
import { Provider } from 'react-redux';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
const container = document.getElementById('fredy');
|
||||
const root = createRoot(container);
|
||||
|
||||
const history = createHashHistory();
|
||||
|
||||
@@ -12,11 +14,10 @@ import App from './App';
|
||||
|
||||
import './Index.less';
|
||||
|
||||
ReactDOM.render(
|
||||
root.render(
|
||||
<Provider store={reduxStore}>
|
||||
<HashRouter history={history}>
|
||||
<App />
|
||||
</HashRouter>
|
||||
</Provider>,
|
||||
document.getElementById('fredy')
|
||||
</Provider>
|
||||
);
|
||||
|
||||
@@ -23,18 +23,24 @@ const GeneralSettings = function Users() {
|
||||
const [workingHourTo, setWorkingHourTo] = React.useState(null);
|
||||
const ctx = React.useContext(ToastContext);
|
||||
|
||||
React.useEffect(async () => {
|
||||
await dispatch.generalSettings.getGeneralSettings();
|
||||
setLoading(false);
|
||||
React.useEffect(() => {
|
||||
async function init() {
|
||||
await dispatch.generalSettings.getGeneralSettings();
|
||||
setLoading(false);
|
||||
}
|
||||
init();
|
||||
}, []);
|
||||
|
||||
React.useEffect(async () => {
|
||||
setInterval(settings?.interval);
|
||||
setPort(settings?.port);
|
||||
setScrapingAntApiKey(settings?.scrapingAnt?.apiKey);
|
||||
setWorkingHourFrom(settings?.workingHours?.from);
|
||||
setWorkingHourTo(settings?.workingHours?.to);
|
||||
setScrapingAntProxy(settings?.scrapingAnt?.proxy || 'datacenter');
|
||||
React.useEffect(() => {
|
||||
async function init() {
|
||||
setInterval(settings?.interval);
|
||||
setPort(settings?.port);
|
||||
setScrapingAntApiKey(settings?.scrapingAnt?.apiKey);
|
||||
setWorkingHourFrom(settings?.workingHours?.from);
|
||||
setWorkingHourTo(settings?.workingHours?.to);
|
||||
setScrapingAntProxy(settings?.scrapingAnt?.proxy || 'datacenter');
|
||||
}
|
||||
init();
|
||||
}, [settings]);
|
||||
|
||||
const nullOrEmpty = (val) => val == null || val.length === 0;
|
||||
|
||||
@@ -18,9 +18,12 @@ const Users = function Users() {
|
||||
const [userIdToBeRemoved, setUserIdToBeRemoved] = React.useState(null);
|
||||
const history = useHistory();
|
||||
|
||||
React.useEffect(async () => {
|
||||
await dispatch.user.getUsers();
|
||||
setLoading(false);
|
||||
React.useEffect(() => {
|
||||
async function init() {
|
||||
await dispatch.user.getUsers();
|
||||
setLoading(false);
|
||||
}
|
||||
init();
|
||||
}, []);
|
||||
|
||||
const onUserRemoval = async () => {
|
||||
|
||||
@@ -21,21 +21,24 @@ const UserMutator = function UserMutator() {
|
||||
const ctx = React.useContext(ToastContext);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
React.useEffect(async () => {
|
||||
if (params.userId != null) {
|
||||
try {
|
||||
const userJson = await xhrGet(`/api/admin/users/${params.userId}`);
|
||||
const user = userJson.json;
|
||||
React.useEffect(() => {
|
||||
async function init() {
|
||||
if (params.userId != null) {
|
||||
try {
|
||||
const userJson = await xhrGet(`/api/admin/users/${params.userId}`);
|
||||
const user = userJson.json;
|
||||
|
||||
const defaultName = user?.username || '';
|
||||
const defaultIsAdmin = user?.isAdmin || false;
|
||||
const defaultName = user?.username || '';
|
||||
const defaultIsAdmin = user?.isAdmin || false;
|
||||
|
||||
setUsername(defaultName);
|
||||
setIsAdmin(defaultIsAdmin);
|
||||
} catch (Exception) {
|
||||
console.error(Exception);
|
||||
setUsername(defaultName);
|
||||
setIsAdmin(defaultIsAdmin);
|
||||
} catch (Exception) {
|
||||
console.error(Exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
init();
|
||||
}, [params.userId]);
|
||||
|
||||
const saveUser = async () => {
|
||||
|
||||
Reference in New Issue
Block a user