Skip to content

Commit

Permalink
Fixed build error
Browse files Browse the repository at this point in the history
  • Loading branch information
neketka committed Apr 20, 2024
1 parent 2ee06d9 commit b7fda2f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 64 deletions.
25 changes: 11 additions & 14 deletions admin/src/all.dto.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
// CODE AUTOGENERATED BY npm run updateapi
// IF YOU MODIFY THIS FILE, MAKE SURE TO ALSO MODIFY THE updateapi SCRIPT!
// OTHERWISE YOUR CHANGES MAY BE OVERWRITTEN!

type AchievementType =
type AchievementTypeDto =
| "TotalPoints"
| "TotalChallenges"
| "TotalJourneys"
| "TotalChallengesOrJourneys";

type AchievementLocationTypeDto =
| "ENG_QUAD"
| "ARTS_QUAD"
| "AG_QUAD"
| "NORTH_CAMPUS"
| "WEST_CAMPUS"
| "COLLEGETOWN"
| "ITHACA_COMMONS"
| "ANY";

type AchievementAchievementTypeDto =
| "TOTAL_POINTS"
| "TOTAL_CHALLENGES"
Expand All @@ -33,7 +22,7 @@ type LoginEnrollmentTypeDto =
| "ALUMNI"
| "GUEST";

export type ChallengeLocationDto =
type ChallengeLocationDto =
| "ENG_QUAD"
| "ARTS_QUAD"
| "AG_QUAD"
Expand All @@ -43,7 +32,15 @@ export type ChallengeLocationDto =
| "ITHACA_COMMONS"
| "ANY";

export type EventCategoryDto =
type EventCategory =
| "FOOD"
| "NATURE"
| "HISTORICAL"
| "CAFE"
| "DININGHALL"
| "DORM";

