Commit 71871b0d authored by “Yevgeniy's avatar “Yevgeniy

Merge branch 'development' of…

Merge branch 'development' of ssh://git.attractor-school.com:30022/apollo64/crm-team-one into task-19-feature-project/week_view
parents 41a1b7ca bd90d3e8
This diff is collapsed.
......@@ -7,18 +7,21 @@
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon",
"start": "npm run build && node build/server.js",
"lint": "eslint . --ext .ts"
"lint": "eslint . --ext .ts",
"fixtures": "ts-node ./src/fixtures.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@faker-js/faker": "^7.6.0",
"@types/node": "^18.11.8",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"eslint": "^8.26.0",
"nodemon": "^2.0.20",
"ts-node": "^10.9.1",
"typeorm-fixtures-cli": "^3.0.1",
"typescript": "^4.8.4"
},
"dependencies": {
......
import { myDataSource } from "./app-data-source";
import { User, UserRole } from "./models/User";
import { faker } from '@faker-js/faker';
import { Task } from "./models/Task";
import { Project } from "./models/Project";
function randomIntFromInterval(min:number, max:number) {
return Math.floor(Math.random() * (max - min + 1) + min)
}
const loadFixtures = async () => {
myDataSource
.initialize()
.then(async () => {
const repositoryTask = myDataSource.getRepository(Task);
await repositoryTask.delete({});
const repositoryUser = myDataSource.getRepository(User);
await repositoryUser.delete({});
const repositoryProject = myDataSource.getRepository(Project);
await repositoryProject.delete({});
console.log('========================== ' + '\n' + 'Data Source has been cleared!' +'\n' + '==========================')
const userRoles = [{role: UserRole.DIRECTOR}, {role: UserRole.SUPERUSER}, {role: UserRole.USER}, {role: UserRole.USER}];
const users = []
for (let i = 0; i < 4; i++) {
const name = faker.name.firstName()
const surname = faker.name.lastName()
const displayName = name + ' ' + surname[0] + '.'
const user = new User()
user.name = name;
user.surname = surname;
user.password = '12345qwert';
user.displayName= displayName;
user.phone = faker.phone.number('+77#########')
user.email = faker.internet.email();
user.role = userRoles[i].role;
user.generateToken()
await user.save();
users.push(user)
}
const tasks = []
type taskFinishType = "opened" | "done" |"failed";
type priorityType = "A" | "B" |"C";
const priorities:priorityType[] = ["A", "B" , "C"]
const accomplish:taskFinishType[] = ["opened", "done" , "failed"]
for (let i = 0; i < 15; i++) {
if (i <= 10) {
const newTask = new Task();
newTask.title = `Buy ${faker.commerce.productName()}`;
newTask.description = faker.random.words(4);
newTask.executors = faker.helpers.arrayElements(users, randomIntFromInterval(0, 3));
newTask.dateTimeDue = faker.date.soon(randomIntFromInterval(1, 15));
newTask.dateTimeStart = faker.date.recent((randomIntFromInterval(0, 8)));
newTask.author = faker.helpers.arrayElement(users);
newTask.accomplish = faker.helpers.arrayElement(accomplish);
newTask.priority = faker.helpers.arrayElement(priorities);
await newTask.save();
tasks.push(newTask)
} else {
const newTask = new Task();
newTask.title = `Buy ${faker.commerce.productName()}`;
newTask.description = faker.random.words(4);
newTask.executors = faker.helpers.arrayElements(users, randomIntFromInterval(0, 3));
newTask.dateTimeDue = null;
newTask.dateTimeStart = null;
newTask.author = faker.helpers.arrayElement(users);
newTask.accomplish = accomplish[0];
newTask.priority = faker.helpers.arrayElement(priorities);
await newTask.save();
tasks.push(newTask)
}
}
console.log('========================== ' + '\n' + 'Fixtures done!' +'\n' + '==========================')
})
.catch((err) => {
console.error("Error during Data Source initialization:", err)
})
};
loadFixtures()
\ No newline at end of file
......@@ -11,7 +11,7 @@ import {
import {User} from './User';
import {Project} from './Project';
type taskFinishType = "open" | "done" |"failed";
type taskFinishType = "opened" | "done" |"failed";
type priorityType = "A" | "B" |"C";
interface ITask{
......
......@@ -43,20 +43,20 @@ interface IUser {
export class User extends BaseEntity implements IUser {
@PrimaryGeneratedColumn("uuid")
id!: string;
@Column({ name: 'name', type: 'varchar', length:20,nullable: false })
@Column({ name: 'name', type: 'varchar', length:30,nullable: false })
name!: string;
@Column({ name: 'surname', type: 'varchar', length:30,nullable: false })
surname!: string;
@Column({ name: 'displayName', type: 'varchar', length:30,nullable: false })
@Column({ name: 'displayName', type: 'varchar', length:35,nullable: false })
displayName!: string;
@Column({ name: 'email', type: 'varchar',length:20, unique: true, nullable: false })
@Column({ name: 'email', type: 'varchar',length:40, unique: true, nullable: false })
@IsEmail()
email!: string;
@Column({ name: 'phone', type: 'varchar',length:10, unique: true, nullable: true})
@Column({ name: 'phone', type: 'varchar',length:15, unique: true, nullable: true})
phone?: string;
@Column({ name: 'token', type: 'varchar',length:100, unique: true, nullable: false })
......
......@@ -44,7 +44,7 @@ export const addTask = (task) => {
try {
await axios.post("/tasks", task, {
headers: {
'Authorization': 'aBhHYW8kXUUzjXlxOwGmg'
'Authorization': 'yjBjcPCQwytwrYo9rRuiK'
}
});
dispatch(addTaskSuccess())
......
......@@ -14,6 +14,7 @@ const tasksReduсer = (state = initialState, action) => {
const newArr = []
action.tasks.forEach((task)=>{
if (task.dateTimeStart && task.dateTimeDue) {
if (new Date(task.dateTimeDue).getTime() - new Date(task.dateTimeStart).getTime() < (4 * 3600000)) {
const dateStart = task.dateTimeStart.split('T')[0]
const timeStart = task.dateTimeStart.split('T')[1]
const timeEnd = task.dateTimeDue.split('T')[1]
......@@ -34,6 +35,7 @@ const tasksReduсer = (state = initialState, action) => {
endMinute: timeEndMinute,
}
} )
}
}
})
return {...state, loading: false, tasks: newArr};
......
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