From 32415fc4e3783db2eed0ae696aeefd74d6888e4d Mon Sep 17 00:00:00 2001 From: Daniel Henkel Date: Tue, 18 Jun 2024 20:02:55 +0200 Subject: [PATCH] remove important information user field --- graphql/user/fields.ts | 72 +----------------------------------------- 1 file changed, 1 insertion(+), 71 deletions(-) diff --git a/graphql/user/fields.ts b/graphql/user/fields.ts index 57470bd97..61d1f9206 100644 --- a/graphql/user/fields.ts +++ b/graphql/user/fields.ts @@ -10,9 +10,8 @@ import { Log, Push_subscription as PushSubscription, notification_channel_enum as NotificationChannelEnum, - Important_information, } from '../generated'; -import { Root, Authorized, FieldResolver, Query, Resolver, Arg, Ctx, ObjectType, Field, Int, createUnionType } from 'type-graphql'; +import { Root, Authorized, FieldResolver, Query, Resolver, Arg, Ctx, ObjectType, Field, Int } from 'type-graphql'; import { UNAUTHENTICATED_USER, loginAsUser } from '../authentication'; import { GraphQLContext } from '../context'; import { Role } from '../authorizations'; @@ -36,7 +35,6 @@ import assert from 'assert'; import { getPushSubscriptions, publicKey } from '../../common/notification/channels/push'; import _ from 'lodash'; import { getUserNotificationPreferences } from '../../common/notification'; -import { AchievementState } from '../../common/achievement/types'; @ObjectType() export class UserContact implements UserContactType { @@ -59,54 +57,6 @@ export class Contact { @Field((_type) => String, { nullable: true }) chatId?: string; } - -@ObjectType() -export class ImportantInformationNew { - @Field((_type) => String) - title: string; - @Field((_type) => String) - description: string; - @Field((_type) => String) - type: 'normal' | 'sequence'; - - @Field((_type) => Int, { nullable: true }) - maxSteps: number | null; - @Field((_type) => Int, { nullable: true }) - finishedSteps: number | null; - // @Field((_type) => important_information_recipients_enum) - @Field((_type) => String) - recipients: 'students' | 'pupils'; - // @Field((_type) => important_information_language_enum) - @Field((_type) => String) - language: 'en' | 'de'; - @Field((_type) => ImportantInformationModal) - modal: typeof ImportantInformationModal; -} - -@ObjectType() -export class ImportantInformationTextModal { - @Field((_type) => String) - text: string; - @Field((_type) => String, { nullable: true }) - navigateTo: string | null; -} - -export const ImportantInformationAchievementModal = Achievement; - -export const ImportantInformationModal = createUnionType({ - name: 'Modal', - types: () => [ImportantInformationAchievementModal, ImportantInformationTextModal] as const, - resolveType: (value) => { - if ('tagline' in value) { - return ImportantInformationAchievementModal; - } - if ('text' in value) { - return ImportantInformationTextModal; - } - return undefined; - }, -}); - @Resolver((of) => UserType) export class UserFieldsResolver { @FieldResolver((returns) => String) @@ -354,26 +304,6 @@ export class UserFieldsResolver { return await getAppointmentsForUser(user, take, skip, cursor, direction); } - @FieldResolver((returns) => [ImportantInformationNew]) - @Authorized(Role.ADMIN, Role.OWNER) - async importantInformations(@Ctx() context: GraphQLContext) { - const achievements = await getUserAchievements(context.user); - return achievements - .filter((a) => a.achievementType === 'SEQUENTIAL' && a.achievementState === AchievementState.ACTIVE) - .map( - (a): ImportantInformationNew => ({ - description: a.description, - title: a.title, - recipients: 'students', - language: 'de', - type: 'sequence', - maxSteps: a.maxSteps, - finishedSteps: a.currentStep, - modal: a, - }) - ); - } - @FieldResolver((returns) => Boolean) @Authorized(Role.ADMIN, Role.OWNER) async hasAppointments(@Root() user: User): Promise {