Skip to content
Merged

2.3.0 #300

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions apps/api/src/routes/exports/archives/photos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { randomUUID } from 'node:crypto'
import prisma from '../../../prisma.js'
import { openFileStream } from '../../../services/file/helpers/getFileUrl.js'
import { sheetAuthorize } from '../sheets/sheets.schema.js'
import { z } from 'zod'

const querySchema = z.object({
mode: z.enum(['group', 'flat']),
})

export async function veranstaltungPhotoArchive(ctx: Context) {
const authorization = await sheetAuthorize(ctx)
Expand All @@ -13,6 +18,7 @@ export async function veranstaltungPhotoArchive(ctx: Context) {
}

const { query, gliederung } = authorization
const { mode } = querySchema.parse(ctx.query)

const anmeldungen = await prisma.anmeldung.findMany({
where: {
Expand Down Expand Up @@ -54,6 +60,7 @@ export async function veranstaltungPhotoArchive(ctx: Context) {
},
person: {
select: {
id: true,
firstname: true,
lastname: true,
photo: true,
Expand Down Expand Up @@ -90,9 +97,11 @@ export async function veranstaltungPhotoArchive(ctx: Context) {
const stream = await openFileStream(person.photo)

const directory = `Fotos Teilnehmende ${unterveranstaltung.veranstaltung.name}/${unterveranstaltung.gliederung.name}`
const name = `${person.firstname} ${person.lastname}.${mime.getExtension(person.photo.mimetype ?? 'text/plain')}`
const basename = mode === 'group' ? `${person.firstname} ${person.lastname}` : person.id
const extension = mime.getExtension(person.photo.mimetype ?? 'text/plain')

zip.append(stream, {
name: `${directory}/${name}`,
name: mode === 'group' ? `${directory}/${basename}.${extension}` : `${person.photo.id}.${extension}`,
date: person.photo.createdAt,
})
}
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/exports/sheets/teilnehmendenliste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export async function veranstaltungTeilnehmendenliste(ctx: Context) {

Status: AnmeldungStatusMapping[anmeldung.status].human,
Anmeldedatum: anmeldung.createdAt,
Foto: anmeldung.person.photoId ? 'Ja' : 'Nein',
'Foto ID': anmeldung.person.photoId ?? '',

Geschlecht: anmeldung.person.gender ? GenderMapping[anmeldung.person.gender].human : '',
Vorname: anmeldung.person.firstname,
Expand Down
8 changes: 8 additions & 0 deletions apps/api/src/services/anmeldung/anmeldungGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ const select = {
unterveranstaltung: {
select: {
id: true,
beschreibung: true,
gliederung: {
select: {
id: true,
name: true,
edv: true,
},
},
veranstaltung: {
select: {
id: true,
Expand Down
69 changes: 54 additions & 15 deletions apps/api/src/services/anmeldungLink/anmeldeLink.list.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,53 @@
import { z } from 'zod'
import { definePublicQueryProcedure } from '../../types/defineProcedure.js'
import { defineOrderBy } from '../../types/defineOrderBy.js'
import { defineProtectedQueryProcedure } from '../../types/defineProcedure.js'
import client from '../../prisma.js'
import { Role, Prisma } from '@prisma/client'
import { ZPaginationSchema } from '../../types/defineQuery.js'
import type { Context } from '../../context.js'

export const anmeldungLinkListProcedure = definePublicQueryProcedure({
const filterSchema = z.discriminatedUnion('type', [
z.strictObject({
type: z.literal('veranstaltung'),
veranstaltungId: z.number(),
}),
z.strictObject({
type: z.literal('unterveranstaltung'),
unterveranstaltungId: z.number(),
}),
])

type FilterSchema = z.infer<typeof filterSchema>

function getWhere(ctx: Context, filter: FilterSchema): Prisma.AnmeldungLinkWhereInput {
if (filter.type === 'veranstaltung') {
return {
unterveranstaltung: {
veranstaltungId: filter.veranstaltungId,
},
}
} else if (filter.type === 'unterveranstaltung') {
return {
unterveranstaltungId: filter.unterveranstaltungId,
}
}
throw new Error('Invalid filter type')
}

export const anmeldungLinkListProcedure = defineProtectedQueryProcedure({
key: 'list',
roleIds: [Role.ADMIN, Role.GLIEDERUNG_ADMIN, Role.USER],
inputSchema: z.strictObject({
unterveranstaltungId: z.number().int(),
pagination: ZPaginationSchema,
filter: filterSchema,
orderBy: defineOrderBy(['usedAt', 'createdBy', 'comment']),
}),
handler: async ({ input: { unterveranstaltungId } }) => {
async handler({ ctx, input }) {
const { skip, take } = input.pagination
const result = await client.anmeldungLink.findMany({
where: {
unterveranstaltungId,
},
skip,
take,
where: getWhere(ctx, input.filter),
orderBy: {
createdAt: 'desc',
},
Expand All @@ -20,6 +56,7 @@ export const anmeldungLinkListProcedure = definePublicQueryProcedure({
createdAt: true,
usedAt: true,
comment: true,
accessToken: true,
createdBy: {
select: {
person: {
Expand All @@ -32,6 +69,8 @@ export const anmeldungLinkListProcedure = definePublicQueryProcedure({
},
anmeldung: {
select: {
id: true,
createdAt: true,
person: {
select: {
firstname: true,
Expand All @@ -47,15 +86,15 @@ export const anmeldungLinkListProcedure = definePublicQueryProcedure({
},
})

export const anmeldungLinkCountProcedure = definePublicQueryProcedure({
export const anmeldungLinkCountProcedure = defineProtectedQueryProcedure({
key: 'count',
roleIds: [Role.ADMIN, Role.GLIEDERUNG_ADMIN, Role.USER],
inputSchema: z.strictObject({
unterveranstaltungId: z.number().int(),
filter: filterSchema,
}),
handler: ({ input: { unterveranstaltungId } }) =>
client.anmeldungLink.count({
where: {
unterveranstaltungId,
},
}),
handler: ({ ctx, input }) => {
return client.anmeldungLink.count({
where: getWhere(ctx, input.filter),
})
},
})
17 changes: 0 additions & 17 deletions apps/frontend/src/components/UIComponents/TwoRowText.vue

This file was deleted.

14 changes: 8 additions & 6 deletions apps/frontend/src/components/UnterveranstaltungenTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { apiClient } from '@/api'
import BasicInput from '@/components/BasicInputs/BasicInput.vue'
import { UnterveranstaltungTypeMapping, type RouterInput, type RouterOutput } from '@codeanker/api'
import { type TGridColumn } from '@codeanker/datagrid'
import TwoRowText from './UIComponents/TwoRowText.vue'
import DataGridDoubleLineCell from './DataGridDoubleLineCell.vue'

const props = defineProps<{
veranstaltungId?: number
Expand All @@ -33,11 +33,13 @@ const columns = computed<TGridColumn<TUnterveranstaltungData, TUnterveranstaltun
{
field: 'veranstaltung.name',
title: 'Veranstaltung',
cell: TwoRowText,
cellProps: (_, { content }) => ({
title: content.veranstaltung.name,
subtitle: content.beschreibung.split(' ').slice(0, 5).join(' '),
}),
cell: DataGridDoubleLineCell,
cellProps: (formattedValue, row) => {
return {
title: row.content.veranstaltung.name,
message: row.content.beschreibung.split(' ').slice(0, 5).join(' '),
}
},
},
{
field: 'gliederung.name',
Expand Down
Loading
Loading