React 18 and Vite (#4510)
This commit is contained in:
parent
1bb1b13f6d
commit
21613fa602
244 changed files with 4547 additions and 8933 deletions
|
@ -1,8 +1,7 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import getServerSchedules from '@/api/server/schedules/getServerSchedules';
|
||||
import { ServerContext } from '@/state/server';
|
||||
import Spinner from '@/components/elements/Spinner';
|
||||
import { useHistory, useRouteMatch } from 'react-router-dom';
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import ScheduleRow from '@/components/server/schedules/ScheduleRow';
|
||||
import { httpErrorToHuman } from '@/api/http';
|
||||
|
@ -13,24 +12,23 @@ import tw from 'twin.macro';
|
|||
import GreyRowBox from '@/components/elements/GreyRowBox';
|
||||
import { Button } from '@/components/elements/button/index';
|
||||
import ServerContentBlock from '@/components/elements/ServerContentBlock';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
export default () => {
|
||||
const match = useRouteMatch();
|
||||
const history = useHistory();
|
||||
|
||||
const uuid = ServerContext.useStoreState((state) => state.server.data!.uuid);
|
||||
function ScheduleContainer() {
|
||||
const uuid = ServerContext.useStoreState(state => state.server.data!.uuid);
|
||||
const { clearFlashes, addError } = useFlash();
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
const schedules = ServerContext.useStoreState((state) => state.schedules.data);
|
||||
const setSchedules = ServerContext.useStoreActions((actions) => actions.schedules.setSchedules);
|
||||
const schedules = ServerContext.useStoreState(state => state.schedules.data);
|
||||
const setSchedules = ServerContext.useStoreActions(actions => actions.schedules.setSchedules);
|
||||
|
||||
useEffect(() => {
|
||||
clearFlashes('schedules');
|
||||
|
||||
getServerSchedules(uuid)
|
||||
.then((schedules) => setSchedules(schedules))
|
||||
.catch((error) => {
|
||||
.then(schedules => setSchedules(schedules))
|
||||
.catch(error => {
|
||||
addError({ message: httpErrorToHuman(error), key: 'schedules' });
|
||||
console.error(error);
|
||||
})
|
||||
|
@ -49,16 +47,13 @@ export default () => {
|
|||
There are no schedules configured for this server.
|
||||
</p>
|
||||
) : (
|
||||
schedules.map((schedule) => (
|
||||
schedules.map(schedule => (
|
||||
// @ts-expect-error go away
|
||||
<GreyRowBox
|
||||
as={'a'}
|
||||
key={schedule.id}
|
||||
href={`${match.url}/${schedule.id}`}
|
||||
as={Link}
|
||||
to={schedule.id}
|
||||
css={tw`cursor-pointer mb-2 flex-wrap`}
|
||||
onClick={(e: any) => {
|
||||
e.preventDefault();
|
||||
history.push(`${match.url}/${schedule.id}`);
|
||||
}}
|
||||
>
|
||||
<ScheduleRow schedule={schedule} />
|
||||
</GreyRowBox>
|
||||
|
@ -76,4 +71,6 @@ export default () => {
|
|||
)}
|
||||
</ServerContentBlock>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default ScheduleContainer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue