Add phone number field and WhatsApp/copy message buttons for participants
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user