Skip to content

Commit ed909f3

Browse files
committed
fix: update party order in AI votes sorting
Adjust the sorting order of parties in the AI votes component by removing 'FDP' from the list. This change ensures the correct representation of parties based on the current voting period. Signed-off-by: Manuel Ruck <git@manuelruck.de>
1 parent 7556354 commit ed909f3

File tree

2 files changed

+43
-23
lines changed

2 files changed

+43
-23
lines changed

bundestag.io/admin/src/components/Procedures/AiVotes.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Maybe, Vote, VoteResult } from '@/__generated/gql-ai/graphql';
22
import { Button, Spin } from 'antd';
33
import { useState } from 'react';
4+
import { getFractions } from './VoteResultsForm';
45

56
export type AiVotesProps = {
67
decision: string;
@@ -37,14 +38,14 @@ export const AiVotes: React.FC<AiVotesProps> = ({ decision, period, onResult })
3738
}).then((data) => data.json());
3839

3940
response.sort((a, b) => {
40-
const partiesOrder = ['Union', 'SPD', 'AfD', 'Grüne', 'FDP', 'Linke'];
41+
const partiesOrder = getFractions(period).map((party) => party.name);
4142
return partiesOrder.indexOf(a.name) - partiesOrder.indexOf(b.name);
4243
});
4344

4445
setVotes(response);
4546
onResult?.(response);
4647
} catch (error) {
47-
console.error(error);
48+
console.error('Error fetching votes:', error);
4849
} finally {
4950
setLoading(false);
5051
}

bundestag.io/admin/src/components/Procedures/VoteResultsForm.tsx

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,45 @@ import { Beschlusstext } from './Beschlusstext';
77
// Ant Design Sub-Elements
88
const FormItem = Form.Item;
99

10-
const FRACTIONS = [
11-
{
12-
name: 'Union',
13-
},
14-
{
15-
name: 'SPD',
16-
},
17-
{
18-
name: 'AfD',
19-
},
20-
{
21-
name: 'Grüne',
22-
},
23-
{
24-
name: 'FDP',
25-
},
26-
{
27-
name: 'Linke',
28-
},
29-
];
10+
export const getFractions = (period: number) =>
11+
period === 21
12+
? [
13+
{
14+
name: 'Union',
15+
},
16+
{
17+
name: 'AfD',
18+
},
19+
{
20+
name: 'SPD',
21+
},
22+
{
23+
name: 'Grüne',
24+
},
25+
{
26+
name: 'Linke',
27+
},
28+
]
29+
: [
30+
{
31+
name: 'Union',
32+
},
33+
{
34+
name: 'SPD',
35+
},
36+
{
37+
name: 'AfD',
38+
},
39+
{
40+
name: 'Grüne',
41+
},
42+
{
43+
name: 'FDP',
44+
},
45+
{
46+
name: 'Linke',
47+
},
48+
];
3049

3150
const VoteResultsForm = ({ data, type, procedureId, period, lastPlenaryProtocoll, title }) => {
3251
const [form] = Form.useForm();
@@ -80,7 +99,7 @@ const VoteResultsForm = ({ data, type, procedureId, period, lastPlenaryProtocoll
8099
});
81100
};
82101

83-
let parties = FRACTIONS;
102+
let parties = getFractions(period);
84103
if (data.partyVotes && data.partyVotes.length > 0) {
85104
parties = data.partyVotes.map(({ party }) => ({
86105
name: party,

0 commit comments

Comments
 (0)