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:
@@ -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