feat: menambahkan akses slug ke beberapa fungsi yang belum terimplementasi
This commit is contained in:
@@ -16,8 +16,8 @@ const { slugify } = require('../../../helpers/utils/slug');
|
||||
class TaskService {
|
||||
async createTask(idProject, payload, actor = {}) {
|
||||
try {
|
||||
if (!this.isPositiveInteger(idProject)) {
|
||||
return error(new BadRequestError('Project ID must be a valid number'));
|
||||
if (!idProject) {
|
||||
return error(new BadRequestError('Project ID or slug is required'));
|
||||
}
|
||||
|
||||
if (!actor?.id || !this.isMentorOrAdmin(actor)) {
|
||||
@@ -30,18 +30,16 @@ class TaskService {
|
||||
return error(new NotFoundError('Project not found'));
|
||||
}
|
||||
|
||||
const taskSlug = await this.generateUniqueTaskSlug(project.id, payload.title);
|
||||
|
||||
const accessError = await this.validateProjectAccess(idProject, actor);
|
||||
|
||||
const accessError = await this.validateProjectAccess(project.id, actor);
|
||||
if (accessError) {
|
||||
return error(accessError);
|
||||
}
|
||||
|
||||
const taskSlug = await this.generateUniqueTaskSlug(project.id, payload.title);
|
||||
const deadlineAt = this.buildDeadlineAt(payload.deadline_date, payload.specific_time);
|
||||
|
||||
const task = await taskRepository.createTask({
|
||||
id_project: parseInt(idProject),
|
||||
id_project: project.id,
|
||||
slug: taskSlug,
|
||||
title: payload.title,
|
||||
description: payload.description,
|
||||
@@ -63,8 +61,8 @@ class TaskService {
|
||||
|
||||
async getTasksByProject(idProject, actor = {}) {
|
||||
try {
|
||||
if (!this.isPositiveInteger(idProject)) {
|
||||
return error(new BadRequestError('Project ID must be a valid number'));
|
||||
if (!idProject) {
|
||||
return error(new BadRequestError('Project ID or slug is required'));
|
||||
}
|
||||
|
||||
const project = await taskRepository.findProjectByIdOrSlug(idProject);
|
||||
@@ -142,8 +140,8 @@ class TaskService {
|
||||
|
||||
async updateTask(idTask, payload, actor = {}, projectIdentifier = null) {
|
||||
try {
|
||||
if (!this.isPositiveInteger(idTask)) {
|
||||
return error(new BadRequestError('Task ID must be a valid number'));
|
||||
if (!idTask) {
|
||||
return error(new BadRequestError('Task ID or slug is required'));
|
||||
}
|
||||
|
||||
if (!actor?.id || !this.isMentorOrAdmin(actor)) {
|
||||
@@ -212,8 +210,8 @@ class TaskService {
|
||||
|
||||
async deleteTask(idTask, actor = {}, projectIdentifier = null) {
|
||||
try {
|
||||
if (!this.isPositiveInteger(idTask)) {
|
||||
return error(new BadRequestError('Task ID must be a valid number'));
|
||||
if (!idTask) {
|
||||
return error(new BadRequestError('Task ID or slug is required'));
|
||||
}
|
||||
|
||||
if (!actor?.id || !this.isMentorOrAdmin(actor)) {
|
||||
@@ -248,8 +246,8 @@ class TaskService {
|
||||
|
||||
async submitTask(idTask, payload, file, actor = {}, projectIdentifier = null) {
|
||||
try {
|
||||
if (!this.isPositiveInteger(idTask)) {
|
||||
return error(new BadRequestError('Task ID must be a valid number'));
|
||||
if (!idTask) {
|
||||
return error(new BadRequestError('Task ID or slug is required'));
|
||||
}
|
||||
|
||||
if (!actor?.id || actor.role !== 'intern') {
|
||||
|
||||
Reference in New Issue
Block a user