File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { type NextRequest } from 'next/server' ;
22import { handleError } from '@/lib/utils/errors.utils' ;
3- import PositionTagService from '@/lib/services/position- tag.service' ;
3+ import TagService from '@/lib/services/tag.service' ;
44import { createTagSchema } from '@/lib/schemas/tag.schema' ;
55import { getSession } from '@/lib/utils/auth.utils' ;
66
77export async function GET ( ) {
88 try {
99 const session = await getSession ( ) ;
10- const tags = await PositionTagService . getPositionTagsByOrgId ( session . activeOrganizationId ) ;
10+ const tags = await TagService . getPositionTagsByOrgId ( session . activeOrganizationId ) ;
1111 return Response . json ( { data : tags } , { status : 200 } ) ;
1212 } catch ( err ) {
1313 return handleError ( err ) ;
@@ -20,7 +20,7 @@ export async function POST(request: NextRequest) {
2020 const body = await request . json ( ) ;
2121 const parsed = createTagSchema . parse ( body ) ;
2222
23- const tag = await PositionTagService . createPositionTag (
23+ const tag = await TagService . createPositionTag (
2424 parsed . name ,
2525 session . activeOrganizationId ,
2626 parsed . colorHexCode
Original file line number Diff line number Diff line change 11import { type NextRequest } from 'next/server' ;
22import { handleError } from '@/lib/utils/errors.utils' ;
3- import TaskTemplateTagService from '@/lib/services/task-template- tag.service' ;
3+ import TagService from '@/lib/services/tag.service' ;
44import { createTagSchema } from '@/lib/schemas/tag.schema' ;
55import { getSession } from '@/lib/utils/auth.utils' ;
66
77export async function GET ( ) {
88 try {
99 const session = await getSession ( ) ;
10- const tags = await TaskTemplateTagService . getTaskTemplateTagsByOrgId (
10+ const tags = await TagService . getTaskTemplateTagsByOrgId (
1111 session . activeOrganizationId
1212 ) ;
1313 return Response . json ( { data : tags } , { status : 200 } ) ;
@@ -22,7 +22,7 @@ export async function POST(request: NextRequest) {
2222 const body = await request . json ( ) ;
2323 const parsed = createTagSchema . parse ( body ) ;
2424
25- const tag = await TaskTemplateTagService . createTaskTemplateTag (
25+ const tag = await TagService . createTaskTemplateTag (
2626 parsed . name ,
2727 session . activeOrganizationId ,
2828 parsed . colorHexCode
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import { prisma } from '@/lib/prisma' ;
2+ import { TaskTemplateTag , type PositionTag } from '@/generated/prisma' ;
3+
4+ async function getPositionTagsByOrgId ( orgId : string ) : Promise < PositionTag [ ] > {
5+ return prisma . positionTag . findMany ( {
6+ where : { orgId } ,
7+ orderBy : { name : 'asc' } ,
8+ } ) ;
9+ }
10+
11+ async function createPositionTag (
12+ name : string ,
13+ orgId : string ,
14+ colorHexCode : string
15+ ) : Promise < PositionTag > {
16+ return prisma . positionTag . create ( {
17+ data : {
18+ name,
19+ orgId,
20+ colorHexCode,
21+ } ,
22+ } ) ;
23+ }
24+
25+ async function getTaskTemplateTagsByOrgId ( orgId : string ) : Promise < TaskTemplateTag [ ] > {
26+ return prisma . taskTemplateTag . findMany ( {
27+ where : { orgId } ,
28+ orderBy : { name : 'asc' } ,
29+ } ) ;
30+ }
31+
32+ async function createTaskTemplateTag (
33+ name : string ,
34+ orgId : string ,
35+ colorHexCode : string
36+ ) : Promise < TaskTemplateTag > {
37+ return prisma . taskTemplateTag . create ( {
38+ data : {
39+ name,
40+ orgId,
41+ colorHexCode,
42+ } ,
43+ } ) ;
44+ }
45+
46+ const TagService = {
47+ getPositionTagsByOrgId,
48+ createPositionTag,
49+ getTaskTemplateTagsByOrgId,
50+ createTaskTemplateTag,
51+ } ;
52+ export default TagService ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments