Skip to content

Commit

Permalink
Merge branch 'develop' into chore-remove-gql-from-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jamil314 authored Jan 2, 2025
2 parents 4da8fc9 + d27be1d commit 7b0683c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
7 changes: 3 additions & 4 deletions packages/commons/src/events/ActionDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { z } from 'zod'
const ActionBase = z.object({
createdAt: z.string().datetime(),
createdBy: z.string(),
createdAtLocation: z.string(),
data: z.record(z.string(), z.any())
})

Expand Down Expand Up @@ -60,15 +61,13 @@ const DraftAction = ActionBase.merge(

const CreatedAction = ActionBase.merge(
z.object({
type: z.literal(ActionType.CREATE),
createdAtLocation: z.string()
type: z.literal(ActionType.CREATE)
})
)

const NotifiedAction = ActionBase.merge(
z.object({
type: z.literal(ActionType.NOTIFY),
createdAtLocation: z.string()
type: z.literal(ActionType.NOTIFY)
})
)

Expand Down
12 changes: 8 additions & 4 deletions packages/events/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,22 @@ export const appRouter = router({
notify: publicProcedure.input(NotifyActionInput).mutation((options) => {
return addAction(options.input, {
eventId: options.input.eventId,
createdBy: options.ctx.user.id
createdBy: options.ctx.user.id,
createdAtLocation: options.ctx.user.primaryOfficeId
})
}),
draft: publicProcedure.input(DraftActionInput).mutation((options) => {
return addAction(options.input, {
eventId: options.input.eventId,
createdBy: options.ctx.user.id
createdBy: options.ctx.user.id,
createdAtLocation: options.ctx.user.primaryOfficeId
})
}),
declare: publicProcedure.input(DeclareActionInput).mutation((options) => {
return addAction(options.input, {
eventId: options.input.eventId,
createdBy: options.ctx.user.id
createdBy: options.ctx.user.id,
createdAtLocation: options.ctx.user.primaryOfficeId
})
}),
register: publicProcedure
Expand All @@ -140,7 +143,8 @@ export const appRouter = router({
},
{
eventId: options.input.eventId,
createdBy: options.ctx.user.id
createdBy: options.ctx.user.id,
createdAtLocation: options.ctx.user.primaryOfficeId
}
)
})
Expand Down
9 changes: 7 additions & 2 deletions packages/events/src/service/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ export async function createEvent({

export async function addAction(
input: ActionInput,
{ eventId, createdBy }: { eventId: string; createdBy: string }
{
eventId,
createdBy,
createdAtLocation
}: { eventId: string; createdBy: string; createdAtLocation: string }
) {
const db = await getClient()
const now = new Date().toISOString()
Expand All @@ -115,7 +119,8 @@ export async function addAction(
actions: {
...input,
createdBy,
createdAt: now
createdAt: now,
createdAtLocation
}
}
}
Expand Down

0 comments on commit 7b0683c

Please sign in to comment.