project page connected to API without authentication. Undefined data Errors handled

This commit is contained in:
Ruidy Nemausat 2020-02-21 12:00:27 +01:00
parent 4b43486c16
commit 5d0c8edacd
5 changed files with 134 additions and 142 deletions

View file

@ -7,7 +7,9 @@ type IProps = {
};
export const ActivityCollection: FC<IProps> = ({ activities, filterText }) => {
return (
return activities === undefined ? (
<></>
) : (
<>
<ul className="collection">
{activities

View file

@ -6,7 +6,9 @@ interface AvatarListProps {
}
export const AvatarList: FC<AvatarListProps> = ({ users }) => {
return (
return users === undefined ? (
<></>
) : (
<>
{users.map((user: User, i: number) => (
<img

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,3 @@
export class Constants {
static getProjectURI: string = "/api/projects";
static getProjectURI: string = "/api/v1/projects";
}

View file

@ -1,7 +1,5 @@
import { Ticket } from "../types/Ticket";
import { Project } from "../types/Project";
// import { Constants } from "../utils/Constants";
// import { User } from "../types/User";
import { AppFile } from "../types/AppFile";
import { Activity } from "../types/Activity";
import { User } from "../types/User";
@ -20,17 +18,6 @@ export default class ProjectVM {
public files: AppFile[];
public activities: Activity[];
/**
* getMembers
*/
// public getMembers(): string {
// let res: Promise<Response> = fetch(
// `${Constants.getProjectURI}/${this.id}/members`
// );
// return JSON.stringify(res);
// // res.json();
// }
public constructor(project: Project) {
this.id = project.id;
this.title = project.title;
@ -38,8 +25,12 @@ export default class ProjectVM {
this.users = project.users;
this.value = project.progression;
this.tickets = project.tickets;
this.ticketsTotalCount = this.tickets.length;
this.ticketsDone = this.tickets.filter(t => t.status === "Done").length;
this.ticketsTotalCount =
this.tickets === undefined ? 0 : this.tickets.length;
this.ticketsDone =
this.tickets === undefined
? 0
: this.tickets.filter(t => t.status === "Done").length;
this.files = project.files;
this.activities = project.activities;
this.remainingDays = getRemainingdays(project.plannedEnding);