diff --git a/app/(dashboard)/dashboard/_components/ProtocolsTable/AnonymousRecruitmentModal.tsx b/app/(dashboard)/dashboard/_components/ProtocolsTable/AnonymousRecruitmentModal.tsx deleted file mode 100644 index 0863cbbb..00000000 --- a/app/(dashboard)/dashboard/_components/ProtocolsTable/AnonymousRecruitmentModal.tsx +++ /dev/null @@ -1,99 +0,0 @@ -'use client'; -import type { Protocol } from '@prisma/client'; -import { useState, useEffect } from 'react'; -import RecruitmentSwitch from '~/components/RecruitmentSwitch'; -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, - DialogTrigger, -} from '~/components/ui/dialog'; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '~/components/ui/select'; - -import { Button } from '~/components/ui/Button'; -import { api } from '~/trpc/client'; -import { getBaseUrl } from '~/trpc/shared'; -import CopyButton from '~/app/(dashboard)/dashboard/_components/ProtocolsTable/CopyButton'; - -export const AnonymousRecruitmentModal = () => { - const { data: appSettings } = api.appSettings.get.useQuery(); - const { data: protocolData, isLoading: isLoadingProtocols } = - api.protocol.get.all.useQuery(); - const [protocols, setProtocols] = useState([]); - const [selectedProtocol, setSelectedProtocol] = useState(); - - const allowAnonymousRecruitment = !!appSettings?.allowAnonymousRecruitment; - - useEffect(() => { - if (protocolData) { - setProtocols(protocolData); - } - }, [protocolData]); - - const url = `${getBaseUrl()}/onboard/${selectedProtocol?.id}`; - - return ( - setSelectedProtocol(undefined)}> - - - - - - Anonymous Recruitment - - If anonymous recruitment is enabled, you may generate an anonymous - recruitment URL. - - -
-

Allow anonymous recruitment?

- -
- {allowAnonymousRecruitment && ( - <> -
- -
- {selectedProtocol && ( -
-
{url}
- -
- )} - - )} -
-
- ); -}; diff --git a/app/(dashboard)/dashboard/_components/ProtocolsTable/AnonymousRecruitmentSection.tsx b/app/(dashboard)/dashboard/_components/ProtocolsTable/AnonymousRecruitmentSection.tsx new file mode 100644 index 00000000..d0377dfd --- /dev/null +++ b/app/(dashboard)/dashboard/_components/ProtocolsTable/AnonymousRecruitmentSection.tsx @@ -0,0 +1,95 @@ +'use client'; +import type { Protocol } from '@prisma/client'; +import { useState, useEffect } from 'react'; +import RecruitmentSwitch from '~/components/RecruitmentSwitch'; + +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from '~/components/ui/select'; + +import { Button } from '~/components/ui/Button'; +import { api } from '~/trpc/client'; +import { getBaseUrl } from '~/trpc/shared'; +import CopyButton from '~/app/(dashboard)/dashboard/_components/ProtocolsTable/CopyButton'; + +export const AnonymousRecruitmentSection = () => { + const { data: appSettings } = api.appSettings.get.useQuery(); + const { data: protocolData, isLoading: isLoadingProtocols } = + api.protocol.get.all.useQuery(); + const [protocols, setProtocols] = useState([]); + const [selectedProtocol, setSelectedProtocol] = useState(); + + const allowAnonymousRecruitment = !!appSettings?.allowAnonymousRecruitment; + + useEffect(() => { + if (protocolData) { + setProtocols(protocolData); + } + }, [protocolData]); + + useEffect(() => { + if (!allowAnonymousRecruitment) { + setSelectedProtocol(undefined); + } + }, [allowAnonymousRecruitment]); + + const url = `${getBaseUrl()}/onboard/${selectedProtocol?.id}`; + + return ( +
+
+

Anonymous Recruitment

+

+ If anonymous recruitment is enabled, you may generate an anonymous + recruitment URL. This URL can be shared with participants to allow + them to self-enroll in your study. +

+
+ +
+

Allow anonymous recruitment?

+ +
+ {allowAnonymousRecruitment && ( + <> +
+ +
+ {selectedProtocol && ( +
+
{url}
+ +
+ )} + + )} +
+ ); +}; diff --git a/app/(dashboard)/dashboard/_components/ProtocolsTable/ProtocolsTable.tsx b/app/(dashboard)/dashboard/_components/ProtocolsTable/ProtocolsTable.tsx index 2018e644..5a9ead4f 100644 --- a/app/(dashboard)/dashboard/_components/ProtocolsTable/ProtocolsTable.tsx +++ b/app/(dashboard)/dashboard/_components/ProtocolsTable/ProtocolsTable.tsx @@ -7,7 +7,7 @@ import { api } from '~/trpc/client'; import { DeleteProtocolsDialog } from '~/app/(dashboard)/dashboard/protocols/_components/DeleteProtocolsDialog'; import { useState } from 'react'; import type { ProtocolWithInterviews } from '~/shared/types'; -import { AnonymousRecruitmentModal } from './AnonymousRecruitmentModal'; +import { AnonymousRecruitmentSection } from './AnonymousRecruitmentSection'; import { RecruitmentModal } from '../RecruitmentModal'; export const ProtocolsTable = ({ @@ -38,7 +38,7 @@ export const ProtocolsTable = ({ return ( <>
- +