Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
progof committed Nov 3, 2024
1 parent 60a59e2 commit 95aa3f7
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 387 deletions.
3 changes: 1 addition & 2 deletions backend/src/dayquest/dayquest.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,7 @@ export class DayQuestController {
userId: user.id,
taskId: task_id,
});

console.log("completeTask -> task", task);

return res
.status(200)
.send({ message: "Task completed successfully", task });
Expand Down
26 changes: 0 additions & 26 deletions backend/src/dayquest/dayquest.cron.ts

This file was deleted.

167 changes: 3 additions & 164 deletions backend/src/dayquest/task.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,84 +128,6 @@ export class TasksService {
});
}

// async completeTask(
// db: Database | Transaction,
// options: {
// userId: string;
// taskId: string;
// }
// ) {
// const { taskId, userId } = options;

// const task = (
// await db
// .select()
// .from(habitTasksTable)
// .where(
// and(
// eq(habitTasksTable.id, taskId),
// eq(habitTasksTable.creatorId, userId)
// )
// )
// ).at(0);

// if (!task) {
// throw new HTTPError({ message: "Task not found", status: 404 });
// }

// if (task.creatorId !== userId) {
// throw new HTTPError({
// message: "You are not allowed to complete this task",
// status: 403,
// });
// }


// // Получаем все выполненные задачи пользователя за сегодня в данной категории
// const completedTasks = (
// await db
// .select()
// .from(completedTasksTable)
// .where(
// and(
// eq(completedTasksTable.taskId, taskId),
// eq(completedTasksTable.userId, userId),
// gte(completedTasksTable.completedAt, getStartOfToday())
// )
// )
// ).length > 0;

// if (completedTasks) {
// throw new HTTPError({
// message: "Task is already completed",
// status: 400,
// });
// }

// await db
// .insert(completedTasksTable)
// .values({
// taskId: taskId,
// userId: userId,
// })
// .returning();


// const user = (
// await db.select().from(usersTable).where(eq(usersTable.id, userId))
// ).at(0);

// if (!user) {
// throw new HTTPError({ message: "User not found", status: 404 });
// }

// await db
// .update(usersTable)
// .set({
// score: sql`${usersTable.score} + 1`,
// })
// .where(eq(usersTable.id, userId));
// }

async completeTask(
db: Database | Transaction,
Expand Down Expand Up @@ -327,89 +249,6 @@ export class TasksService {
.where(eq(usersTable.id, userId));
}
}

// async unCompleteTask(
// db: Database | Transaction,
// options: {
// userId: string;
// taskId: string;
// }
// ){
// const { taskId, userId } = options;

// const task = (
// await db
// .select()
// .from(habitTasksTable)
// .where(
// and(
// eq(habitTasksTable.id, taskId),
// eq(habitTasksTable.creatorId, userId)
// )
// )
// ).at(0);

// if (!task) {
// throw new HTTPError({ message: "Task not found", status: 404 });
// }

// if (task.creatorId !== userId) {
// throw new HTTPError({
// message: "You are not allowed to complete this task",
// status: 403,
// });
// }

// const todayStart = getStartOfToday();

// const completedTasks = (
// await db
// .select()
// .from(completedTasksTable)
// .where(
// and(
// eq(completedTasksTable.taskId, taskId),
// eq(completedTasksTable.userId, userId),
// gte(completedTasksTable.completedAt, todayStart),
// )
// )
// ).length > 0;

// if (completedTasks) {
// throw new HTTPError({
// message: "Task is already UnCompleted",
// status: 400,
// });
// }


// await db
// .delete(completedTasksTable)
// .where(
// and(
// eq(completedTasksTable.taskId, taskId),
// eq(completedTasksTable.userId, userId)
// )
// );


// const user = (
// await db.select().from(usersTable).where(eq(usersTable.id, userId))
// ).at(0);

// if (!user) {
// throw new HTTPError({ message: "User not found", status: 404 });

// }

// console.log("unCompleteTask score:",user.score);
// await db
// .update(usersTable)
// .set({
// score: user.score - 1,
// })
// .where(eq(usersTable.id, userId));
// }

async unCompleteTask(
db: Database | Transaction,
Expand Down Expand Up @@ -459,7 +298,7 @@ export class TasksService {
)
).at(0);

