66 lines
4.3 KiB
TypeScript
66 lines
4.3 KiB
TypeScript
|
|
import { Prisma } from "@/generated/prisma/client";
|
||
|
|
import { prisma } from "./db";
|
||
|
|
|
||
|
|
const DEFAULT_FIELDS = [
|
||
|
|
{ key: "firstName", label: "First Name", type: "text", section: "personal", required: true, removable: false, isCore: true, sortOrder: 0 },
|
||
|
|
{ key: "lastName", label: "Last Name", type: "text", section: "personal", required: true, removable: false, isCore: true, sortOrder: 1 },
|
||
|
|
{ key: "email", label: "Email", type: "email", section: "contact", sortOrder: 2 },
|
||
|
|
{ key: "cellPhone", label: "Cell Phone", type: "phone", section: "contact", sortOrder: 3 },
|
||
|
|
{ key: "homePhone", label: "Home Phone", type: "phone", section: "contact", sortOrder: 4 },
|
||
|
|
{ key: "gender", label: "Gender", type: "select", section: "personal", options: ["Male", "Female"], sortOrder: 5 },
|
||
|
|
{ key: "dateOfBirth", label: "Date of Birth", type: "date", section: "personal", sortOrder: 6 },
|
||
|
|
{ key: "maritalStatus", label: "Marital Status", type: "select", section: "personal", options: ["Married", "Single", "Other"], sortOrder: 7 },
|
||
|
|
{ key: "visitType", label: "Visit Type", type: "select", section: "survey", options: ["First/Second Time Guest", "Update My Information"], sortOrder: 8 },
|
||
|
|
{ key: "address", label: "Address", type: "text", section: "address", sortOrder: 9 },
|
||
|
|
{ key: "aptNumber", label: "Apt #", type: "text", section: "address", sortOrder: 10 },
|
||
|
|
{ key: "city", label: "City", type: "text", section: "address", sortOrder: 11 },
|
||
|
|
{ key: "state", label: "State", type: "text", section: "address", sortOrder: 12 },
|
||
|
|
{ key: "zip", label: "Zip", type: "text", section: "address", sortOrder: 13 },
|
||
|
|
{ key: "prayerRequests", label: "Prayer Requests", type: "textarea", section: "survey", sortOrder: 14 },
|
||
|
|
{ key: "prayerForTeam", label: "For Prayer Team", type: "checkbox", section: "survey", sortOrder: 15 },
|
||
|
|
{ key: "prayerConfidential", label: "Confidential", type: "checkbox", section: "survey", sortOrder: 16 },
|
||
|
|
{ key: "messageTopics", label: "Message Topics", type: "multiselect", section: "survey", options: ["Stress/Anxiety", "Marriage", "Hearing God's Voice", "Dealing With Doubt", "Parenting", "Grief & Loss", "Forgiveness", "Finances", "Purpose/Calling", "Prayer", "Healthy Boundaries", "Understanding The Bible", "Emotional Health", "Sharing My Faith", "Decision Making", "Spiritual Disciplines", "Spiritual Gifts"], sortOrder: 17 },
|
||
|
|
{ key: "nextStep", label: "Next Steps", type: "multiselect", section: "survey", options: ["Baptism", "Next Steps"], sortOrder: 18 },
|
||
|
|
{ key: "attendanceDuration", label: "Attendance Duration", type: "radio", section: "survey", options: ["Less than 6 months", "6 Months - 1 Year", "1-3 Years", "4-6 Years", "7+ Years"], sortOrder: 19 },
|
||
|
|
{ key: "campusPreference", label: "Campus Preference", type: "multiselect", section: "survey", options: ["Beulah", "Pace/Milton", "Gulf Breeze", "Warrington"], sortOrder: 20 },
|
||
|
|
{ key: "howHeard", label: "How Did You Hear About Us?", type: "multiselect", section: "survey", options: ["This is my church home", "Regular Attender", "Drove by", "Social Media", "Google", "Personal Invite"], sortOrder: 21 },
|
||
|
|
{ key: "serviceAttended", label: "Service Attended", type: "select", section: "survey", options: ["A", "B", "C", "D"], sortOrder: 22 },
|
||
|
|
{ key: "followUp", label: "Follow-Up", type: "text", section: "followup", sortOrder: 23 },
|
||
|
|
{ key: "notes", label: "Notes", type: "textarea", section: "followup", sortOrder: 24 },
|
||
|
|
];
|
||
|
|
|
||
|
|
export async function seedDefaultTemplate(organizationId: string) {
|
||
|
|
const existing = await prisma.formTemplate.findFirst({
|
||
|
|
where: { organizationId, isDefault: true },
|
||
|
|
});
|
||
|
|
if (existing) return existing;
|
||
|
|
|
||
|
|
const template = await prisma.formTemplate.create({
|
||
|
|
data: {
|
||
|
|
organizationId,
|
||
|
|
name: "Connect Card",
|
||
|
|
slug: "connect-card",
|
||
|
|
description: "Default connect card template",
|
||
|
|
isDefault: true,
|
||
|
|
isActive: true,
|
||
|
|
fields: {
|
||
|
|
create: DEFAULT_FIELDS.map((f) => ({
|
||
|
|
key: f.key,
|
||
|
|
label: f.label,
|
||
|
|
type: f.type,
|
||
|
|
section: f.section,
|
||
|
|
required: f.required ?? false,
|
||
|
|
removable: f.removable ?? true,
|
||
|
|
isCore: f.isCore ?? false,
|
||
|
|
sortOrder: f.sortOrder,
|
||
|
|
options: f.options ?? Prisma.JsonNull,
|
||
|
|
})),
|
||
|
|
},
|
||
|
|
},
|
||
|
|
include: { fields: true },
|
||
|
|
});
|
||
|
|
return template;
|
||
|
|
}
|
||
|
|
|
||
|
|
export { DEFAULT_FIELDS };
|