Skip to content

Commit

Permalink
[CHORE] - Improve formatting on frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
nulzo committed Nov 30, 2023
1 parent 163c74e commit 8495b73
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 56 deletions.
10 changes: 5 additions & 5 deletions frontend/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
presets: [
'@babel/preset-env',
['@babel/preset-react', { runtime: 'automatic' }],
],
};
presets: [
"@babel/preset-env",
["@babel/preset-react", { runtime: "automatic" }],
],
};
6 changes: 3 additions & 3 deletions frontend/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
collectCoverage: true,
coverageReporters: ['text', 'cobertura'],
}
collectCoverage: true,
coverageReporters: ["text", "cobertura"],
};
6 changes: 3 additions & 3 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions frontend/src/API/authenticateRequests.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import axios from "axios";

function getCookie(name: string) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(";").shift();
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(";").shift();
}

export default function fetchOrCreateUser(data: any) {

Check warning on line 9 in frontend/src/API/authenticateRequests.ts

View workflow job for this annotation

GitHub Actions / run-npm

Unexpected any. Specify a different type
const csrftoken = getCookie("csrftoken");
return axios
.post("api/authenticate/", data, {
headers: {
"X-CSRFToken": csrftoken,
},
})
.then((res) => console.log(res.data))
.catch((err) => console.log(err));
const csrftoken = getCookie("csrftoken");
return axios
.post("api/authenticate/", data, {
headers: {
"X-CSRFToken": csrftoken,
},
})
.then((res) => console.log(res.data))
.catch((err) => console.log(err));
}
7 changes: 4 additions & 3 deletions frontend/src/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ export default function Root() {
// eslint-disable-next-line
const tickets = useFetchTicket("new", "?status=NEW");
if (isAuthenticated) {
// eslint-disable-next-line
const user = fetchOrCreateUser({
"name": account?.name,
"email": account?.username,
"MSOID": account?.idTokenClaims?.oid
name: account?.name,
email: account?.username,
MSOID: account?.idTokenClaims?.oid,
});
}
return (
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/components/forms/TicketForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ export default function TicketForm() {
className={cn(
"w-full md:w-[35vw] lg:w-[30vw] xl:w-[40vw] justify-between",
!field.value &&
"text-muted-foreground font-normal",
"text-muted-foreground font-normal",
)}
>
{field.value
? professors?.data.find(
(professor: any) =>
professor.professor_id === field.value,
)?.full_name
(professor: any) =>
professor.professor_id === field.value,
)?.full_name
: "select a professor"}
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0" />
</Button>
Expand Down Expand Up @@ -287,13 +287,13 @@ export default function TicketForm() {
className={cn(
"w-full md:w-[35vw] lg:w-[30vw] xl:w-[40vw] justify-between",
!field.value &&
"text-muted-foreground font-normal",
"text-muted-foreground font-normal",
)}
>
{field.value
? courses?.data.find(
(course: any) => course.id === field.value,
)?.course_code
(course: any) => course.id === field.value,
)?.course_code
: "select a course"}
<CaretSortIcon
key="course_sort_icon"
Expand Down Expand Up @@ -390,14 +390,14 @@ export default function TicketForm() {
className={cn(
"w-full md:w-[35vw] lg:w-[30vw] xl:w-[40vw] justify-between",
!field.value &&
"text-muted-foreground font-normal",
"text-muted-foreground font-normal",
)}
>
{field.value
? issues?.data.find(
(issue: any) =>
issue.issue_id === field.value,
)?.problem_type
(issue: any) =>
issue.issue_id === field.value,
)?.problem_type
: "select an issue"}
<CaretSortIcon
key="issue_sort_icon"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/navigation/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function Sidebar({ isPopout = false }: any) {
shapeRendering={shape_rendering}
/>
}
// notification={Object(useQueryClient().getQueryData(['new-ticket'])).length !== 0}
// notification={Object(useQueryClient().getQueryData(['new-ticket'])).length !== 0}
/>
<Navlink
className="w-full justify-start"
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/components/tickets/Ticket.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { CardDescription, CardTitle } from "@/components/ui/card";
import { Label } from "@/components/ui/label";
import TutorTicketForm from "@/components/forms/TutorTicketForm";
import { BIOIIcon, CISTIcon, CSCIIcon, CYBRIcon, ISQAIcon } from "@/components/assets/DepartmentIcons";
import {
// BIOIIcon,
// CISTIcon,
CSCIIcon,
// CYBRIcon,
// ISQAIcon,
} from "@/components/assets/DepartmentIcons";
import { CheckIcon, CircleDashedIcon, CircleIcon, XIcon } from "lucide-react";

export default function Ticket({ ticket }: any) {
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/forms/TicketForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ export default function TicketForm() {
className={cn(
"w-full md:w-[35vw] lg:w-[30vw] xl:w-[40vw] justify-between",
!field.value &&
"text-muted-foreground font-normal",
"text-muted-foreground font-normal",
)}
>
{field.value
? professors?.data.find(
(professor: any) =>
professor.professor_id === field.value,
)?.full_name
(professor: any) =>
professor.professor_id === field.value,
)?.full_name
: "select a professor"}
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0" />
</Button>
Expand Down Expand Up @@ -287,13 +287,13 @@ export default function TicketForm() {
className={cn(
"w-full md:w-[35vw] lg:w-[30vw] xl:w-[40vw] justify-between",
!field.value &&
"text-muted-foreground font-normal",
"text-muted-foreground font-normal",
)}
>
{field.value
? courses?.data.find(
(course: any) => course.id === field.value,
)?.course_code
(course: any) => course.id === field.value,
)?.course_code
: "select a course"}
<CaretSortIcon
key="course_sort_icon"
Expand Down Expand Up @@ -390,14 +390,14 @@ export default function TicketForm() {
className={cn(
"w-full md:w-[35vw] lg:w-[30vw] xl:w-[40vw] justify-between",
!field.value &&
"text-muted-foreground font-normal",
"text-muted-foreground font-normal",
)}
>
{field.value
? issues?.data.find(
(issue: any) =>
issue.issue_id === field.value,
)?.problem_type
(issue: any) =>
issue.issue_id === field.value,
)?.problem_type
: "select an issue"}
<CaretSortIcon
key="issue_sort_icon"
Expand Down
1 change: 0 additions & 1 deletion frontend/src/views/HomeView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fetchOrCreateUser from "@/API/authenticateRequests";
import Header from "@/components/typography/Header";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/views/LoginView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { Link } from "@radix-ui/themes";
import UNO from "@/components/assets/UNO";
import { useAccount, useIsAuthenticated } from "@azure/msal-react";
import { useIsAuthenticated } from "@azure/msal-react";
import { useMsal } from "@azure/msal-react";
import { loginRequest } from "../authConfig";
import MicrosoftIcon from "@/components/assets/MicrosoftIcon";
import { useNavigate } from "react-router-dom";

interface UserAuthFormProps extends React.HTMLAttributes<HTMLDivElement> { }
interface UserAuthFormProps extends React.HTMLAttributes<HTMLDivElement> {}

export default function LoginView({ className, ...props }: UserAuthFormProps) {
const isAuthenticated = useIsAuthenticated();
const { instance, accounts, inProgress } = useMsal();
const account = useAccount(accounts[0] || {});
const { instance } = useMsal();
// const account = useAccount(accounts[0] || {});
const [isAuthCompleted, setIsAuthCompleted] = React.useState(false);
const navigate = useNavigate();

Expand All @@ -33,7 +33,7 @@ export default function LoginView({ className, ...props }: UserAuthFormProps) {
event.preventDefault();
await handleLogin();
setIsAuthCompleted(true);
};
}

return (
<>
Expand Down

0 comments on commit 8495b73

Please sign in to comment.