Skip to content

Commit

Permalink
Remove 0. klasse
Browse files Browse the repository at this point in the history
Use "Gjest" or "Sosialt medlem" as appropriate.

Remove some very unnecessary string formatting-stuff
  • Loading branch information
henrikhorluck committed Aug 30, 2024
1 parent ff35404 commit 4eee533
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 53 deletions.
11 changes: 0 additions & 11 deletions src/__tests__/fmt.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ interface IProps {
attendee: IPublicAttendee;
}

export const memberDisplay = (attendee: IPublicAttendee): string => {
if (attendee.field_of_study === 'Gjest') {
return 'Gjest';
} else if (attendee.field_of_study === 'Sosialt medlem') {
return 'Sosialt medlem';
} else {
return `${attendee.year_of_study}. klasse`;
}
};

export const Attendee: FC<IProps> = ({ attendee, count }) => {
const specialList = ['mads hermansen'];
return (
Expand Down Expand Up @@ -46,7 +56,7 @@ export const Attendee: FC<IProps> = ({ attendee, count }) => {
</span>
) : null}
</p>
<p>{`${attendee.year_of_study}. klasse`}</p>
<p>{memberDisplay(attendee)}</p>
<div className={style.icon}>
<FontAwesomeIcon icon={attendee.is_visible ? faUserFriends : faUserSecret} fixedWidth />
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/profile/components/Profile/Study/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import { ProfilePageContext } from 'profile/providers/ProfilePage';
import KeyValue from '../KeyValue';
import Progress from './Progress';
import style from './study.less';
import { memberDisplay } from 'profile/components/Settings/SettingsInfo';

export const Study = () => {
const { started_date, year } = useContext(ProfilePageContext);
const profile = useContext(ProfilePageContext);
const { started_date, year } = profile;
const startYear = DateTime.fromISO(started_date).toFormat('y');
return (
<Pane>
<Content title="Studie">
<div className={style.studyText}>
<KeyValue k="Klassetrinn" v={`${year}. Klasse`} />
<KeyValue k="Klassetrinn" v={memberDisplay(profile)} />
<KeyValue k="Startår" v={startYear} />
</div>
<Progress ongoingYear={year} completedYear={year - 1} />
Expand Down
19 changes: 14 additions & 5 deletions src/profile/components/Settings/SettingsInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import React from 'react';
import Markdown from 'common/components/Markdown';
import { Pane } from 'common/components/Panes';
import { getProfile } from 'profile/api';
import { IUserProfile } from 'profile/models/User';
import { IPublicProfile, IUserProfile } from 'profile/models/User';
import { useEffect, useState } from 'react';
import KeyValue from '../Profile/KeyValue';
import fmt from 'profile/utils/stringFormat';

const MAIN_INFO_TEXT = `
# Innstillinger
Expand All @@ -14,6 +13,16 @@ const MAIN_INFO_TEXT = `
`;

export const memberDisplay = (profile: IUserProfile | IPublicProfile): string => {
if (profile.field_of_study === 0) {
return 'Gjest';
} else if (profile.year === 0) {
return 'Sosialt medlem';
} else {
return `${profile.year}. klasse`;
}
};

const SettingsInfo = () => {
const [profile, setProfile] = useState<IUserProfile | undefined>(undefined);

Expand All @@ -31,9 +40,9 @@ const SettingsInfo = () => {
<Markdown source={MAIN_INFO_TEXT} />
{profile ? (
<>
<KeyValue k="Navn" v={fmt('{0} {1}', profile.first_name, profile.last_name)} bold />
<KeyValue k="Klassetrinn" v={fmt('{0}. klasse', profile.year)} bold />
<KeyValue k="Adresse" v={fmt('{0} {1} {2}', profile.address, profile.zip_code, profile.city)} bold />
<KeyValue k="Navn" v={`${profile.first_name} ${profile.last_name}`} bold />
<KeyValue k="Klassetrinn" v={memberDisplay(profile)} bold />
<KeyValue k="Adresse" v={`${profile.address} ${profile.zip_code} ${profile.city}`} bold />
<KeyValue k="Telefon" v={profile.phone_number} bold />
<KeyValue k="Kallenavn" v={profile.nickname} bold />
<KeyValue k="NTNU-brukernavn" v={profile.ntnu_username} bold />
Expand Down
34 changes: 0 additions & 34 deletions src/profile/utils/stringFormat.ts

This file was deleted.

0 comments on commit 4eee533

Please sign in to comment.