#58 fixtures fixed to work

parent 4aa1ced5
......@@ -14,6 +14,8 @@ const loadFixtures = async () => {
myDataSource
.initialize()
.then(async () => {
const repositoryMember = myDataSource.getRepository(Member);
await repositoryMember.delete({})
const repositoryTask = myDataSource.getRepository(Task);
await repositoryTask.delete({});
const repositoryProject = myDataSource.getRepository(Project);
......@@ -54,6 +56,8 @@ const loadFixtures = async () => {
newTask.executor = faker.helpers.arrayElement(users);
newTask.dateTimeDue = faker.date.soon(randomIntFromInterval(1, 15));
newTask.dateTimeStart = faker.date.recent((randomIntFromInterval(0, 8)));
newTask.dateTimeDeadLine = faker.date.soon(randomIntFromInterval(1, 15));
newTask.dateTimeFactDeadLine = faker.date.soon(randomIntFromInterval(1, 15));
newTask.author = faker.helpers.arrayElement(users);
newTask.accomplish = faker.helpers.arrayElement(accomplish);
newTask.priority = faker.helpers.arrayElement(priorities);
......@@ -64,8 +68,8 @@ const loadFixtures = async () => {
newTask.title = `Buy ${faker.commerce.productName()}`;
newTask.description = faker.random.words(4);
newTask.executor = faker.helpers.arrayElement(users);
newTask.dateTimeDue = null;
newTask.dateTimeStart = null;
// newTask.dateTimeDue = null;
// newTask.dateTimeStart = null;
newTask.author = faker.helpers.arrayElement(users);
newTask.accomplish = accomplish[0];
newTask.priority = faker.helpers.arrayElement(priorities);
......
......@@ -23,7 +23,8 @@ import {
// workers:User[];
tasks:Task[]|null;
createdAt: Date;
dateDue: Date| null;
active:boolean;
// dateDue: Date| null;
// department:boolean;
members: Member[];
}
......@@ -41,10 +42,13 @@ import {
createdAt!: Date;
@Column({ name: 'color', type: 'varchar', length:100,nullable: true })
color!: string
color!: string;
@Column({ name: 'dateDue', type: Date, default: null })
dateDue!: Date| null;
@Column({ name: 'active',type: 'boolean', default: true })
active!: boolean;
// @Column({ name: 'dateDue', type: Date, default: null })
// dateDue!: Date| null;
// @Column({ name: 'department', type: Boolean,nullable:true ,default: false})
// department!: boolean;
......
......@@ -21,6 +21,8 @@ import {
createdAt: Date;
dateTimeStart:Date| null;
dateTimeDue:Date| null;
dateTimeDeadLine: Date| null;
dateTimeFactDeadLine: Date| null;
accomplish: taskFinishType;
priority: priorityType | null;
author: User;
......@@ -39,9 +41,13 @@ import {
@CreateDateColumn({ name: 'created_at', type: Date, default: new Date() })
createdAt!: Date;
@Column({ name: 'dateTimeStart', type: Date,nullable: true })
dateTimeStart!: Date | null;
dateTimeStart!: Date ;
@Column({ name: 'dateTimeDue', type: Date,nullable: true })
dateTimeDue!: Date | null;
dateTimeDue!: Date ;
@Column({ name: 'dateTimeDeadLine', type: Date,nullable: true })
dateTimeDeadLine!: Date;
@Column({ name: 'dateTimeFactDeadLine', type: Date,nullable: true })
dateTimeFactDeadLine!: Date;
@Column({
type: "enum",
......
......@@ -2,6 +2,7 @@ import express,{Router, Request, Response} from 'express';
import {Project} from '../models/Project';
import {myDataSource} from '../app-data-source';
import { User } from '../models/User';
import { Member, MemberRole } from '../models/Member';
const router:Router = express.Router();
const dataSource = myDataSource;
......@@ -23,12 +24,16 @@ router.post('/', async (req:Request, res:Response): Promise<Response> => {
.select("user")
.from(User, "user")
.where("user.token = :token", { token: token })
.getOne()
.getOne();
if(!user) return res.status(404).send({Message:'user not found'})
const member:Member = new Member;
member.user= user;
member.role= MemberRole.ADMIN;
await member.save();
const project : Project= new Project()
project.title = title;
project.color = color;
project.dateDue = dateDue || null;
project.members=[member]
// project.department = department;
// project.workers = workers|| null;
project.tasks = tasks || null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment