Skip to content

Commit 27fef45

Browse files
authored
Merge pull request #2842 from hackforla/parent-org-update-fix-2555
type error fix + check for req fields
2 parents 5693576 + 0c7b9e1 commit 27fef45

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

server/app/controllers/parent-organization-controller.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,22 @@ const insert: RequestHandler<
4040

4141
const update: RequestHandler<
4242
{ id: string },
43-
Response,
43+
{ success: boolean } | { error: string },
4444
ParentOrganization,
4545
never
4646
> = async (req, res) => {
47+
const { id, name, tenantId } = req.body;
48+
if (!id || !name || !tenantId) {
49+
res.status(400).json({ error: "Missing required fields." });
50+
return;
51+
}
52+
4753
try {
4854
await parentOrganizationService.update(req.body);
49-
res.sendStatus(200);
50-
} catch (err) {
55+
res.status(200).json({ success: true });
56+
} catch (err: any) {
5157
console.error(err);
52-
res.status(500);
58+
res.status(500).json({ error: "Internal server error." });
5359
}
5460
};
5561

0 commit comments

Comments
 (0)