Skip to content

Commit

Permalink
Made /plans page functional
Browse files Browse the repository at this point in the history
  • Loading branch information
jzongker committed Mar 28, 2024
1 parent 1fdabb2 commit a34655d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/models/Plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ export class Plan {
public id?: string;
public churchId?: string;
public name?: string;
public serviceDate?: Date;
public notes?: string;
}
8 changes: 4 additions & 4 deletions src/repositories/PlanRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export class PlanRepository {
private async create(plan: Plan) {
plan.id = UniqueIdHelper.shortId();

const sql = "INSERT INTO plans (id, churchId, name) VALUES (?, ?, ?);";
const params = [plan.id, plan.churchId, plan.name];
const sql = "INSERT INTO plans (id, churchId, name, serviceDate, notes) VALUES (?, ?, ?, ?, ?);";
const params = [plan.id, plan.churchId, plan.name, plan.serviceDate, plan.notes];
await DB.query(sql, params);
return plan;
}

private async update(plan: Plan) {
const sql = "UPDATE plans SET name=? WHERE id=? and churchId=?";
const params = [plan.name, plan.id, plan.churchId];
const sql = "UPDATE plans SET name=?, serviceDate=?, notes=? WHERE id=? and churchId=?";
const params = [plan.name, plan.serviceDate, plan.notes, plan.id, plan.churchId];
await DB.query(sql, params);
return plan;
}
Expand Down
2 changes: 2 additions & 0 deletions tools/dbScripts/plans.mysql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ CREATE TABLE `plans` (
`id` char(11) NOT NULL,
`churchId` char(11) DEFAULT NULL,
`name` varchar(45) DEFAULT NULL,
`serviceDate` date DEFAULT NULL,
`notes` text,
PRIMARY KEY (`id`)
);

0 comments on commit a34655d

Please sign in to comment.