Skip to content

Commit

Permalink
Merge branch 'master' into jxl9/achievements-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
neketka committed Apr 20, 2024
2 parents fca604a + cecf657 commit 2ee06d9
Show file tree
Hide file tree
Showing 40 changed files with 1,462 additions and 720 deletions.
608 changes: 306 additions & 302 deletions admin/package-lock.json

Large diffs are not rendered by default.

40 changes: 36 additions & 4 deletions admin/src/all.dto.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
// 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 AchievementTypeDto =

type AchievementType =
| "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 @@ -19,7 +30,26 @@ type LoginEnrollmentTypeDto =
| "UNDERGRADUATE"
| "GRADUATE"
| "FACULTY"
| "ALUMNI";
| "ALUMNI"
| "GUEST";

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

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

type EventTimeLimitationDto = "LIMITED_TIME" | "PERPETUAL";

Expand All @@ -31,7 +61,8 @@ type UserEnrollmentTypeDto =
| "UNDERGRADUATE"
| "GRADUATE"
| "FACULTY"
| "ALUMNI";
| "ALUMNI"
| "GUEST";

type UserAuthTypeDto = "apple" | "google" | "device";

Expand Down Expand Up @@ -84,7 +115,7 @@ export interface CompletedChallengeDto {
export interface ChallengeDto {
id: string;
name?: string;
location?: string;
location?: ChallengeLocationDto;
description?: string;
points?: number;
imageUrl?: string;
Expand Down Expand Up @@ -155,6 +186,7 @@ export interface EventDto {
requiredMembers?: number;
name?: string;
description?: string;
category?: EventCategoryDto;
timeLimitation?: EventTimeLimitationDto;
endTime?: string;
challenges?: string[];
Expand Down
30 changes: 26 additions & 4 deletions admin/src/components/Challenges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
EntryForm,
EntryModal,
FreeEntryForm,
OptionEntryForm,
MapEntryForm,
NumberEntryForm,
} from "./EntryModal";
Expand All @@ -23,6 +24,7 @@ import {
} from "./ListCard";
import { SearchBar } from "./SearchBar";
import { ServerDataContext } from "./ServerData";
import { ChallengeLocationDto } from "../all.dto";

const ChallengeImage = styled.div<{ url: string }>`
width: calc(100% + 23px);
Expand All @@ -36,6 +38,17 @@ const ChallengeImage = styled.div<{ url: string }>`
`}
`;

const locationOptions = [
"ENG_QUAD",
"ARTS_QUAD",
"AG_QUAD",
"NORTH_CAMPUS",
"WEST_CAMPUS",
"COLLEGETOWN",
"ITHACA_COMMONS",
"ANY",
];

function ChallengeCard(props: {
challenge: ChallengeDto;
onUp: () => void;
Expand Down Expand Up @@ -75,7 +88,11 @@ function ChallengeCard(props: {
function makeForm(): EntryForm[] {
return [
{ name: "Location", latitude: 42.447546, longitude: -76.484593 },
{ name: "Location Description", characterLimit: 2048, value: "" },
{
name: "Location Description",
options: locationOptions,
value: 0,
},
{ name: "Name", characterLimit: 256, value: "" },
{ name: "Description", characterLimit: 2048, value: "" },
{ name: "Points", characterLimit: 2048, min: 1, max: 1000, value: 50 },
Expand All @@ -94,8 +111,11 @@ function toForm(challenge: ChallengeDto) {
},
{
name: "Location Description",
characterLimit: 2048,
value: challenge.location ?? "",
options: locationOptions,
value:
challenge.location !== undefined
? locationOptions.indexOf(challenge.location)
: 0,
},
{ name: "Name", characterLimit: 256, value: challenge.name ?? "" },
{
Expand Down Expand Up @@ -138,7 +158,9 @@ function fromForm(
return {
id,
name: (form[2] as FreeEntryForm).value,
location: (form[1] as FreeEntryForm).value,
location: locationOptions[
(form[1] as OptionEntryForm).value
] as ChallengeLocationDto,
description: (form[3] as FreeEntryForm).value,
points: (form[4] as NumberEntryForm).value,
imageUrl: (form[5] as FreeEntryForm).value,
Expand Down
67 changes: 52 additions & 15 deletions admin/src/components/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ import { ServerDataContext } from "./ServerData";
import { compareTwoStrings } from "string-similarity";
import { EventDto } from "../all.dto";
import { AlertModal } from "./AlertModal";
import { EventCategoryDto } from "../all.dto";

const categoryOptions = [
"ENG_QUAD",
"ARTS_QUAD",
"AG_QUAD",
"NORTH_CAMPUS",
"WEST_CAMPUS",
"COLLEGETOWN",
"ITHACA_COMMONS",
"ANY",
];

function EventCard(props: {
event: EventDto;
Expand All @@ -43,8 +55,12 @@ 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 =
categoryInput[0] + categoryInput.substring(1).toLowerCase();

const affirmOfBool = (val: boolean) => (val ? "Yes" : "No");

Expand Down Expand Up @@ -72,10 +88,9 @@ function EventCard(props: {
Time Limitation: <b>{timeLimitation}</b> <br />
Challenge Count: <b>{props.event.challenges?.length}</b> <br />
Difficulty: <b>{difficultyMode}</b> <br />
Category: <b>{categoryType}</b> <br />
Publicly Visible: <b>{affirmOfBool(!!props.event.indexable)}</b>{" "}
<br />
Latitude: <b>{props.event.latitudeF}</b>, Longitude:{" "}
<b>{props.event.longitudeF}</b> <br />
</ListCardBody>
<ListCardButtons>
<HButton onClick={props.onDelete}>DELETE</HButton>
Expand All @@ -88,10 +103,16 @@ function EventCard(props: {
);
}

// Default Form Creation
function makeForm() {
return [
{ name: "Name", characterLimit: 256, value: "" },
{ name: "Description", characterLimit: 2048, value: "" },
{
name: "Category",
options: categoryOptions,
value: 1,
},
{ name: "Required Members", value: -1, min: -1, max: 99 },
{
name: "Time Limitation",
Expand All @@ -101,39 +122,55 @@ function makeForm() {
{
name: "Difficulty",
options: ["Easy", "Normal", "Hard"],
value: 1,
value: 0,
},
{ name: "Publicly Visible", options: ["No", "Yes"], value: 0 },
{ name: "Available Until", date: new Date("2050") },
] as EntryForm[];
}

// Form to DTO Conversion
function fromForm(form: EntryForm[], id: string): EventDto {
return {
id,
requiredMembers: (form[2] as NumberEntryForm).value,
requiredMembers: (form[3] as NumberEntryForm).value,
timeLimitation:
(form[3] as OptionEntryForm).value === 0 ? "PERPETUAL" : "LIMITED_TIME",
(form[4] as OptionEntryForm).value === 0 ? "PERPETUAL" : "LIMITED_TIME",
name: (form[0] as FreeEntryForm).value,
description: (form[1] as FreeEntryForm).value,
indexable: (form[5] as OptionEntryForm).value === 1,
endTime: (form[6] as DateEntryForm).date.toUTCString(),

category: categoryOptions[
(form[2] as OptionEntryForm).value
] as EventCategoryDto,

indexable: (form[6] as OptionEntryForm).value === 1,
endTime: (form[7] as DateEntryForm).date.toUTCString(),
challenges: [],
difficulty:
(form[4] as OptionEntryForm).value === 0
(form[5] as OptionEntryForm).value === 0
? "Easy"
: (form[4] as OptionEntryForm).value === 1
? "Normal"
: "Hard",
: (form[5] as OptionEntryForm).value === 1
? "Normal"
: "Hard",

latitudeF: 0,
longitudeF: 0,
};
}

// DTO to Form Conversion
function toForm(event: EventDto) {
return [
{ name: "Name", characterLimit: 256, value: event.name },
{ name: "Description", characterLimit: 2048, value: event.description },
{
name: "Category",
options: categoryOptions,
value:
event.category !== undefined
? categoryOptions.indexOf(event.category)
: 0,
},
{
name: "Required Members",
value: event.requiredMembers,
Expand All @@ -152,8 +189,8 @@ function toForm(event: EventDto) {
event.difficulty === "Easy"
? 0
: event.difficulty === "Normal"
? "Normal"
: "Hard",
? 1
: 2,
},
{
name: "Publicly Visible",
Expand Down
5 changes: 5 additions & 0 deletions game/assets/icons/back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions game/assets/icons/dropdown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions game/assets/images/details_progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions game/assets/images/interests_progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions game/assets/images/register_progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2ee06d9

Please sign in to comment.