-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
128 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,38 @@ | ||
import React, {useContext, useState} from "react"; | ||
import {User} from "../../types"; | ||
import React, { useContext, useState } from "react"; | ||
import { User } from "../../types"; | ||
|
||
interface IUserContext { | ||
user: User, | ||
isAdmin: boolean, | ||
user: User; | ||
isAdmin: boolean; | ||
} | ||
|
||
const defaultContext: IUserContext = { | ||
user: {} as User, | ||
isAdmin: false, | ||
} | ||
user: {} as User, | ||
isAdmin: false, | ||
}; | ||
|
||
const UserContext = React.createContext<IUserContext>(defaultContext); | ||
|
||
export const UserProvider = ({ fetchedUser, children }: {fetchedUser: User, children: any}) => { | ||
const [user, setUser] = useState(fetchedUser); | ||
const [isAdmin, setIsAdmin] = useState(fetchedUser.roles.includes("admin")); | ||
export const UserProvider = ({ | ||
fetchedUser, | ||
children, | ||
}: { | ||
fetchedUser: User; | ||
children: any; | ||
}) => { | ||
const [user, setUser] = useState(fetchedUser); | ||
const [isAdmin, setIsAdmin] = useState(fetchedUser.roles.includes("admin")); | ||
|
||
return ( | ||
<UserContext.Provider | ||
value={{ | ||
user, | ||
isAdmin | ||
}} | ||
> | ||
{children} | ||
</UserContext.Provider> | ||
); | ||
return ( | ||
<UserContext.Provider | ||
value={{ | ||
user, | ||
isAdmin, | ||
}} | ||
> | ||
{children} | ||
</UserContext.Provider> | ||
); | ||
}; | ||
|
||
export const useUserContext = () => useContext(UserContext); | ||
export const useUserContext = () => useContext(UserContext); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,4 +103,4 @@ export type User = { | |
familyName?: string; | ||
email?: string; | ||
preferredUsername?: string; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
import {formatDate, formatDateTime} from "./DateUtil"; | ||
import { formatDate, formatDateTime } from "./DateUtil"; | ||
|
||
describe('DateUtil', () => { | ||
describe("DateUtil", () => { | ||
const dateString = "2023-01-01T15:11:54.000Z"; | ||
|
||
const dateString = '2023-01-01T15:11:54.000Z' | ||
it("should format date and time with trailing zeros", () => { | ||
const dateString = "2023-01-01T01:01:54.000Z"; | ||
const formattedDateTime = formatDateTime(dateString); | ||
expect(formattedDateTime).toStrictEqual("01-01-2023 02:01"); | ||
}); | ||
|
||
it('should format date and time with trailing zeros', () => { | ||
const dateString = '2023-01-01T01:01:54.000Z'; | ||
const formattedDateTime = formatDateTime(dateString); | ||
expect(formattedDateTime).toStrictEqual('01-01-2023 02:01') | ||
}); | ||
it("should format date", () => { | ||
const formattedDate = formatDate(dateString); | ||
expect(formattedDate).toStrictEqual("01-01-2023"); | ||
}); | ||
|
||
it('should format date', () => { | ||
const formattedDate = formatDate(dateString); | ||
expect(formattedDate).toStrictEqual('01-01-2023'); | ||
}); | ||
|
||
it('should format date and time', () => { | ||
const formattedDateTime = formatDateTime(dateString); | ||
expect(formattedDateTime).toStrictEqual('01-01-2023 16:11') | ||
}); | ||
}); | ||
it("should format date and time", () => { | ||
const formattedDateTime = formatDateTime(dateString); | ||
expect(formattedDateTime).toStrictEqual("01-01-2023 16:11"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
import {useLocation} from "react-router-dom"; | ||
import { useLocation } from "react-router-dom"; | ||
import tapirLogo from "../assets/tapir.png"; | ||
import {Box, Typography} from "@mui/material"; | ||
import { Box, Typography } from "@mui/material"; | ||
import React from "react"; | ||
|
||
const NotFoundPage = () => { | ||
return ( | ||
<Box sx={{ margin: "auto" }}> | ||
return ( | ||
<Box sx={{ margin: "auto" }}> | ||
<Typography variant={"h2"} textAlign={"center"}> | ||
404 - Page not found | ||
</Typography> | ||
<center> | ||
<img alt={"Tapir logo"} src={tapirLogo} /> | ||
</center> | ||
</Box> | ||
); | ||
}; | ||
|
||
<Typography variant={"h2"} textAlign={"center"}> | ||
404 - Page not found | ||
</Typography> | ||
<center><img alt={"Tapir logo"} src={tapirLogo} /></center> | ||
</Box> | ||
) | ||
} | ||
|
||
export default NotFoundPage | ||
export default NotFoundPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters