fix(participant exports): fix participants by returning the export type as well as the file path

We previously used the Apollo context but that's really unreliable.

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2023-06-20 12:11:52 +02:00
parent a5a86a5e1b
commit 49b04c9b19
4 changed files with 28 additions and 25 deletions

View File

@@ -482,6 +482,9 @@ export const EXPORT_EVENT_PARTICIPATIONS = gql`
$format: ExportFormatEnum
$roles: [ParticipantRoleEnum]
) {
exportEventParticipants(eventId: $eventId, format: $format, roles: $roles)
exportEventParticipants(eventId: $eventId, format: $format, roles: $roles) {
path
format
}
}
`;

View File

@@ -55,22 +55,16 @@
:key="format"
aria-role="listitem"
@click="
exportParticipants(
{
eventId: event?.id,
format,
},
{ context: { type: format } }
)
exportParticipants({
eventId: event.id ?? '',
format,
})
"
@keyup.enter="
exportParticipants(
{
eventId: event?.id,
format,
},
{ context: { type: format } }
)
exportParticipants({
eventId: event.id ?? '',
format,
})
"
>
<button class="dropdown-button">
@@ -380,15 +374,15 @@ const {
mutate: exportParticipants,
onDone: onExportParticipantsMutationDone,
onError: onExportParticipantsMutationError,
} = useMutation(EXPORT_EVENT_PARTICIPATIONS);
} = useMutation<
{ exportEventParticipants: { path: string; format: string } },
{ eventId: string; format?: exportFormat; roles?: string[] }
>(EXPORT_EVENT_PARTICIPATIONS);
onExportParticipantsMutationDone(({ data, context }) => {
const link =
window.origin +
"/exports/" +
context?.type.toLowerCase() +
"/" +
data?.exportEventParticipants;
onExportParticipantsMutationDone(({ data }) => {
const path = data?.exportEventParticipants?.path;
const format = data?.exportEventParticipants?.format;
const link = window.origin + "/exports/" + format?.toLowerCase() + "/" + path;
console.debug(link);
const a = document.createElement("a");
a.style.display = "none";