#58 fixtures fixed to work

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