Skip to content

Commit 7267928

Browse files
committed
refactor: migrate constants and TeamGroupsSection to TypeScript
1 parent 5fe9898 commit 7267928

File tree

4 files changed

+87
-57
lines changed

4 files changed

+87
-57
lines changed

src/group-configurations/constants.js

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import PropTypes from 'prop-types';
2+
3+
export interface Usage {
4+
label: string;
5+
url: string;
6+
}
7+
8+
export interface Group {
9+
id: number;
10+
name: string;
11+
usage: Usage[];
12+
version: number;
13+
}
14+
15+
export interface AvailableGroupParameters {
16+
courseId: string;
17+
}
18+
19+
export interface AvailableGroup {
20+
active?: boolean;
21+
description?: string;
22+
groups: Group[];
23+
id: number;
24+
name: string;
25+
parameters?: AvailableGroupParameters;
26+
readOnly?: boolean;
27+
scheme: string;
28+
version: number;
29+
}
30+
31+
export const availableGroupPropTypes = {
32+
active: PropTypes.bool,
33+
description: PropTypes.string,
34+
groups: PropTypes.arrayOf(
35+
PropTypes.shape({
36+
id: PropTypes.number,
37+
name: PropTypes.string,
38+
usage: PropTypes.arrayOf(
39+
PropTypes.shape({
40+
label: PropTypes.string,
41+
url: PropTypes.string,
42+
}),
43+
),
44+
version: PropTypes.number,
45+
}),
46+
),
47+
id: PropTypes.number,
48+
name: PropTypes.string,
49+
parameters: PropTypes.shape({
50+
courseId: PropTypes.string,
51+
}),
52+
readOnly: PropTypes.bool,
53+
scheme: PropTypes.string,
54+
version: PropTypes.number,
55+
};
56+
57+
export const MESSAGE_VALIDATION_TYPES = {
58+
error: 'error',
59+
warning: 'warning',
60+
} as const;
61+
62+
export type MessageValidationType = typeof MESSAGE_VALIDATION_TYPES[keyof typeof MESSAGE_VALIDATION_TYPES];

src/group-configurations/team-groups-section/index.jsx

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
3+
import { AvailableGroup } from '../constants';
4+
import ContentGroupCard from '../content-groups-section/ContentGroupCard';
5+
6+
interface TeamGroupsSectionProps {
7+
availableGroup: AvailableGroup;
8+
}
9+
10+
const TeamGroupsSection: React.FC<TeamGroupsSectionProps> = ({
11+
availableGroup: { groups, name }
12+
}) => (
13+
<div className="mt-2.5">
14+
<h2 className="lead text-black mb-3 configuration-section-name">{name}</h2>
15+
{groups.map((group) => (
16+
<ContentGroupCard
17+
group={group}
18+
key={group.id}
19+
readOnly
20+
/>
21+
))}
22+
</div>
23+
);
24+
25+
export default TeamGroupsSection;

0 commit comments

Comments
 (0)