the email template itself has to be able to get modified by admin
This commit is contained in:
@@ -13,6 +13,15 @@ function seed() {
|
||||
)
|
||||
`);
|
||||
|
||||
// Create email_templates table
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS email_templates (
|
||||
id INTEGER PRIMARY KEY,
|
||||
subject TEXT,
|
||||
body TEXT
|
||||
)
|
||||
`);
|
||||
|
||||
// Check if the hourly_rate setting already exists
|
||||
const settingStmt = db.prepare('SELECT * FROM settings WHERE key = ?');
|
||||
const hourlyRateSetting = settingStmt.get('hourly_rate');
|
||||
@@ -28,6 +37,32 @@ function seed() {
|
||||
console.log('Hourly rate setting already exists.');
|
||||
}
|
||||
|
||||
// Check if default email template exists
|
||||
const templateStmt = db.prepare('SELECT * FROM email_templates WHERE id = ?');
|
||||
const defaultTemplate = templateStmt.get(1);
|
||||
|
||||
if (!defaultTemplate) {
|
||||
const insertTemplate = db.prepare(
|
||||
"INSERT INTO email_templates (id, subject, body) VALUES (?, ?, ?)"
|
||||
);
|
||||
const defaultSubject = "Your Project Estimate is Ready!";
|
||||
const defaultBody = `Hello, [User Name],
|
||||
|
||||
Thank you for using EstimateFlow. We've prepared a rough estimate for your project based on your selections.
|
||||
|
||||
[EstimateDetails]
|
||||
|
||||
Please note that this is a preliminary estimate. For a more detailed quote and to discuss your project further, please don't hesitate to contact us.
|
||||
|
||||
Best regards,
|
||||
The EstimateFlow Team`;
|
||||
insertTemplate.run(1, defaultSubject, defaultBody);
|
||||
console.log('Default email template created.');
|
||||
} else {
|
||||
console.log('Default email template already exists.');
|
||||
}
|
||||
|
||||
|
||||
console.log('Seeding complete.');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user