mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-06 00:36:39 +00:00
use switch statement in error controller. Added submit button in modal form. Changed appusers endpoint to users
This commit is contained in:
parent
d6d46f2850
commit
056849e51c
9 changed files with 56 additions and 13 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -8,4 +8,3 @@ app.db*
|
|||
app.db
|
||||
client/node_modules
|
||||
client/src/pages/TestPage.tsx
|
||||
Scripts/
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ using Microsoft.AspNetCore.Authorization;
|
|||
|
||||
namespace TicketManager.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[Route("api/v1/[controller]")]
|
||||
// [Authorize]
|
||||
[Route("api/v1/users")]
|
||||
[ApiController]
|
||||
public class UsersController : ControllerBase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,3 +46,4 @@
|
|||
- [ ] logging
|
||||
- [ ] check useRef, useReducer, dispatch
|
||||
- [ ] error page redirect when offline.
|
||||
- [ ] ticket/files/activities list placeholders when empty
|
||||
|
|
|
|||
1
Scripts/apiQueries.sh
Executable file
1
Scripts/apiQueries.sh
Executable file
|
|
@ -0,0 +1 @@
|
|||
curl --insecure https://localhost:5001/api/v1/
|
||||
1
Scripts/authentication.sh
Executable file
1
Scripts/authentication.sh
Executable file
|
|
@ -0,0 +1 @@
|
|||
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer
|
||||
|
|
@ -11,14 +11,14 @@ export const Modal: FC<IProps> = ({ handleClose, show, children }) => {
|
|||
return (
|
||||
<div className="modal" style={showHideStyle}>
|
||||
<div className="modal-content">{children}</div>
|
||||
{/* <div className="modal-footer">
|
||||
<div className="modal-footer">
|
||||
<button
|
||||
className="modal-close waves-effect waves-green btn-flat"
|
||||
onClick={handleClose}
|
||||
type="submit"
|
||||
className="modal-close waves-effect waves-green btn"
|
||||
>
|
||||
close
|
||||
Done
|
||||
</button>
|
||||
</div> */}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
import React, { FC, useState, ChangeEvent } from "react";
|
||||
import React, { FC, useState, ChangeEvent, useEffect } from "react";
|
||||
import { Modal } from "./Modal";
|
||||
import { AvatarList } from "./AvatarList";
|
||||
import { User } from "../types/User";
|
||||
import { FilterBar } from "./FilterBar";
|
||||
import { HttpResponse } from "../types/HttpResponse";
|
||||
import { get } from "../utils/http";
|
||||
import { Constants } from "../utils/Constants";
|
||||
|
||||
interface IProps {
|
||||
show: boolean;
|
||||
|
|
@ -17,6 +20,32 @@ export const UsersModal: FC<IProps> = ({ show, handleClose, users }) => {
|
|||
) => {
|
||||
setFilterText(e.target.value);
|
||||
};
|
||||
const [allUsers, setAllUsers] = useState();
|
||||
|
||||
async function httpGet(): Promise<void> {
|
||||
try {
|
||||
const response: HttpResponse<User> = await get<User>(
|
||||
`${Constants.usersURI}`
|
||||
);
|
||||
if (response.parsedBody !== undefined) {
|
||||
setAllUsers(response.parsedBody);
|
||||
// setIsLoading(false);
|
||||
}
|
||||
} catch (ex) {
|
||||
// setHasError(true);
|
||||
// setError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
// if (id !== undefined) {
|
||||
httpGet();
|
||||
// } else {
|
||||
// setHasError(true);
|
||||
// setError("Bad Request");
|
||||
// }
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Modal show={show} handleClose={handleClose}>
|
||||
<div className="row valign-wrapper blue">
|
||||
|
|
@ -40,6 +69,7 @@ export const UsersModal: FC<IProps> = ({ show, handleClose, users }) => {
|
|||
handleChange={handleChange}
|
||||
/>
|
||||
</div>
|
||||
{/* <div className="code">{allUsers}</div> */}
|
||||
<form>
|
||||
<ul>
|
||||
{users.map((u: User) => (
|
||||
|
|
|
|||
|
|
@ -6,6 +6,14 @@ interface IProps {
|
|||
}
|
||||
|
||||
export const ErrorController: FC<IProps> = ({ error }) => {
|
||||
if (error === "Not Found") return <Redirect to="/404" />;
|
||||
return <></>;
|
||||
switch (error) {
|
||||
case "Bad Request":
|
||||
return <Redirect to="/400" />;
|
||||
|
||||
case "Not Found":
|
||||
return <Redirect to="/404" />;
|
||||
|
||||
default:
|
||||
return <Redirect to="/404" />;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export const ProjectController: FC = () => {
|
|||
const [project, setProject] = useState<Project>({} as Project);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [hasError, setHasError] = useState(false);
|
||||
const [error, setError] = useState();
|
||||
const [error, setError] = useState("");
|
||||
const { id } = useParams();
|
||||
|
||||
async function httpGet(id: string): Promise<void> {
|
||||
|
|
@ -34,6 +34,9 @@ export const ProjectController: FC = () => {
|
|||
useEffect(() => {
|
||||
if (id !== undefined) {
|
||||
httpGet(id);
|
||||
} else {
|
||||
setHasError(true);
|
||||
setError("Bad Request");
|
||||
}
|
||||
}, [id]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue