File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,23 +9,28 @@ export const programCreateProcedure = defineProtectedMutateProcedure({
99 roleIds : [ 'ADMIN' ] ,
1010 inputSchema : z . strictObject ( {
1111 veranstaltungId : z . string ( ) . uuid ( ) ,
12- name : z . string ( ) ,
13- description : z . string ( ) ,
14- location : z . string ( ) ,
15- responsible : z . string ( ) ,
16- startingAt : z . date ( ) ,
17- endingAt : z . date ( ) ,
12+ data : z . object ( {
13+ name : z . string ( ) ,
14+ description : z . string ( ) ,
15+ location : z . string ( ) ,
16+ responsible : z . string ( ) ,
17+ startingAt : z . date ( ) ,
18+ endingAt : z . date ( ) ,
19+ } ) ,
1820 } ) ,
19- handler : async ( { input } ) => {
20- if ( dayjs ( input . endingAt ) . isBefore ( input . startingAt ) ) {
21+ handler : async ( { input : { veranstaltungId , data } } ) => {
22+ if ( dayjs ( data . endingAt ) . isBefore ( data . startingAt ) ) {
2123 throw new TRPCError ( {
2224 code : 'BAD_REQUEST' ,
2325 message : 'Das Enddatum kann nicht vor dem Startdatum liegen.' ,
2426 } )
2527 }
2628
2729 await prisma . programmPunkt . create ( {
28- data : input ,
30+ data : {
31+ ...data ,
32+ veranstaltungId : veranstaltungId ,
33+ } ,
2934 } )
3035 } ,
3136} )
Original file line number Diff line number Diff line change 1+ import { z } from 'zod'
2+ import prisma from '../../prisma.js'
3+ import { defineProtectedMutateProcedure } from '../../types/defineProcedure.js'
4+
5+ export const programDeleteProcedure = defineProtectedMutateProcedure ( {
6+ key : 'delete' ,
7+ roleIds : [ 'ADMIN' ] ,
8+ inputSchema : z . strictObject ( {
9+ programId : z . string ( ) . uuid ( ) ,
10+ } ) ,
11+ handler : async ( { input : { programId } } ) => {
12+ await prisma . programmPunkt . delete ( {
13+ where : {
14+ id : programId ,
15+ } ,
16+ } )
17+ } ,
18+ } )
Original file line number Diff line number Diff line change 1+ import { TRPCError } from '@trpc/server'
2+ import dayjs from 'dayjs'
3+ import { z } from 'zod'
4+ import prisma from '../../prisma.js'
5+ import { defineProtectedMutateProcedure } from '../../types/defineProcedure.js'
6+
7+ export const programEditProcedure = defineProtectedMutateProcedure ( {
8+ key : 'edit' ,
9+ roleIds : [ 'ADMIN' ] ,
10+ inputSchema : z . strictObject ( {
11+ programId : z . string ( ) . uuid ( ) ,
12+ data : z . object ( {
13+ name : z . string ( ) ,
14+ description : z . string ( ) ,
15+ location : z . string ( ) ,
16+ responsible : z . string ( ) ,
17+ startingAt : z . date ( ) ,
18+ endingAt : z . date ( ) ,
19+ } ) ,
20+ } ) ,
21+ handler : async ( { input : { programId, data } } ) => {
22+ if ( dayjs ( data . endingAt ) . isBefore ( data . startingAt ) ) {
23+ throw new TRPCError ( {
24+ code : 'BAD_REQUEST' ,
25+ message : 'Das Enddatum kann nicht vor dem Startdatum liegen.' ,
26+ } )
27+ }
28+
29+ await prisma . programmPunkt . update ( {
30+ where : {
31+ id : programId ,
32+ } ,
33+ data : data ,
34+ } )
35+ } ,
36+ } )
Original file line number Diff line number Diff line change 1+ import { z } from 'zod'
2+ import prisma from '../../prisma.js'
3+ import { defineProtectedMutateProcedure } from '../../types/defineProcedure.js'
4+
5+ export const programGetProcedure = defineProtectedMutateProcedure ( {
6+ key : 'get' ,
7+ roleIds : [ 'ADMIN' ] ,
8+ inputSchema : z . strictObject ( {
9+ programId : z . string ( ) . uuid ( ) ,
10+ } ) ,
11+ handler : async ( { input } ) => {
12+ return await prisma . programmPunkt . findUniqueOrThrow ( {
13+ where : {
14+ id : input . programId ,
15+ } ,
16+ select : {
17+ name : true ,
18+ description : true ,
19+ location : true ,
20+ responsible : true ,
21+ startingAt : true ,
22+ endingAt : true ,
23+ } ,
24+ } )
25+ } ,
26+ } )
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export const programListProcedure = defineProtectedQueryProcedure({
1414 veranstaltungId : input . veranstaltungId ,
1515 } ,
1616 select : {
17+ id : true ,
1718 name : true ,
1819 description : true ,
1920 location : true ,
Original file line number Diff line number Diff line change 22import { mergeRouters } from '../../trpc.js'
33import { programSearchLocationProcedure , programSearchResponsiblesProcedure } from './program.autocomplete.js'
44import { programCreateProcedure } from './program.create.js'
5+ import { programDeleteProcedure } from './program.delete.js'
6+ import { programEditProcedure } from './program.edit.js'
7+ import { programGetProcedure } from './program.get.js'
58import { programListProcedure } from './program.list.js'
69
710// Import Routes here - do not delete this line
811
912export const programRouter = mergeRouters (
13+ // Queries
1014 programListProcedure ,
11- programCreateProcedure ,
15+ programGetProcedure ,
1216 programSearchLocationProcedure ,
13- programSearchResponsiblesProcedure
17+ programSearchResponsiblesProcedure ,
18+
19+ // Mutations
20+ programCreateProcedure ,
21+ programEditProcedure ,
22+ programDeleteProcedure
1423 // Add Routes here - do not delete this line
1524)
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export const veranstaltungPublicGetProcedure = definePublicQueryProcedure({
1919 ort : true ,
2020 programmPunkte : {
2121 select : {
22+ id : true ,
2223 name : true ,
2324 description : true ,
2425 location : true ,
Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ const people = [
5252 role: ' Contributor' ,
5353 imageUrl: ' https://avatars.githubusercontent.com/u/16214836?v=4' ,
5454 },
55+ {
56+ name: ' Silas Jakubzik' ,
57+ role: ' Contributor' ,
58+ imageUrl: ' https://avatars.githubusercontent.com/u/115188138?v=4' ,
59+ },
5560 {
5661 name: ' CODEANKER' ,
5762 role: ' Sponsor' ,
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments