Skip to content

Commit

Permalink
remove important information user field
Browse files Browse the repository at this point in the history
  • Loading branch information
dhenkel92 committed Aug 16, 2024
1 parent 8f1554a commit 32415fc
Showing 1 changed file with 1 addition and 71 deletions.
72 changes: 1 addition & 71 deletions graphql/user/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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<boolean> {
Expand Down

0 comments on commit 32415fc

Please sign in to comment.