Add phone number field and WhatsApp/copy message buttons for participants

This commit is contained in:
2026-01-06 02:56:35 +01:00
parent 0637267ad5
commit 427da6452a
3 changed files with 105 additions and 25 deletions

View File

@@ -46,6 +46,7 @@ export interface Participant {
id: number;
questionnaire_id: number;
name: string;
phone: string | null;
token: string;
created_at: string;
}
@@ -141,6 +142,13 @@ export function initializeDatabase(): void {
)
`);
// Migration: Add phone column to participants if it doesn't exist
try {
db.exec(`ALTER TABLE participants ADD COLUMN phone TEXT`);
} catch (e) {
// Column already exists, ignore
}
db.exec(`
CREATE INDEX IF NOT EXISTS idx_participants_questionnaire ON participants(questionnaire_id);
CREATE INDEX IF NOT EXISTS idx_participants_token ON participants(token);
@@ -308,10 +316,10 @@ export const questionnaireOps = {
// Participant operations
export const participantOps = {
create: (questionnaireId: number, name: string, token: string): number => {
create: (questionnaireId: number, name: string, phone: string | null, token: string): number => {
const result = db.prepare(
'INSERT INTO participants (questionnaire_id, name, token) VALUES (?, ?, ?)'
).run(questionnaireId, name, token);
'INSERT INTO participants (questionnaire_id, name, phone, token) VALUES (?, ?, ?, ?)'
).run(questionnaireId, name, phone, token);
return result.lastInsertRowid as number;
},