e26a154518
Connects to backend and gets all registered users by role. Enabled editors to see all registered users which wasn't possible.
58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
import { gql } from "@apollo/client";
|
|
import { UserRole } from "../../jwt/jwt";
|
|
|
|
const BasicPersonFragment = gql`
|
|
fragment BasicPersonFragment on Person {
|
|
id
|
|
rowId
|
|
firstName
|
|
lastName
|
|
role
|
|
}
|
|
`;
|
|
|
|
export interface BasicPersonResponse {
|
|
id: string;
|
|
rowId: number;
|
|
firstName: string | null;
|
|
lastName: string | null;
|
|
role: UserRole;
|
|
__typename: "Person";
|
|
}
|
|
|
|
export const GET_PERSONS_SORTED_BY_ROLE = gql`
|
|
query AllPeople {
|
|
editors: allPeople(condition: { role: CANDYMAT_EDITOR }) {
|
|
nodes {
|
|
...BasicPersonFragment
|
|
}
|
|
}
|
|
candidates: allPeople(condition: { role: CANDYMAT_CANDIDATE }) {
|
|
nodes {
|
|
...BasicPersonFragment
|
|
}
|
|
}
|
|
users: allPeople(condition: { role: CANDYMAT_PERSON }) {
|
|
nodes {
|
|
...BasicPersonFragment
|
|
}
|
|
}
|
|
}
|
|
${BasicPersonFragment}
|
|
`;
|
|
|
|
export interface GetPersonsSortedByRoleResponse {
|
|
editors: {
|
|
nodes: Array<BasicPersonResponse>;
|
|
__typename: "PeopleConnection";
|
|
};
|
|
candidates: {
|
|
nodes: Array<BasicPersonResponse>;
|
|
__typename: "PeopleConnection";
|
|
};
|
|
users: {
|
|
nodes: Array<BasicPersonResponse>;
|
|
__typename: "PeopleConnection";
|
|
};
|
|
}
|