queue creation logic
This commit is contained in:
@ -1,9 +1,14 @@
|
||||
::selection {
|
||||
background: #00d8a4;
|
||||
color: white;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
font-family: "Comfortaa", sans-serif;
|
||||
background-image: linear-gradient(to bottom, #020917, #101725);
|
||||
background-color: #001529
|
||||
background-color: #001529;
|
||||
}
|
||||
|
||||
.content {
|
||||
|
||||
@ -26,6 +26,13 @@ const HeaderComponent = () => {
|
||||
|
||||
const [authModalOpen, setAuthModalOpen] = useState(false);
|
||||
const [drawerOpen, setDrawerOpen] = useState(false);
|
||||
// const [screenOrientation, setScreenOrientation] = useState<OrientationType>(
|
||||
// window.screen.orientation.type
|
||||
// );
|
||||
|
||||
// window.addEventListener("orientationchange", () =>
|
||||
// setScreenOrientation(window.screen.orientation.type)
|
||||
// );
|
||||
|
||||
const currentLanguage = useSelector(
|
||||
(state: StorePrototype) => state.settings.language
|
||||
@ -156,7 +163,11 @@ const HeaderComponent = () => {
|
||||
<Menu
|
||||
theme="dark"
|
||||
mode="horizontal"
|
||||
items={isMobile ? mobileItems : items}
|
||||
items={
|
||||
isMobile && window.screen.orientation.type === "portrait-primary"
|
||||
? mobileItems
|
||||
: items
|
||||
}
|
||||
style={{ flex: 1, minWidth: 0 }}
|
||||
selectedKeys={selectedKeys}
|
||||
className="header-container"
|
||||
|
||||
72
frontend/app/src/components/queue/CreateQueueCard.tsx
Normal file
72
frontend/app/src/components/queue/CreateQueueCard.tsx
Normal file
@ -0,0 +1,72 @@
|
||||
import React, { useContext } from "react";
|
||||
import {
|
||||
CreateQueueRequest,
|
||||
Queue,
|
||||
useCreateQueueMutation,
|
||||
useGetQueuesQuery,
|
||||
} from "../../slice/QueueApi";
|
||||
import "../styles.css";
|
||||
import { Button, Form, Input, Spin } from "antd";
|
||||
import Title from "antd/es/typography/Title";
|
||||
import tr from "../../config/translation";
|
||||
import { MessageContext } from "../../App";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { PlusCircleOutlined } from "@ant-design/icons";
|
||||
|
||||
const CreateQueueCard = (): JSX.Element => {
|
||||
const messageApi = useContext(MessageContext);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [form] = Form.useForm();
|
||||
const [createQueue, { isLoading }] = useCreateQueueMutation();
|
||||
|
||||
const submit = (formData: CreateQueueRequest) => {
|
||||
createQueue(formData)
|
||||
.unwrap()
|
||||
.then((data: Queue) => navigate(`/dashboard/queue/${data.id}`))
|
||||
.then(() => messageApi.success(tr("Queue created")))
|
||||
.catch(() => messageApi.error(tr("Failed to create queue")));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="card">
|
||||
<Spin spinning={isLoading}>
|
||||
<Title level={2}>{tr("New queue")}</Title>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
requiredMark={false}
|
||||
onFinish={(formData: CreateQueueRequest) => submit(formData)}
|
||||
>
|
||||
<Form.Item
|
||||
name={"name"}
|
||||
label={tr("Name")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: tr("Please input queue name!"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name={"description"}
|
||||
label={tr("Description") + " " + tr("(optional)")}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Button
|
||||
style={{ width: "100%" }}
|
||||
icon={<PlusCircleOutlined />}
|
||||
type="primary"
|
||||
onClick={() => form.submit()}
|
||||
>
|
||||
{tr("Create")}
|
||||
</Button>
|
||||
</Form>
|
||||
</Spin>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default CreateQueueCard;
|
||||
@ -9,6 +9,7 @@ import {
|
||||
} from "@ant-design/icons";
|
||||
import Title from "antd/es/typography/Title";
|
||||
import tr from "../../config/translation";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
type Queue = {
|
||||
id: string;
|
||||
@ -19,6 +20,7 @@ const QueuesList = (): JSX.Element => {
|
||||
const { data, isLoading } = useGetQueuesQuery({});
|
||||
return (
|
||||
<div className="card">
|
||||
<Link to="/dashboard/new">
|
||||
<Button
|
||||
type="primary"
|
||||
style={{ width: "100%" }}
|
||||
@ -26,6 +28,7 @@ const QueuesList = (): JSX.Element => {
|
||||
>
|
||||
{tr("Create queue")}
|
||||
</Button>
|
||||
</Link>
|
||||
<Title level={2}>{tr("My queues")}</Title>
|
||||
<Spin
|
||||
indicator={<LoadingOutlined style={{ fontSize: 36 }} spin />}
|
||||
|
||||
@ -42,7 +42,6 @@
|
||||
flex-flow: row;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
width: 100%;
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
@ -11,4 +11,9 @@ export const theme: ThemeConfig = {
|
||||
borderRadius: 5,
|
||||
fontFamily: "Comfortaa",
|
||||
},
|
||||
components: {
|
||||
Input: {
|
||||
activeBorderColor: "#001529",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -11,6 +11,8 @@ import DashboardPage from "./DashboardPage";
|
||||
import PropTypes from "prop-types";
|
||||
import { useSelector } from "react-redux";
|
||||
import NotFoundPage from "./NotFoundPage";
|
||||
import CreateQueueCard from "../components/queue/CreateQueueCard";
|
||||
import NewQueuePage from "./NewQueuePage";
|
||||
|
||||
const AppRoutes = ({ children }: { children: ReactNode }) => {
|
||||
store.dispatch(getLocalToken());
|
||||
@ -22,6 +24,7 @@ const AppRoutes = ({ children }: { children: ReactNode }) => {
|
||||
<Routes>
|
||||
<Route path="/" element={<MainPage />} />
|
||||
<Route path="/dashboard" element={<DashboardPage />} />
|
||||
<Route path="/dashboard/new" element={<NewQueuePage />} />
|
||||
<Route path="*" element={<NotFoundPage />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
|
||||
@ -3,6 +3,7 @@ import "./styles.css";
|
||||
import logo from "../../static/logo-full.png";
|
||||
import { Button } from "antd";
|
||||
import tr from "../config/translation";
|
||||
import { isMobile } from "react-device-detect";
|
||||
|
||||
const MainPage = () => {
|
||||
return (
|
||||
@ -13,7 +14,9 @@ const MainPage = () => {
|
||||
</p>
|
||||
<div className="button-box">
|
||||
<Button size="large">{tr("Join a queue")}</Button>
|
||||
<div style={{ width: "3rem" }} />
|
||||
{!(
|
||||
isMobile && window.screen.orientation.type === "portrait-primary"
|
||||
) && <div style={{ width: "3rem" }} />}
|
||||
<Button size="large">{tr("Take a tour")}</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
18
frontend/app/src/pages/NewQueuePage.tsx
Normal file
18
frontend/app/src/pages/NewQueuePage.tsx
Normal file
@ -0,0 +1,18 @@
|
||||
import React from "react";
|
||||
import "./styles.css";
|
||||
import { useSelector } from "react-redux";
|
||||
import { StorePrototype } from "../config/store";
|
||||
import tr from "../config/translation";
|
||||
import Title from "antd/es/typography/Title";
|
||||
import CreateQueueCard from "../components/queue/CreateQueueCard";
|
||||
|
||||
const NewQueuePage = () => {
|
||||
const user = useSelector((state: StorePrototype) => state.auth.user);
|
||||
return user ? (
|
||||
<CreateQueueCard />
|
||||
) : (
|
||||
<Title level={2}>{tr("Log in first")}</Title>
|
||||
);
|
||||
};
|
||||
|
||||
export default NewQueuePage;
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
@keyframes cardPopup {
|
||||
0% {
|
||||
transform: translateY(20%);
|
||||
@ -11,7 +10,7 @@
|
||||
transform: translateY(0);
|
||||
opacity: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
animation: 0.5s ease-out 0s 1 cardPopup;
|
||||
@ -20,10 +19,10 @@
|
||||
margin-right: 1rem;
|
||||
margin-left: 1rem;
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.main {
|
||||
font-family: "Comfortaa", sans-serif;
|
||||
user-select: none;
|
||||
padding: 3rem;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
|
||||
@ -7,6 +7,12 @@ export type CreateQueueRequest = {
|
||||
description: string | null;
|
||||
};
|
||||
|
||||
export type Queue = {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
};
|
||||
|
||||
export const QueueApi = createApi({
|
||||
reducerPath: "QueueApi",
|
||||
baseQuery: fetchBaseQuery({
|
||||
|
||||
Reference in New Issue
Block a user