if (!completedTask) {
if (completedTask) {
throw new HTTPError({
message: "Task is not completed yet",
status: 400,
Expand Down Expand Up @@ -493,10 +332,10 @@ export class TasksService {
experiencePoints = 1;
break;
case 'MEDIUM':
experiencePoints = 2;
experiencePoints = 1;
break;
case 'HARD':
experiencePoints = 3;
experiencePoints = 1;
break;
default:
experiencePoints = 0; // На случай, если значение сложности некорректное
Expand Down
1 change: 0 additions & 1 deletion backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { DayQuestController } from "@/dayquest/dayquest.controller.js";
import { TasksService } from "@/dayquest/task.service.js";
import { CategoriesService } from "@/dayquest/category.service.js";
import { CommentsService } from "@/dayquest/comment.service.js";
import "@/dayquest/dayquest.cron.js";

import { AuthGoogleService } from "./auth/google/google.service.js";
import { AuthGoogleController } from "./auth/google/google.controller.js";
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/assets/icons/categories.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/src/assets/icons/clipboard-check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from "zod";
import { useForm } from "vee-validate";
import { toTypedSchema } from "@vee-validate/zod";
import { useCreateCategoryMutation } from "@/services/dayquest/category.service";
import { TextField } from "@/components/ui/input";
import { TextArea } from "@/components/ui/text-area/";
import LoaderIcon from "@/assets/icons/loader.svg?component";
import { Button } from "@/components/ui/button";
import { FetchError } from "@/utils/fetch";
Expand Down Expand Up @@ -46,19 +46,21 @@ const onSubmit = handleSubmit((data) => {
</script>

<template>
<DialogTitle class="text-xl font-bold tracking-tight"> DayQuest</DialogTitle>
<DialogDescription class="mt-2 text-sm text-zinc-600">
<DialogTitle class="text-xl font-bold tracking-tight text-blue-500"
>Create category of tasks</DialogTitle
>
<DialogDescription class="my-4 text-sm text-zinc-600">
Create a category of habit or goal that you will develop each day.
</DialogDescription>
<form @submit.prevent="onSubmit" class="flex flex-col gap-3 mt-2">
<TextField
<form @submit.prevent="onSubmit" class="flex flex-col gap-6 mt-2">
<TextArea
name="name"
label="Name"
placeholder="Learn B2 English"
class="text-zinc-700"
/>

<div class="mt-4 flex justify-end border-zinc-200 pt-4">
<div class="flex justify-center border-zinc-200">
<Button
:disabled="!meta.dirty || isPending"
class="relative font-semibold"
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/tasks-table/CreateTaskDialogContent.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { toTypedSchema } from "@vee-validate/zod";
import { useForm, Field } from "vee-validate";
import TextField from "@/components/ui/input/TextField.vue";
import { TextArea } from "@/components/ui/text-area/";
import Button from "@/components/ui/button/Button.vue";
import LoaderIcon from "@/assets/icons/loader.svg?component";
import { DialogTitle, DialogDescription } from "@/components/ui/dialog";
Expand Down Expand Up @@ -64,7 +64,7 @@ const onSubmit = handleSubmit((data) => {

<template>
<div class="flex flex-col">
<DialogTitle class="text-xl font-bold tracking-tight">
<DialogTitle class="text-xl font-bold tracking-tight text-blue-500">
Create task
</DialogTitle>
<DialogDescription class="mt-2 text-sm text-zinc-600">
Expand All @@ -74,7 +74,7 @@ const onSubmit = handleSubmit((data) => {
</DialogDescription>
<form @submit.prevent="onSubmit" class="mt-4 flex flex-col">
<div class="mb-4 flex flex-col gap-3">
<TextField
<TextArea
name="name"
label="Name"
placeholder="Read 5 pages in English"
Expand All @@ -96,7 +96,7 @@ const onSubmit = handleSubmit((data) => {
<SelectTrigger :invalid="!!errorMessage">
<SelectValue placeholder="Select priority" />
</SelectTrigger>
<SelectContent>
<SelectContent class="text-zinc-600">
<SelectItem :value="TASK_PRIORITY.LOW">Low</SelectItem>
<SelectItem :value="TASK_PRIORITY.MEDIUM">Medium</SelectItem>
<SelectItem :value="TASK_PRIORITY.HIGH">High</SelectItem>
Expand All @@ -121,7 +121,7 @@ const onSubmit = handleSubmit((data) => {
<SelectTrigger :invalid="!!errorMessage">
<SelectValue placeholder="Select difficulty" />
</SelectTrigger>
<SelectContent>
<SelectContent class="text-zinc-600">
<SelectItem :value="TASK_DIFFICULTY.EASY">Easy</SelectItem>
<SelectItem :value="TASK_DIFFICULTY.MEDIUM">Medium</SelectItem>
<SelectItem :value="TASK_DIFFICULTY.HARD">Hard</SelectItem>
Expand Down
Loading

0 comments on commit 95aa3f7

Please sign in to comment.