Skip to content

Commit 7297f36

Browse files
committed
Bug fix for case where participant limit is reached
1 parent 6547ed1 commit 7297f36

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

src/components/ParticipantRegister/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { shell, remote, clipboard } = getElectron()
99

1010
export default function ParticipantRegister({
1111
participantRegisterConfig,
12+
reachedParticipantLimit,
1213
startTime
1314
}) {
1415
const { maxTime, id } = participantRegisterConfig
@@ -20,7 +21,7 @@ export default function ParticipantRegister({
2021

2122
const timeLeft =
2223
startTime && maxTime ? remainingTime(maxTime, startTime) : null
23-
const [over, setOver] = useState(timeLeft === 0)
24+
const [timeOver, setTimeOver] = useState(timeLeft === 0)
2425
const inputEl = useRef(null)
2526

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

3738
return (
3839
<>
39-
{startTime && maxTime && !over && (
40+
<div className='input-label'>Here is your public link to share</div>
41+
{startTime && maxTime && !reachedParticipantLimit && !timeOver && (
4042
<p>
4143
Registration will remain open for{' '}
42-
<TimeCountdown seconds={timeLeft} over={() => setOver(true)} />.
44+
<TimeCountdown seconds={timeLeft} over={() => setTimeOver(true)} />.
45+
</p>
46+
)}
47+
{timeOver && !reachedParticipantLimit && (
48+
<p>Registration is now closed.</p>
49+
)}
50+
{reachedParticipantLimit && (
51+
<p>
52+
Registration has closed because the participant limit was reached.
4353
</p>
4454
)}
45-
{over && <p>Registration is now closed.</p>}
46-
<div className='input-label'>Here is your public link to share</div>
4755
<div className='public-link-details'>
4856
<input
4957
ref={inputEl}

src/routes/Flow/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ export default function Process() {
103103
}
104104

105105
const { participantsConfig } = process.processConfig
106-
const { method, participants } = participantsConfig
106+
const { method, participants, publicLink } = participantsConfig
107+
const reachedParticipantLimit =
108+
participants.length === publicLink.maxParticipants
107109

108110
const run = () => {
109111
runProcess(processId)
@@ -158,7 +160,8 @@ export default function Process() {
158160
{method === FROM_PUBLIC_LINK && (
159161
<div className='participant-register-wrapper'>
160162
<ParticipantRegister
161-
participantRegisterConfig={participantsConfig.publicLink}
163+
reachedParticipantLimit={reachedParticipantLimit}
164+
participantRegisterConfig={publicLink}
162165
startTime={process.startTime}
163166
/>
164167
</div>

src/routes/Flows/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function FlowsContainer() {
7373
<>
7474
<FlowSubsection flows={runningFlows} label='Live flows' />
7575
<div className='divider' />
76-
<FlowSubsection flows={configuringFlows} label='Configured unrun flows' />
76+
<FlowSubsection flows={configuringFlows} label='Ready to run' />
7777
<div className='divider' />
7878
<FlowSubsection flows={completedFlows} label='Previously run flows' />
7979
<div className='divider' />

typescript/electron-only/processes.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,6 @@ const newProcessDefaults = () => {
9797
}
9898
}
9999

100-
/*
101-
102-
return getContactablesFromRegistration(
103-
publicLink.id,
104-
callback
105-
)
106-
updateParticipants(processId, finalInput, true)
107-
*/
108-
109100
const updateParticipants = async (
110101
processId: string,
111102
newParticipants: ContactableConfig[],
@@ -157,8 +148,23 @@ const cloneProcess = async (processId: string): Promise<string> => {
157148
const orig = await getProcess(processId)
158149
const newProcess = {
159150
...orig,
151+
processConfig: {
152+
...orig.processConfig,
153+
participantsConfig: {
154+
...orig.processConfig.participantsConfig,
155+
participants: [],
156+
publicLink: {
157+
...orig.processConfig.participantsConfig.publicLink,
158+
id: guidGenerator() // create a new id for the public link
159+
}
160+
}
161+
},
160162
...newProcessDefaults()
161163
}
164+
const { method, publicLink } = newProcess.processConfig.participantsConfig
165+
if (method === FROM_PUBLIC_LINK) {
166+
await createParticipantRegister(publicLink)
167+
}
162168
writeProcess(newProcess.id, newProcess)
163169
console.log('created a new process configuration by cloning', newProcess.id)
164170
return newProcess.id

0 commit comments

Comments
 (0)