forked from nfelger/achill
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9072c5e
commit fef4160
Showing
3 changed files
with
136 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/routes/calculation_postions.$calculationPositionId.time_entries.$date.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ActionFunctionArgs } from "@remix-run/node"; | ||
import TroiApiService from "troi-library"; | ||
import { login } from "~/cookies.server"; | ||
import { addTimeEntry } from "~/troi/troiControllerServer"; | ||
|
||
export async function action({ request, params }: ActionFunctionArgs) { | ||
if (request.method !== "POST") { | ||
throw new Error("MethodNotAllowed"); | ||
// todo (Malte Laukötter, 2023-12-15): throw a error with the correct error type (405) | ||
} | ||
|
||
if (params.calculationPositionId === undefined) { | ||
throw new Error("Missing calculationPositionId"); | ||
} | ||
|
||
if (params.date === undefined) { | ||
throw new Error("Missing date"); | ||
} | ||
|
||
const body = await request.formData(); | ||
|
||
const hours = body.get("hours"); | ||
if (typeof hours !== "string") { | ||
throw new Error("Missing hours"); | ||
} | ||
|
||
const description = body.get("description"); | ||
if (typeof description !== "string") { | ||
throw new Error("Missing description"); | ||
} | ||
|
||
addTimeEntry( | ||
request, | ||
parseInt(params.calculationPositionId, 10), | ||
params.date, | ||
parseFloat(hours), | ||
description, | ||
); | ||
|
||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters