Skip to content

Commit

Permalink
enhance: open ms forms in new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
rschlaefli committed Oct 24, 2023
1 parent c0e0db7 commit cb7ef98
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 68 deletions.
34 changes: 0 additions & 34 deletions src/components/CreateProposal.tsx

This file was deleted.

34 changes: 9 additions & 25 deletions src/components/NewProposalButton.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,25 @@
import { Button } from '@uzh-bf/design-system'
import { RefObject } from 'react'
import Link from 'next/link'

interface NewProposalButtonProps {
isSupervisor: boolean
displayMode: string
setDisplayMode: (displayMode: string) => void
setSelectedProposal: (proposalId: string | null) => void
buttonRef: RefObject<HTMLButtonElement>
}

export default function NewProposalButton({
isSupervisor,
displayMode,
setDisplayMode,
setSelectedProposal,
buttonRef,
}: NewProposalButtonProps) {
const handleButtonClick = () => {
setSelectedProposal(null)
isSupervisor
? setDisplayMode('createSupervisor')
: setDisplayMode('createStudent')
buttonRef?.current?.scrollIntoView({
behavior: 'smooth',
})
}

return (
<div>
<Button
active={
displayMode === 'createSupervisor' || displayMode === 'createStudent'
<Link
target="_blank"
href={
isSupervisor
? (process.env.NEXT_PUBLIC_FORMS_URL_PUBLISH as string)
: (process.env.NEXT_PUBLIC_FORMS_URL_SUBMIT as string)
}
onClick={handleButtonClick}
>
New Proposal
</Button>
<Button>New Proposal</Button>
</Link>
</div>
)
}
11 changes: 2 additions & 9 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useSession } from 'next-auth/react'
import { useRouter } from 'next/router'
import * as R from 'ramda'
import { useMemo, useRef, useState } from 'react'
import CreateProposal from 'src/components/CreateProposal'
import Header from 'src/components/Header'
import NewProposalButton from 'src/components/NewProposalButton'
import ProposalApplication from 'src/components/ProposalApplication'
Expand Down Expand Up @@ -69,13 +68,7 @@ export default function Index() {

<div className="grid grid-cols-1 gap-2 m-4 md:grid-cols-2">
<div className="flex-initial pb-4 space-y-4 md:flex-1">
<NewProposalButton
isSupervisor={isSupervisor}
displayMode={displayMode}
setDisplayMode={setDisplayMode}
setSelectedProposal={setSelectedProposal}
buttonRef={buttonRef}
/>
<NewProposalButton isSupervisor={isSupervisor} />
<StudentProposals
isSupervisor={isSupervisor}
data={data}
Expand All @@ -96,7 +89,7 @@ export default function Index() {
</div>

<div className="mb-4 border shadow" ref={buttonRef}>
<CreateProposal displayMode={displayMode} ref={buttonRef} />
{!selectedProposal && <div className="p-4">No proposal selected</div>}
<ProposalMeta proposalDetails={proposalDetails} />
<ProposalApplication
proposalDetails={proposalDetails}
Expand Down

0 comments on commit cb7ef98

Please sign in to comment.