Skip to content

Commit f85c816

Browse files
committed
update updatepayroll handler to fix bug
1 parent 4b5e2ff commit f85c816

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cmd/api/payroll.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ func (app *application) DeletePayroll(c echo.Context) error {
275275

276276
func (app *application) updatePayrollHandler(c echo.Context) error {
277277

278+
id := c.Param("id")
279+
payroll_id, err := uuid.Parse(id)
280+
if err != nil {
281+
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid uuid"})
282+
}
283+
278284
var input struct {
279285
BasicSalary *float64 `json:"basic_salary"`
280286
TIN *string `json:"tin"`
@@ -291,7 +297,7 @@ func (app *application) updatePayrollHandler(c echo.Context) error {
291297
return c.JSON(http.StatusBadRequest, map[string]string{"error": err.Error()})
292298
}
293299

294-
e, err := app.store.JustGetPayroll(c.Request().Context())
300+
e, err := app.store.GetPayrollByID(c.Request().Context(), payroll_id)
295301

296302
if err != nil {
297303
slog.Error("Error Getting employee for update ", "Error", err.Error())

0 commit comments

Comments
 (0)