Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs #44

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/assets/Logomark.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="Improve communication within your university with Ticket System, a groundbreaking startup with a centralized platform for submitting complaints and suggestions. Enhance student-faculty-administration interaction by streamlining the process, fostering transparency, and ensuring efficient resolution. Join us in revolutionizing university communication today!"
/>
<title>TreS</title>
</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"loginButton": "Log in",
"password": "Password",
"createButton": "Create ticket",
"signup": "Sign Up",
"profile": "Profile",
"error": "Error",
"noAssignee": "no assignee",
Expand Down
1 change: 0 additions & 1 deletion public/locales/ua/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"loginButton": "Увійти",
"password": "Пароль",
"createButton": "Створити тікет",
"signup": "Реєстрація",
"profile": "Профіль",
"error": "Помилка",
"noAssignee": "ніким не розглядається",
Expand Down
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CssBaseline, ThemeProvider } from "@mui/material";
import CssBaseline from "@mui/material/CssBaseline";
import ThemeProvider from "@mui/material/styles/ThemeProvider";

import { Router } from "./Router";

Expand Down
1 change: 1 addition & 0 deletions src/Pages/Bookmarks/Bookmarks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Bookmarks: FC = () => {

return (
<MyTicketPage
title={"bookmarks"}
useGetQuery={getTickets}
isLoading={isLoading}
isSuccess={isSuccess}
Expand Down
10 changes: 7 additions & 3 deletions src/Pages/CreateTicketForm/CreateTicketForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { useEffect, useState, FC } from "react";
import { useTranslation } from "react-i18next";
import { useForm } from "react-hook-form";

import { Grid, Typography, useTheme } from "@mui/material";
import Grid from "@mui/material/Grid";
import Typography from "@mui/material/Typography";
import useTheme from "@mui/material/styles/useTheme";

import { QueueSelect } from "./components/QueueSelect";
import { TicketTitleInput } from "./components/TicketTitleInput";
Expand Down Expand Up @@ -40,8 +42,10 @@ const CreateTicketForm: FC = () => {
};

const onSubmit = (data: ICreateTicketRequestBody): void => {
createTicket({ body: JSON.stringify(data) });
handleClear();
if (data.queue) {
createTicket({ body: JSON.stringify(data) });
handleClear();
}
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { FC } from "react";
import { useTranslation } from "react-i18next";

import { Button, Grid, useTheme } from "@mui/material";
import Button from "@mui/material/Button";
import Grid from "@mui/material/Grid";
import useTheme from "@mui/material/styles/useTheme";

import IPalette from "../../../../theme/IPalette.interface";

Expand Down
24 changes: 12 additions & 12 deletions src/Pages/CreateTicketForm/components/QueueSelect/QueueSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ import { useEffect, useState, FC } from "react";
import { useTranslation } from "react-i18next";
import { UseFormRegister, UseFormSetValue } from "react-hook-form";

import {
Box,
FormControl,
ListItemText,
ListSubheader,
MenuItem,
Select,
Typography,
useTheme,
SelectChangeEvent,
} from "@mui/material";
import Box from "@mui/material/Box";
import FormControl from "@mui/material/FormControl";
import ListItemText from "@mui/material/ListItemText";
import ListSubheader from "@mui/material/ListSubheader";
import MenuItem from "@mui/material/MenuItem";
import Select from "@mui/material/Select";
import Typography from "@mui/material/Typography";
import { SelectChangeEvent } from "@mui/material/Select";
import useTheme from "@mui/material/styles/useTheme";

import { Loader } from "../../../../components/Loader";

Expand Down Expand Up @@ -99,7 +97,9 @@ const QueueSelect: FC<QueueSelectProps> = ({
<FormControl
fullWidth
sx={{ bgcolor: palette.grey.card }}
{...register("queue")}
{...register("queue", {
required: "This is required.",
})}
>
<Select
id="queue-select"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { FC } from "react";
import { useTranslation } from "react-i18next";
import { UseFormRegister } from "react-hook-form";

import { Box, TextField, Typography, useTheme } from "@mui/material";
import Box from "@mui/material/Box";
import TextField from "@mui/material/TextField";
import Typography from "@mui/material/Typography";
import useTheme from "@mui/material/styles/useTheme";

import IPalette from "../../../../theme/IPalette.interface";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box } from "@mui/material";
import Box from "@mui/material/Box";

const MarkdownControls = () => {
return <Box>markdown</Box>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { useTranslation } from "react-i18next";
import { UseFormRegister } from "react-hook-form";

import TextField from "@mui/material/TextField";
import { Box, Typography, useTheme } from "@mui/material";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import useTheme from "@mui/material/styles/useTheme";

import IPalette from "../../../../theme/IPalette.interface";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { useEffect, FC, Dispatch, SetStateAction, ChangeEvent } from "react";
import { useTranslation } from "react-i18next";
import { UseFormSetValue } from "react-hook-form";

import {
Box,
Checkbox,
FormControl,
FormControlLabel,
FormGroup,
Typography,
useTheme,
} from "@mui/material";
import Box from "@mui/material/Box";
import Checkbox from "@mui/material/Checkbox";
import FormControl from "@mui/material/FormControl";
import FormControlLabel from "@mui/material/FormControlLabel";
import FormGroup from "@mui/material/FormGroup";
import Typography from "@mui/material/Typography";
import useTheme from "@mui/material/styles/useTheme";

import IPalette from "../../../../theme/IPalette.interface";

Expand Down
4 changes: 3 additions & 1 deletion src/Pages/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { FC } from "react";
import { useTranslation } from "react-i18next";

import { Box, Grid, Typography } from "@mui/material";
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";
import Typography from "@mui/material/Typography";

import { ComingSoon } from "../../components/ComingSoon";

Expand Down
1 change: 1 addition & 0 deletions src/Pages/Deleted/Deleted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Deleted: FC = () => {

return (
<MyTicketPage
title={"deleted"}
useGetQuery={getTickets}
isLoading={isLoading}
isSuccess={isSuccess}
Expand Down
4 changes: 3 additions & 1 deletion src/Pages/ErrorPage/ErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { FC } from "react";
import { useTranslation } from "react-i18next";

import { Box, Grid, Typography } from "@mui/material";
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";
import Typography from "@mui/material/Typography";

const ErrorPage: FC = () => {
const { t } = useTranslation();
Expand Down
1 change: 1 addition & 0 deletions src/Pages/Followed/Followed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Followed: FC = () => {

return (
<MyTicketPage
title={"followed"}
useGetQuery={getTickets}
isLoading={isLoading}
isSuccess={isSuccess}
Expand Down
13 changes: 10 additions & 3 deletions src/Pages/FullTicketInfo/FullTicketInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { useEffect, FC } from "react";
import { useTranslation } from "react-i18next";
import { NavLink, useLocation } from "react-router-dom";

import { Box, Grid, useTheme, Typography } from "@mui/material";
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";
import Typography from "@mui/material/Typography";
import useTheme from "@mui/material/styles/useTheme";

import { Loader } from "../../components/Loader";
import { ActionPanel } from "./components/ActionPanel";
Expand Down Expand Up @@ -125,10 +128,14 @@ const FullTicketInfo: FC = () => {
<Grid>
<Typography>{t("fullTicket.author")}</Typography>
<NavLink
to={`${endpoints.profile}/${ticket.creator.user_id}`}
to={
!ticket.creator
? ""
: `${endpoints.profile}/${ticket.creator.user_id}`
}
style={{ color: palette.semantic.info }}
>
@{ticket.creator.login}
@{!ticket.creator ? "anonymous" : ticket.creator.login}
</NavLink>
</Grid>
<Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { FC } from "react";

import { Box, IconButton, useTheme } from "@mui/material";
import Box from "@mui/material/Box";
import IconButton from "@mui/material/IconButton";
import useTheme from "@mui/material/styles/useTheme";

import DoNotDisturbAltOutlinedIcon from "@mui/icons-material/DoNotDisturbAltOutlined";
import BookmarkBorderOutlinedIcon from "@mui/icons-material/BookmarkBorderOutlined";
Expand Down
47 changes: 18 additions & 29 deletions src/Pages/GeneralTickets/GeneralTickets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { useSearchParams } from "react-router-dom";
import { FetchBaseQueryError } from "@reduxjs/toolkit/query/react";
import { SerializedError } from "@reduxjs/toolkit";

import { Box, Grid, Typography, useMediaQuery } from "@mui/material";
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";
import Typography from "@mui/material/Typography";
import useMediaQuery from "@mui/material/useMediaQuery";

import { Ticket } from "../../components/Ticket/Ticket";
import { Loader } from "../../components/Loader";
Expand All @@ -14,6 +17,7 @@ import { CustomPagination } from "../../components/CustomPagination";
import { useGetTicketsMutation } from "../../store/api/tickets/tickets.api";
import { useJwtDecode } from "../../shared/hooks";
import { useGetFacultiesQuery, useGetStatusesQuery } from "../../store/api/api";
import { ITicket } from "../../components/Ticket/ticket.interface";

interface GeneralTicketsPageInfo {
data?: {
Expand All @@ -37,7 +41,7 @@ const GeneralTickets: FC = () => {
const faculties = useGetFacultiesQuery({});
const statuses = useGetStatusesQuery({});

const [searchParams, setSearchParams] = useSearchParams();
const [searchParams] = useSearchParams();
const ticketsPerRow: number = Number(searchParams.get("ticket_per_row")) || 2;
const currentPage: number = Number(searchParams.get("current_page")) || 1;
const facultyQuery: string | null = searchParams.get("faculty");
Expand Down Expand Up @@ -75,34 +79,23 @@ const GeneralTickets: FC = () => {

return {
start_page: currentPage,
tickets_count: 3 * ticketsPerRow,
items_count: 3 * ticketsPerRow,
faculty: facultyId,
status: matchingStatusesId,
};
}, [currentPage, ticketsPerRow, facultyId, searchParams, statuses.isSuccess]);
}, [option, searchParams]);

useEffect(() => {
geTickets({ option: option, body: JSON.stringify(requestBody) }).then(
(res: GeneralTicketsPageInfo): void | PromiseLike<void> => {
if (res.data) {
setTickets(res.data.ticket_list);
setTotalPage(res.data.total_pages);
}
geTickets({
option: option,
body: JSON.stringify(requestBody),
}).then((res: GeneralTicketsPageInfo): void | PromiseLike<void> => {
if (res.data) {
setTickets(res.data.ticket_list);
setTotalPage(res.data.total_pages);
}
);
}, [option, searchParams, geTickets, requestBody]);

const handlePageChange = (page: number) => {
const params = new URLSearchParams(searchParams.toString());

if (params.has("current_page")) {
params.set("current_page", page.toString());
} else {
params.append("current_page", page.toString());
}

setSearchParams(params);
};
});
}, [requestBody]);

return (
<Grid container flexDirection={"column"}>
Expand Down Expand Up @@ -134,11 +127,7 @@ const GeneralTickets: FC = () => {
);
})}
</Grid>
<CustomPagination
total={totalPage}
current={currentPage}
onChange={handlePageChange}
/>
<CustomPagination total={totalPage} current={currentPage} />
</>
) : (
<Typography variant="h1" mt={6}>
Expand Down
14 changes: 7 additions & 7 deletions src/Pages/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import { Dispatch, SetStateAction, useState, FC, Suspense } from "react";
import { Outlet } from "react-router-dom";

import { Box, Grid, useTheme } from "@mui/material";
import Box from "@mui/material/Box";
import useTheme from "@mui/material/styles/useTheme";

import { Header } from "./components/Header";
import { Sidebar } from "./components/Sidebar";

import IPalette from "../../theme/IPalette.interface";
import { Loader } from "../../components/Loader";
import { dimensions } from "../../constants";

interface LayoutProps {
isAuth: boolean;
setIsAuth: Dispatch<SetStateAction<boolean>>;
}

const drawerWidth = 300;

const Layout: FC<LayoutProps> = ({ isAuth, setIsAuth }) => {
const [mobileOpen, setMobileOpen] = useState<boolean>(false);
const { palette }: IPalette = useTheme();

const drawerWidth = dimensions.drawerWidth;

const handleDrawerToggle = (): void => {
setMobileOpen(!mobileOpen);
};

return (
<Grid sx={{ display: "flex" }}>
<Box sx={{ display: "flex" }}>
<Header
isAuth={isAuth}
setIsAuth={setIsAuth}
drawerWidth={drawerWidth}
handleDrawerToggle={handleDrawerToggle}
/>

<Sidebar
mobileOpen={mobileOpen}
drawerWidth={drawerWidth}
handleDrawerToggle={handleDrawerToggle}
/>
<Box
Expand Down Expand Up @@ -67,7 +67,7 @@ const Layout: FC<LayoutProps> = ({ isAuth, setIsAuth }) => {
<Outlet />
</Suspense>
</Box>
</Grid>
</Box>
);
};

Expand Down
Loading