Skip to content

Commit

Permalink
fix: access map value
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasFalkowsky committed Jan 25, 2024
1 parent 9f08349 commit fccd826
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 3 additions & 2 deletions common/achievement/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getAchievementState, renderAchievementWithContext, transformPrismaJson
import { evaluateAchievement } from './evaluate';
import { getAchievementImageURL } from './util';

export async function getUserAchievementsWithTemplates(user: User) {
async function getUserAchievementsWithTemplates(user: User) {
const userAchievementsWithTemplates = await prisma.user_achievement.findMany({
where: { userId: user.userID, AND: { template: { isActive: true } } },
include: { template: true },
Expand Down Expand Up @@ -191,7 +191,7 @@ const assembleAchievementData = async (userAchievements: achievements_with_templ

// TODO: create a function to get the course image path for an array given templateIds. If the result of this function is undefined, use the template image.

return {
const res = {
id: userAchievements[currentAchievementIndex].id,
name: currentAchievementTemplate.name,
subtitle: currentAchievementTemplate.subtitle,
Expand Down Expand Up @@ -226,6 +226,7 @@ const assembleAchievementData = async (userAchievements: achievements_with_templ
actionName: currentAchievementTemplate.actionName,
actionRedirectLink: currentAchievementTemplate.actionRedirectLink,
};
return res;
};

export { getUserAchievements, getFurtherAchievements, getNextStepAchievements, getAchievementById };
4 changes: 1 addition & 3 deletions common/achievement/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ async function getTemplatesByMetrics(metricsForAction: Metric[]) {

async function getTemplatesWithCourseRelation(): Promise<achievement_template[]> {
const templatesByCourseRelation = await getAchievementTemplates(TemplateSelectEnum.BY_COURSE_RELATION);
const courseTemplates: achievement_template[] = templatesByCourseRelation
? Array.from(templatesByCourseRelation[achievement_template_for_enum.Course])
: [];
const courseTemplates: achievement_template[] = templatesByCourseRelation ? templatesByCourseRelation.get(achievement_template_for_enum.Course) : [];

return courseTemplates;
}
Expand Down

0 comments on commit fccd826

Please sign in to comment.