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
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -7,5 +7,4 @@ app.db*
|
||||||
.DS_Store
|
.DS_Store
|
||||||
app.db
|
app.db
|
||||||
client/node_modules
|
client/node_modules
|
||||||
client/src/pages/TestPage.tsx
|
client/src/pages/TestPage.tsx
|
||||||
Scripts/
|
|
||||||
|
|
@ -9,8 +9,8 @@ using Microsoft.AspNetCore.Authorization;
|
||||||
|
|
||||||
namespace TicketManager.Controllers
|
namespace TicketManager.Controllers
|
||||||
{
|
{
|
||||||
[Authorize]
|
// [Authorize]
|
||||||
[Route("api/v1/[controller]")]
|
[Route("api/v1/users")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class UsersController : ControllerBase
|
public class UsersController : ControllerBase
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -46,3 +46,4 @@
|
||||||
- [ ] logging
|
- [ ] logging
|
||||||
- [ ] check useRef, useReducer, dispatch
|
- [ ] check useRef, useReducer, dispatch
|
||||||
- [ ] error page redirect when offline.
|
- [ ] 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 (
|
return (
|
||||||
<div className="modal" style={showHideStyle}>
|
<div className="modal" style={showHideStyle}>
|
||||||
<div className="modal-content">{children}</div>
|
<div className="modal-content">{children}</div>
|
||||||
{/* <div className="modal-footer">
|
<div className="modal-footer">
|
||||||
<button
|
<button
|
||||||
className="modal-close waves-effect waves-green btn-flat"
|
type="submit"
|
||||||
onClick={handleClose}
|
className="modal-close waves-effect waves-green btn"
|
||||||
>
|
>
|
||||||
close
|
Done
|
||||||
</button>
|
</button>
|
||||||
</div> */}
|
</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 { Modal } from "./Modal";
|
||||||
import { AvatarList } from "./AvatarList";
|
import { AvatarList } from "./AvatarList";
|
||||||
import { User } from "../types/User";
|
import { User } from "../types/User";
|
||||||
import { FilterBar } from "./FilterBar";
|
import { FilterBar } from "./FilterBar";
|
||||||
|
import { HttpResponse } from "../types/HttpResponse";
|
||||||
|
import { get } from "../utils/http";
|
||||||
|
import { Constants } from "../utils/Constants";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
|
|
@ -17,6 +20,32 @@ export const UsersModal: FC<IProps> = ({ show, handleClose, users }) => {
|
||||||
) => {
|
) => {
|
||||||
setFilterText(e.target.value);
|
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 (
|
return (
|
||||||
<Modal show={show} handleClose={handleClose}>
|
<Modal show={show} handleClose={handleClose}>
|
||||||
<div className="row valign-wrapper blue">
|
<div className="row valign-wrapper blue">
|
||||||
|
|
@ -40,6 +69,7 @@ export const UsersModal: FC<IProps> = ({ show, handleClose, users }) => {
|
||||||
handleChange={handleChange}
|
handleChange={handleChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
{/* <div className="code">{allUsers}</div> */}
|
||||||
<form>
|
<form>
|
||||||
<ul>
|
<ul>
|
||||||
{users.map((u: User) => (
|
{users.map((u: User) => (
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,14 @@ interface IProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ErrorController: FC<IProps> = ({ error }) => {
|
export const ErrorController: FC<IProps> = ({ error }) => {
|
||||||
if (error === "Not Found") return <Redirect to="/404" />;
|
switch (error) {
|
||||||
return <></>;
|
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 [project, setProject] = useState<Project>({} as Project);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [hasError, setHasError] = useState(false);
|
const [hasError, setHasError] = useState(false);
|
||||||
const [error, setError] = useState();
|
const [error, setError] = useState("");
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
async function httpGet(id: string): Promise<void> {
|
async function httpGet(id: string): Promise<void> {
|
||||||
|
|
@ -34,6 +34,9 @@ export const ProjectController: FC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id !== undefined) {
|
if (id !== undefined) {
|
||||||
httpGet(id);
|
httpGet(id);
|
||||||
|
} else {
|
||||||
|
setHasError(true);
|
||||||
|
setError("Bad Request");
|
||||||
}
|
}
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue