Skip to content

Commit

Permalink
Bug fix for case where participant limit is reached
Browse files Browse the repository at this point in the history
  • Loading branch information
Connoropolous committed Jan 5, 2020
1 parent 6547ed1 commit 7297f36
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
18 changes: 13 additions & 5 deletions src/components/ParticipantRegister/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { shell, remote, clipboard } = getElectron()

export default function ParticipantRegister({
participantRegisterConfig,
reachedParticipantLimit,
startTime
}) {
const { maxTime, id } = participantRegisterConfig
Expand All @@ -20,7 +21,7 @@ export default function ParticipantRegister({

const timeLeft =
startTime && maxTime ? remainingTime(maxTime, startTime) : null
const [over, setOver] = useState(timeLeft === 0)
const [timeOver, setTimeOver] = useState(timeLeft === 0)
const inputEl = useRef(null)

const onClickPreview = e => {
Expand All @@ -36,14 +37,21 @@ export default function ParticipantRegister({

return (
<>
{startTime && maxTime && !over && (
<div className='input-label'>Here is your public link to share</div>
{startTime && maxTime && !reachedParticipantLimit && !timeOver && (
<p>
Registration will remain open for{' '}
<TimeCountdown seconds={timeLeft} over={() => setOver(true)} />.
<TimeCountdown seconds={timeLeft} over={() => setTimeOver(true)} />.
</p>
)}
{timeOver && !reachedParticipantLimit && (
<p>Registration is now closed.</p>
)}
{reachedParticipantLimit && (
<p>
Registration has closed because the participant limit was reached.
</p>
)}
{over && <p>Registration is now closed.</p>}
<div className='input-label'>Here is your public link to share</div>
<div className='public-link-details'>
<input
ref={inputEl}
Expand Down
7 changes: 5 additions & 2 deletions src/routes/Flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ export default function Process() {
}

const { participantsConfig } = process.processConfig
const { method, participants } = participantsConfig
const { method, participants, publicLink } = participantsConfig
const reachedParticipantLimit =
participants.length === publicLink.maxParticipants

const run = () => {
runProcess(processId)
Expand Down Expand Up @@ -158,7 +160,8 @@ export default function Process() {
{method === FROM_PUBLIC_LINK && (
<div className='participant-register-wrapper'>
<ParticipantRegister
participantRegisterConfig={participantsConfig.publicLink}
reachedParticipantLimit={reachedParticipantLimit}
participantRegisterConfig={publicLink}
startTime={process.startTime}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Flows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function FlowsContainer() {
<>
<FlowSubsection flows={runningFlows} label='Live flows' />
<div className='divider' />
<FlowSubsection flows={configuringFlows} label='Configured unrun flows' />
<FlowSubsection flows={configuringFlows} label='Ready to run' />
<div className='divider' />
<FlowSubsection flows={completedFlows} label='Previously run flows' />
<div className='divider' />
Expand Down
24 changes: 15 additions & 9 deletions typescript/electron-only/processes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,6 @@ const newProcessDefaults = () => {
}
}

/*
return getContactablesFromRegistration(
publicLink.id,
callback
)
updateParticipants(processId, finalInput, true)
*/

const updateParticipants = async (
processId: string,
newParticipants: ContactableConfig[],
Expand Down Expand Up @@ -157,8 +148,23 @@ const cloneProcess = async (processId: string): Promise<string> => {
const orig = await getProcess(processId)
const newProcess = {
...orig,
processConfig: {
...orig.processConfig,
participantsConfig: {
...orig.processConfig.participantsConfig,
participants: [],
publicLink: {
...orig.processConfig.participantsConfig.publicLink,
id: guidGenerator() // create a new id for the public link
}
}
},
...newProcessDefaults()
}
const { method, publicLink } = newProcess.processConfig.participantsConfig
if (method === FROM_PUBLIC_LINK) {
await createParticipantRegister(publicLink)
}
writeProcess(newProcess.id, newProcess)
console.log('created a new process configuration by cloning', newProcess.id)
return newProcess.id
Expand Down

0 comments on commit 7297f36

Please sign in to comment.