Skip to content
Merged

2.3.0 #301

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
8 changes: 8 additions & 0 deletions apps/api/src/meilisearch/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ export async function updateMeiliPerson(person: MeiliPerson) {
}
}

export async function deleteMeiliPerson(id: number) {
try {
await meilisearchClient.index(searchIndex).deleteDocument(id)
} catch (error) {
console.error('deleteMeiliPerson', error, id)
}
}

export async function syncAllPersonsToMeili() {
await meilisearchClient.index(searchIndex).updateSettings(updateSettings)
await meilisearchClient.updateIndex(searchIndex, { primaryKey: 'id' })
Expand Down
20 changes: 20 additions & 0 deletions apps/api/src/services/anmeldung/anmeldungPublicCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { definePublicMutateProcedure } from '../../types/defineProcedure.js'
import logActivity from '../../util/activity.js'
import { sendMail } from '../../util/mail.js'
import { getPersonCreateData, personSchema } from '../person/schema/person.schema.js'
import { updateMeiliPerson } from '../../meilisearch/person.js'

export const inputSchema = z.strictObject({
token: z.string().optional(),
Expand Down Expand Up @@ -118,9 +119,28 @@ export const anmeldungPublicCreateProcedure = definePublicMutateProcedure({
data: personData,
select: {
id: true,
firstname: true,
lastname: true,
birthday: true,
email: true,
gliederung: {
select: {
id: true,
name: true,
},
},
},
})

await updateMeiliPerson({
id: person.id,
firstname: person.firstname,
lastname: person.lastname,
birthday: person.birthday,
email: person.email,
gliederung: person.gliederung,
})

const accessToken = randomUUID()
const assignmentCode = ctx.authenticated ? null : randomUUID()
const anmeldung = await prisma.anmeldung.create({
Expand Down
25 changes: 23 additions & 2 deletions apps/api/src/services/person/personPatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { defineProtectedMutateProcedure } from '../../types/defineProcedure.js'

import { getPersonCreateData, personSchemaOptional } from './schema/person.schema.js'
import { TRPCError } from '@trpc/server'
import { updateMeiliPerson } from '../../meilisearch/person.js'

export const personVerwaltungPatchProcedure = defineProtectedMutateProcedure({
key: 'patch',
Expand Down Expand Up @@ -47,15 +48,35 @@ export const personVerwaltungPatchProcedure = defineProtectedMutateProcedure({
personId: input.id,
},
})

return prisma.person.update({
const person = await prisma.person.update({
where: {
id: input.id,
},
data: await getPersonCreateData(input.data),
select: {
id: true,
firstname: true,
lastname: true,
birthday: true,
email: true,
gliederung: {
select: {
id: true,
name: true,
},
},
},
})

await updateMeiliPerson({
id: person.id,
firstname: person.firstname,
lastname: person.lastname,
birthday: person.birthday,
email: person.email,
gliederung: person.gliederung,
})

return person
},
})
6 changes: 5 additions & 1 deletion apps/api/src/services/person/personVerwaltungRemove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import z from 'zod'

import prisma from '../../prisma.js'
import { defineProtectedMutateProcedure } from '../../types/defineProcedure.js'
import { deleteMeiliPerson } from '../../meilisearch/person.js'

export const personVerwaltungRemoveProcedure = defineProtectedMutateProcedure({
key: 'verwaltungRemove',
Expand All @@ -11,10 +12,13 @@ export const personVerwaltungRemoveProcedure = defineProtectedMutateProcedure({
id: z.number().int(),
}),
async handler(options) {
return prisma.person.delete({
await prisma.person.delete({
where: {
id: options.input.id,
},
})

await deleteMeiliPerson(options.input.id)
return options.input.id
},
})
11 changes: 6 additions & 5 deletions apps/frontend/src/components/GlobalSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const { state: searchResults, execute: searchAPI } = useAsyncState(
aria-hidden="true"
/>
<ComboboxInput
auto-focus
class="h-12 w-full border-0 bg-transparent !pl-11 pr-4 text-gray-900 placeholder:text-gray-400 focus:ring-0 focus:border-0 sm:text-sm"
placeholder="Suchen..."
@change="search($event.target.value)"
Expand Down Expand Up @@ -167,14 +168,14 @@ const { state: searchResults, execute: searchAPI } = useAsyncState(
<li
:class="[
'flex cursor-default select-none items-center rounded-md px-3 py-2',
active && 'bg-primary-600 cursor-pointer group',
active && 'bg-primary-50 cursor-pointer group',
]"
>
<UsersIcon
:class="['h-6 w-6 flex-none text-gray-400 group-hover:text-white dark:text-white']"
:class="['h-6 w-6 flex-none text-gray-400 dark:text-white text-gray-400']"
aria-hidden="true"
/>
<div class="ml-3 flex-auto truncate highlight dark:text-white group-hover:text-white">
<div :class="['ml-3 flex-auto truncate highlight text-gray-900']">
<!-- eslint-disable vue/no-v-html -->
<span
class="mr-1"
Expand All @@ -197,7 +198,7 @@ const { state: searchResults, execute: searchAPI } = useAsyncState(
</div>
<span
v-if="active"
class="ml-3 flex-none text-primary-100"
class="ml-3 flex-none text-primary-600"
>öffnen</span
>
</li>
Expand Down Expand Up @@ -267,7 +268,7 @@ const { state: searchResults, execute: searchAPI } = useAsyncState(
<style scoped lang="scss">
:deep(.highlight) {
em {
@apply text-primary-600 group-hover:text-white not-italic border-b-2 border-primary-600 group-hover:border-white;
@apply text-primary-600 not-italic border-b-2 border-primary-600;
}
}
</style>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "codeanker-project",
"author": "CODEANKER GmbH",
"version": "2.2.0",
"version": "2.3.0",
"description": "",
"license": "CC-BY-3.0-DE",
"workspaces": [
Expand Down
Loading