+
Generate Participation URLs
+
+ Generate a CSV of participation URLs for all participants by protocol.
+ These URLs can be shared with participants to allow them to participate
+ in your study.
+
+
+ {/* Protocol selection */}
+ {
+ const protocol = protocols.find(
+ (protocol) => protocol.id === value,
+ );
+
+ setSelectedProtocol(protocol);
+ }}
+ value={selectedProtocol?.id}
+ disabled={isLoadingProtocols}
+ >
+
+
+
+
+ {protocols?.map((protocol) => (
+
+ {protocol.name}
+
+ ))}
+
+
+
+
+
+
+ );
+};
diff --git a/app/(dashboard)/dashboard/participants/_components/ExportCSVParticipants.tsx b/app/(dashboard)/dashboard/participants/_components/ExportParticipants.tsx
similarity index 68%
rename from app/(dashboard)/dashboard/participants/_components/ExportCSVParticipants.tsx
rename to app/(dashboard)/dashboard/participants/_components/ExportParticipants.tsx
index 9750330a..56ca65ae 100644
--- a/app/(dashboard)/dashboard/participants/_components/ExportCSVParticipants.tsx
+++ b/app/(dashboard)/dashboard/participants/_components/ExportParticipants.tsx
@@ -1,18 +1,21 @@
'use client';
import { type Participant } from '@prisma/client';
+import { Download } from 'lucide-react';
import { unparse } from 'papaparse';
import { useState } from 'react';
import { Button } from '~/components/ui/Button';
+import { useToast } from '~/components/ui/use-toast';
import { useDownload } from '~/hooks/useDownload';
-function ExportCSVParticipants({
+function ExportParticipants({
participants,
}: {
- participants: Participant[];
+ participants: Participant[] | undefined;
}) {
const download = useDownload();
const [isExporting, setIsExporting] = useState(false);
+ const { toast } = useToast();
const handleExport = () => {
try {
@@ -23,7 +26,6 @@ function ExportCSVParticipants({
const csvData = participants.map((participant) => ({
id: participant.id,
identifier: participant.identifier,
- interview_url: `interview/${participant.id}`,
}));
const csv = unparse(csvData, { header: true });
@@ -35,7 +37,17 @@ function ExportCSVParticipants({
download(url, 'participants.csv');
// Clean up the URL object
URL.revokeObjectURL(url);
+ toast({
+ description: 'Participant CSV exported successfully',
+ variant: 'success',
+ duration: 3000,
+ });
} catch (error) {
+ toast({
+ title: 'Error',
+ description: 'An error occurred while exporting participants',
+ variant: 'destructive',
+ });
throw new Error('An error occurred while exporting participants');
}
@@ -44,9 +56,10 @@ function ExportCSVParticipants({
return (