Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(service-portal-education): Fix typing #16148

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,28 @@ export const EducationGraduationDetail = () => {
title={`${item.organisation ?? ''} - ${item.periodName ?? ''}`}
labels={{
name: formatMessage(edMessage.courseName),
brautarheiti: formatMessage(edMessage.courseId),
einingar: formatMessage(edMessage.units),
einkunn: formatMessage(edMessage.grade),
dags: formatMessage(edMessage.dateShort),
Staða: formatMessage(edMessage.status),
course: formatMessage(edMessage.courseId),
units: formatMessage(edMessage.units),
grade: formatMessage(edMessage.grade),
date: formatMessage(edMessage.dateShort),
status: formatMessage(edMessage.status),
}}
items={
item.courses?.map((course, i) => ({
id: course?.courseId ?? `${i}`,
name: course?.courseName ?? '',
brautarheiti: course?.courseId ?? '',
einingar: course?.units ?? '',
einkunn: course?.finalgrade ?? '',
dags: formatDate(course?.date ?? ''),
Staða: course?.status ?? '',
course: course?.courseId ?? '',
units: course?.units ?? '',
grade: course?.finalgrade ?? '',
date: formatDate(course?.date ?? ''),
status: course?.status ?? '',
tag: tagSelector(course?.status ?? ''),
})) ?? []
}
footer={{
name: `${formatMessage(edMessage.total)}:`,
brautarheiti: '',
einingar: addArray(
course: '',
units: addArray(
item.courses?.map((item) => item?.units || '') || [],
),
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,28 @@ export const EducationGraduationDetail = () => {
title={`${item.organisation ?? ''} - ${item.periodName ?? ''}`}
labels={{
name: formatMessage(edMessage.courseName),
brautarheiti: formatMessage(edMessage.courseId),
einingar: formatMessage(edMessage.units),
einkunn: formatMessage(edMessage.grade),
dags: formatMessage(edMessage.dateShort),
Staða: formatMessage(edMessage.status),
course: formatMessage(edMessage.courseId),
units: formatMessage(edMessage.units),
grade: formatMessage(edMessage.grade),
date: formatMessage(edMessage.dateShort),
status: formatMessage(edMessage.status),
}}
items={
item.courses?.map((course, i) => ({
id: course?.courseId ?? `${i}`,
name: course?.courseName ?? '',
brautarheiti: course?.courseId ?? '',
einingar: course?.units ?? '',
einkunn: course?.finalgrade ?? '',
dags: formatDate(course?.date ?? ''),
Staða: course?.status ?? '',
course: course?.courseId ?? '',
units: course?.units ?? '',
grade: course?.finalgrade ?? '',
date: formatDate(course?.date ?? ''),
status: course?.status ?? '',
tag: tagSelector(course?.status ?? ''),
})) ?? []
}
footer={{
name: `${formatMessage(edMessage.total)}:`,
brautarheiti: '',
einingar: addArray(
course: '',
units: addArray(
item.courses?.map((item) => item?.units || '') || [],
),
}}
Expand Down
26 changes: 16 additions & 10 deletions libs/service-portal/education/src/utils/tagSelector.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
export const tagSelector = (str: string) => {
const obj = {
Lokið: 'mint',
Ólokið: 'purple',
Metið: 'blue',
M: 'blue',
Féll: 'red',
'Féll á önn': 'red',
}
type ColorValue = 'mint' | 'purple' | 'blue' | 'red'

return (obj as any)?.[str] || 'blue'
export const tagSelector = (str: string): ColorValue => {
switch (str) {
case 'Lokið':
return 'mint'
case 'Ólokið':
return 'purple'
case 'Metið':
case 'M':
return 'blue'
case 'Féll':
case 'Féll á önn':
return 'red'
default:
thorkellmani marked this conversation as resolved.
Show resolved Hide resolved
return 'blue'
}
thorkellmani marked this conversation as resolved.
Show resolved Hide resolved
}
Loading