type EventCategoryDto =
| "FOOD"
| "NATURE"
| "HISTORICAL"
Expand Down
14 changes: 5 additions & 9 deletions admin/src/components/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ function EventCard(props: {
props.event.difficulty === "Easy"
? "Easy"
: props.event.difficulty === "Normal"
? "Normal"
: "Hard";
? "Normal"
: "Hard";

let categoryInput = props.event.category as string;
const categoryType =
Expand Down Expand Up @@ -150,8 +150,8 @@ function fromForm(form: EntryForm[], id: string): EventDto {
(form[5] as OptionEntryForm).value === 0
? "Easy"
: (form[5] as OptionEntryForm).value === 1
? "Normal"
: "Hard",
? "Normal"
: "Hard",

latitudeF: 0,
longitudeF: 0,
Expand Down Expand Up @@ -186,11 +186,7 @@ function toForm(event: EventDto) {
name: "Difficulty",
options: ["Easy", "Normal", "Hard"],
value:
event.difficulty === "Easy"
? 0
: event.difficulty === "Normal"
? 1
: 2,
event.difficulty === "Easy" ? 0 : event.difficulty === "Normal" ? 1 : 2,
},
{
name: "Publicly Visible",
Expand Down
20 changes: 9 additions & 11 deletions game/lib/api/game_client_dto.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ enum AchievementTypeDto {
TotalChallengesOrJourneys,
}

enum AchievementLocationTypeDto {
ENG_QUAD,
ARTS_QUAD,
AG_QUAD,
NORTH_CAMPUS,
WEST_CAMPUS,
COLLEGETOWN,
ITHACA_COMMONS,
ANY,
}

enum AchievementAchievementTypeDto {
TOTAL_POINTS,
TOTAL_CHALLENGES,
Expand Down Expand Up @@ -51,6 +40,15 @@ enum ChallengeLocationDto {
ANY,
}

enum EventCategory {
FOOD,
NATURE,
HISTORICAL,
CAFE,
DININGHALL,
DORM,
}

enum EventCategoryDto {
FOOD,
NATURE,
Expand Down
5 changes: 3 additions & 2 deletions server/src/achievement/achievement.dto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ChallengeLocationDto } from '../challenge/challenge.dto';

export enum AchievementTypeDto {
TotalPoints = 'TOTAL_POINTS',
TotalChallenges = 'TOTAL_CHALLENGES',
Expand All @@ -12,9 +14,8 @@ export interface AchievementDto {
name?: string;
description?: string;
imageUrl?: string;
locationType?: string;
locationType?: ChallengeLocationDto;
achievementType?: AchievementTypeDto;
// achievementType?: string;
initialOrganizationId?: string;
}

Expand Down
29 changes: 4 additions & 25 deletions server/src/achievement/achievement.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
AchievementTrackerDto,
UpdateAchievementDataDto,
} from './achievement.dto';
import { ChallengeLocationDto } from '../challenge/challenge.dto';

@Injectable()
export class AchievementService {
Expand Down Expand Up @@ -54,7 +55,7 @@ export class AchievementService {
/** upsert achievement */
async upsertAchievementFromDto(
ability: AppAbility,
achievement: AchievementDto
achievement: AchievementDto,
) {
let ach = await this.prisma.achievement.findFirst({
where: { id: achievement.id },
Expand Down Expand Up @@ -194,30 +195,8 @@ export class AchievementService {
name: ach.name,
description: ach.description,
imageUrl: ach.imageUrl,
locationType:
ach.locationType ==
LocationType.AG_QUAD ? 'AG_QUAD'
: ach.locationType === LocationType.ENG_QUAD
? "ENG_QUAD"
: ach.locationType === LocationType.ARTS_QUAD
? "ARTS_QUAD"
: ach.locationType === LocationType.COLLEGETOWN
? "COLLEGETOWN"
: ach.locationType === LocationType.ITHACA_COMMONS
? "ITHACA_COMMONS"
: ach.locationType === LocationType.NORTH_CAMPUS
? "NORTH_CAMPUS"
: ach.locationType === LocationType.WEST_CAMPUS
? "WEST_CAMPUS"
: ach.locationType === LocationType.ANY
? "ANY"
: "OTHER",
// achievementType: ach.achievementType as AchievementTypeDto,
achievementType:
ach.achievementType === AchievementType.TOTAL_POINTS ? AchievementTypeDto.TotalPoints
: ach.achievementType === AchievementType.TOTAL_CHALLENGES ? AchievementTypeDto.TotalChallenges
: ach.achievementType === AchievementType.TOTAL_JOURNEYS ? AchievementTypeDto.TotalJourneys
: ach.achievementType === AchievementType.TOTAL_CHALLENGES_OR_JOURNEYS ? AchievementTypeDto.TotalChallengesOrJourneys
locationType: ach.locationType as ChallengeLocationDto,
achievementType: ach.achievementType as AchievementTypeDto,
};
}

Expand Down
9 changes: 6 additions & 3 deletions server/src/client/client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import {
import { EventTrackerDto, UpdateEventDataDto } from '../event/event.dto';
import { GroupInviteDto, UpdateGroupDataDto } from '../group/group.dto';
import { UpdateOrganizationDataDto } from '../organization/organization.dto';
import { AchievementTrackerDto, UpdateAchievementDataDto } from '../achievement/achievement.dto';
import {
AchievementTrackerDto,
UpdateAchievementDataDto,
} from '../achievement/achievement.dto';
import { ExtractSubjectType } from '@casl/ability';

export type ClientApiDef = {
Expand Down Expand Up @@ -109,7 +112,7 @@ export class ClientService {
const ability = this.abilityFactory.createForUser(user);
const accessibleObj = await this.abilityFactory.filterInaccessible(
resource.id,
resource.dtoField ? (dto[resource.dtoField] as any) : dto,
resource.dtoField ? (dto as any)[resource.dtoField] : dto,
resource.subject,
ability,
Action.Read,
Expand All @@ -130,4 +133,4 @@ export class ClientService {
}
}
}
}
}

0 comments on commit b7fda2f

Please sign in to comment.