Skip to content

Commit

Permalink
fix: change students query filter (#702)
Browse files Browse the repository at this point in the history
* fix: change students query filter

* fix: add graphql changes

* fix: change table row keys for proper data display
  • Loading branch information
jakubwiczkowski authored Sep 10, 2023
1 parent 789d137 commit 43074e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 52 deletions.
51 changes: 1 addition & 50 deletions apps/web/src/api/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ export type GenericMorph =
| ComponentStudentCouncilFunctions
| Function
| Global
| I18NLocale
| Meeting
| Resolution
| Student
Expand Down Expand Up @@ -281,42 +280,6 @@ export type GlobalInput = {
private_config: InputMaybe<Scalars['JSON']['input']>;
};

export type I18NLocale = {
__typename?: 'I18NLocale';
code: Maybe<Scalars['String']['output']>;
createdAt: Maybe<Scalars['DateTime']['output']>;
name: Maybe<Scalars['String']['output']>;
updatedAt: Maybe<Scalars['DateTime']['output']>;
};

export type I18NLocaleEntity = {
__typename?: 'I18NLocaleEntity';
attributes: Maybe<I18NLocale>;
id: Maybe<Scalars['ID']['output']>;
};

export type I18NLocaleEntityResponse = {
__typename?: 'I18NLocaleEntityResponse';
data: Maybe<I18NLocaleEntity>;
};

export type I18NLocaleEntityResponseCollection = {
__typename?: 'I18NLocaleEntityResponseCollection';
data: Array<I18NLocaleEntity>;
meta: ResponseCollectionMeta;
};

export type I18NLocaleFiltersInput = {
and: InputMaybe<Array<InputMaybe<I18NLocaleFiltersInput>>>;
code: InputMaybe<StringFilterInput>;
createdAt: InputMaybe<DateTimeFilterInput>;
id: InputMaybe<IdFilterInput>;
name: InputMaybe<StringFilterInput>;
not: InputMaybe<I18NLocaleFiltersInput>;
or: InputMaybe<Array<InputMaybe<I18NLocaleFiltersInput>>>;
updatedAt: InputMaybe<DateTimeFilterInput>;
};

export type IdFilterInput = {
and: InputMaybe<Array<InputMaybe<Scalars['ID']['input']>>>;
between: InputMaybe<Array<InputMaybe<Scalars['ID']['input']>>>;
Expand Down Expand Up @@ -746,8 +709,6 @@ export type Query = {
function: Maybe<FunctionEntityResponse>;
functions: Maybe<FunctionEntityResponseCollection>;
global: Maybe<GlobalEntityResponse>;
i18NLocale: Maybe<I18NLocaleEntityResponse>;
i18NLocales: Maybe<I18NLocaleEntityResponseCollection>;
me: Maybe<UsersPermissionsMe>;
meeting: Maybe<MeetingEntityResponse>;
meetings: Maybe<MeetingEntityResponseCollection>;
Expand Down Expand Up @@ -777,16 +738,6 @@ export type QueryFunctionsArgs = {
sort?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
};

export type QueryI18NLocaleArgs = {
id: InputMaybe<Scalars['ID']['input']>;
};

export type QueryI18NLocalesArgs = {
filters: InputMaybe<I18NLocaleFiltersInput>;
pagination?: InputMaybe<PaginationArg>;
sort?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
};

export type QueryMeetingArgs = {
id: InputMaybe<Scalars['ID']['input']>;
};
Expand Down Expand Up @@ -2305,7 +2256,7 @@ export type ResolutionsQueryResult = Apollo.QueryResult<
export const StudentsDocument = gql`
query Students($termId: ID!, $page: Int, $pageSize: Int) {
students(
filters: {}
filters: { functions: { term_of_office: { id: { eq: $termId } } } }
pagination: { page: $page, pageSize: $pageSize }
sort: ["functions.functions.position", "surname", "name"]
) {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/api/queries/students.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
query Students($termId: ID!, $page: Int, $pageSize: Int) {
students(
filters: {}
filters: { functions: { term_of_office: { id: { eq: $termId } } } }
pagination: { page: $page, pageSize: $pageSize }
sort: ["functions.functions.position", "surname", "name"]
) {
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/pages/structure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function OrganisationStructure() {
});

const students = uniqBy(studentsQuery.data?.students.data, 'id');

return (
<Center>
<VStack>
Expand All @@ -84,7 +85,7 @@ function OrganisationStructure() {
</Thead>
<Tbody>
{students.map((student, index) => (
<Tr key={student.id}>
<Tr key={index}>
<Td>
{index +
1 +
Expand All @@ -94,6 +95,10 @@ function OrganisationStructure() {
<Td>{student.attributes.surname}</Td>
<Td>
{student.attributes.functions
.filter(
(func) =>
func.term_of_office.data.id === currentTermId,
)
.at(0)
?.functions.data.map(
({ attributes }) => attributes.name,
Expand Down

0 comments on commit 43074e4

Please sign in to comment.