Skip to content
Snippets Groups Projects
Commit b8f76f76 authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

Use nren.name instead of just .nren and type things properly

parent 000f4bfd
No related branches found
No related tags found
No related merge requests found
...@@ -147,7 +147,7 @@ function Landing(): ReactElement { ...@@ -147,7 +147,7 @@ function Landing(): ReactElement {
<tr key={response.nren.id}> <tr key={response.nren.id}>
<td>{response.nren.name}</td> <td>{response.nren.name}</td>
<td> <td>
<Link to={`/survey/response/${survey.year}/${response.nren}`}><span>Navigate to survey</span></Link> <Link to={`/survey/response/${survey.year}/${response.nren.name}`}><span>Navigate to survey</span></Link>
</td> </td>
<td>{response.status}</td> <td>{response.status}</td>
</tr> </tr>
......
...@@ -77,7 +77,7 @@ function SurveyManagementComponent() { ...@@ -77,7 +77,7 @@ function SurveyManagementComponent() {
}); });
}, []); }, []);
async function apiCall(url, failureToast, successToast) { async function apiCall(url: string, failureToast: string, successToast: string) {
try { try {
const response = await fetch(url, { method: 'POST' }); const response = await fetch(url, { method: 'POST' });
const json = await response.json(); const json = await response.json();
...@@ -98,7 +98,7 @@ function SurveyManagementComponent() { ...@@ -98,7 +98,7 @@ function SurveyManagementComponent() {
await apiCall('/api/survey/new', "Failed creating new survey: ", "Created new survey"); await apiCall('/api/survey/new', "Failed creating new survey: ", "Created new survey");
} }
async function postSurveyStatus(year, status) { async function postSurveyStatus(year: number, status: string) {
if (surveyStatusUpdating.current) { if (surveyStatusUpdating.current) {
toast("Wait for status update to be finished..."); toast("Wait for status update to be finished...");
return; return;
...@@ -112,7 +112,7 @@ function SurveyManagementComponent() { ...@@ -112,7 +112,7 @@ function SurveyManagementComponent() {
surveyStatusUpdating.current = false; surveyStatusUpdating.current = false;
} }
async function removeLock(year, nrenName) { async function removeLock(year: number, nrenName: string) {
await apiCall( await apiCall(
'/api/response/unlock/' + year + '/' + nrenName, '/api/response/unlock/' + year + '/' + nrenName,
"Error while unlocking " + nrenName + " " + year + " survey response: ", "Error while unlocking " + nrenName + " " + year + " survey response: ",
...@@ -199,14 +199,14 @@ function SurveyManagementComponent() { ...@@ -199,14 +199,14 @@ function SurveyManagementComponent() {
{'notes' in response && <textarea onInput={debounce((e) => updateSurveyNotes(survey.year, response.nren.id, e.target.value), 1000)} {'notes' in response && <textarea onInput={debounce((e) => updateSurveyNotes(survey.year, response.nren.id, e.target.value), 1000)}
style={{ minWidth: '100%', minHeight: '5rem' }} placeholder="Notes for this survey" defaultValue={response.notes || ''}> style={{ minWidth: '100%', minHeight: '5rem' }} placeholder="Notes for this survey" defaultValue={response.notes || ''}>
</textarea>} </textarea>}
</td> </td>
<td> <td>
<Button onClick={() => navigate(`/survey/response/${survey.year}/${response.nren}`)} style={{ pointerEvents: 'auto', margin: '.5rem' }} <Button onClick={() => navigate(`/survey/response/${survey.year}/${response.nren.name}`)} style={{ pointerEvents: 'auto', margin: '.5rem' }}
title="Open the responses of the NREN."> title="Open the responses of the NREN.">
open open
</Button> </Button>
<Button onClick={() => removeLock(survey.year, response.nren)} disabled={response.lock_description == ''} style={{ pointerEvents: 'auto' }} <Button onClick={() => removeLock(survey.year, response.nren.name)} disabled={response.lock_description == ''} style={{ pointerEvents: 'auto' }}
title="Remove the lock from the survey so that another person can open the survey for editing. WARNING: The person that currently has the lock will not be able to save their changes anymore once someone else starts editing!"> title="Remove the lock from the survey so that another person can open the survey for editing. WARNING: The person that currently has the lock will not be able to save their changes anymore once someone else starts editing!">
remove lock remove lock
</Button> </Button>
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment