Skip to content
This repository was archived by the owner on Apr 12, 2023. It is now read-only.

Commit 043a1ab

Browse files
committed
Endringer iht endringer i API
1 parent ea5ca12 commit 043a1ab

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

src/pages/api/periods/[id].ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default async function handler(
77
) {
88
try {
99
const { id } = req.query
10-
const url = `${process.env.DP_RAPP_API_URL}/api/v1/mellomlagring/hente/${id}`;
10+
const url = `${process.env.DP_RAPP_API_URL}/api/v1/meldeperioder/mellomlagret/${id}`;
1111

1212
const response = await doRequest(req, res, "GET", url);
1313

src/pages/api/periods/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default async function handler(
66
res: NextApiResponse
77
) {
88
try {
9-
const url = `${process.env.DP_RAPP_API_URL}/api/v1/meldeperiode/hente`;
9+
const url = `${process.env.DP_RAPP_API_URL}/api/v1/meldeperioder/`;
1010

1111
const response = await doRequest(req, res, "GET", url);
1212

src/pages/api/periods/save.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default async function handler(
66
res: NextApiResponse
77
) {
88
try {
9-
const url = `${process.env.DP_RAPP_API_URL}/api/v1/mellomlagring/lagre`;
9+
const url = `${process.env.DP_RAPP_API_URL}/api/v1/meldeperioder/lagre`;
1010

1111
const response = await doRequest(req, res, "POST", url);
1212

src/pages/api/periods/send.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default async function handler(
66
res: NextApiResponse
77
) {
88
try {
9-
const url = `${process.env.DP_RAPP_API_URL}/api/v1/send`;
9+
const url = `${process.env.DP_RAPP_API_URL}/api/v1/meldeperioder/send`;
1010

1111
const response = await doRequest(req, res, "POST", url);
1212

src/pages/form.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,19 @@ export default function Page() {
7272
.then((loadedData: LoadedData) => {
7373
// Convert loaded days to SavedDates
7474
const loadedSavedDates: SavedDates = {}
75-
loadedData?.days.forEach((day) => {
75+
loadedData?.days?.forEach((day) => {
7676
// @ts-ignore
7777
loadedSavedDates[fromStringToDate(day.date).getTime()] = { type: ActivityType[day.type], hours: day.hours }
7878
});
7979

80-
setQuestionWork(loadedData.questionWork);
81-
setQuestionMeasures(loadedData.questionMeasures);
82-
setQuestionIllness(loadedData.questionIllness);
83-
setQuestionVacation(loadedData.questionVacation);
80+
// If we didn't get data and fields are undefined > use null
81+
// We can't leave undefined in these fields, because it makes these components uncontrolled
82+
setQuestionWork(loadedData.questionWork == undefined ? null : loadedData.questionWork);
83+
setQuestionMeasures(loadedData.questionMeasures == undefined ? null : loadedData.questionMeasures);
84+
setQuestionIllness(loadedData.questionIllness == undefined ? null : loadedData.questionIllness);
85+
setQuestionVacation(loadedData.questionVacation == undefined ? null : loadedData.questionVacation);
8486
setSavedDates(loadedSavedDates);
85-
setQuestionProceed(loadedData.questionProceed);
87+
setQuestionProceed(loadedData.questionProceed == undefined ? null : loadedData.questionProceed);
8688
setQuestionConsent(false); // User must check it every time
8789

8890
setLoading(false)

0 commit comments

Comments
 (0)