diff --git a/src/app/pages/participate/participate.page.ts b/src/app/pages/participate/participate.page.ts
index e3b6ec4..e95eecf 100644
--- a/src/app/pages/participate/participate.page.ts
+++ b/src/app/pages/participate/participate.page.ts
@@ -249,7 +249,7 @@ export class ParticipatePage implements OnInit, OnDestroy {
}
private friendlyError(
- reason: 'invalid_token' | 'already_submitted' | 'survey_not_found'
+ reason: 'invalid_token' | 'already_submitted' | 'survey_not_found' | 'survey_closed' | 'survey_draft'
): string {
switch (reason) {
case 'invalid_token':
@@ -258,6 +258,10 @@ export class ParticipatePage implements OnInit, OnDestroy {
return 'You have already submitted a response for this survey. Each link can only be used once.';
case 'survey_not_found':
return 'The survey could not be found on the host. It may have been deleted.';
+ case 'survey_draft':
+ return 'This survey is not yet open for responses. Please try again later.';
+ case 'survey_closed':
+ return 'This survey is closed and no longer accepting responses.';
}
}
}
diff --git a/src/app/pages/survey-detail/survey-detail.page.html b/src/app/pages/survey-detail/survey-detail.page.html
index 5b3c9d7..6415cf5 100644
--- a/src/app/pages/survey-detail/survey-detail.page.html
+++ b/src/app/pages/survey-detail/survey-detail.page.html
@@ -85,7 +85,8 @@
-
+
Start Hosting
diff --git a/src/app/pages/survey-detail/survey-detail.page.ts b/src/app/pages/survey-detail/survey-detail.page.ts
index 0ca7b8e..f7979c3 100644
--- a/src/app/pages/survey-detail/survey-detail.page.ts
+++ b/src/app/pages/survey-detail/survey-detail.page.ts
@@ -12,7 +12,7 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
-import { ToastController, AlertController, Platform } from '@ionic/angular';
+import { ToastController } from '@ionic/angular';
import { DataConnection } from 'peerjs';
import { Subscription } from 'rxjs';
import { SurveyService } from '../../services/survey.service';
@@ -52,9 +52,7 @@ export class SurveyDetailPage implements OnInit, OnDestroy {
private surveyService: SurveyService,
private responseService: ResponseService,
private peerService: PeerService,
- private toastCtrl: ToastController,
- private alertCtrl: AlertController,
- private platform: Platform
+ private toastCtrl: ToastController
) {}
async ngOnInit(): Promise {
@@ -228,6 +226,16 @@ export class SurveyDetailPage implements OnInit, OnDestroy {
if (!this.survey) return;
if (msg.type === 'join') {
+ if (this.survey.status === 'draft') {
+ conn.send({ type: 'error', reason: 'survey_draft' } as P2PMessage);
+ return;
+ }
+
+ if (this.survey.status === 'closed') {
+ conn.send({ type: 'error', reason: 'survey_closed' } as P2PMessage);
+ return;
+ }
+
const participant = await this.surveyService.getParticipant(msg.token);
if (!participant || participant.surveyId !== this.surveyId) {
diff --git a/src/app/shared/models/survey.models.ts b/src/app/shared/models/survey.models.ts
index 21c5f7f..3c2ebea 100644
--- a/src/app/shared/models/survey.models.ts
+++ b/src/app/shared/models/survey.models.ts
@@ -134,4 +134,4 @@ export type P2PMessage =
/** Host acknowledges a successful submit or update */
| { type: 'ack'; status: 'submitted' | 'updated' }
/** Host signals an error — participant should display the reason */
- | { type: 'error'; reason: 'invalid_token' | 'already_submitted' | 'survey_not_found' };
+ | { type: 'error'; reason: 'invalid_token' | 'already_submitted' | 'survey_not_found' | 'survey_closed' | 'survey_draft' };