Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View & Edit submission data #3

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/src/controllers/chefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ const controller = {
} catch (e: unknown) {
next(e);
}
},

getSubmissionStatus: async (req: Request, res: Response, next: NextFunction) => {
try {
const response = await chefsService.getSubmissionStatus(req.query.formId as string, req.params.formSubmissionId);
res.status(200).send(response);
} catch (e: unknown) {
next(e);
}
},

updateSubmission: async (req: Request, res: Response, next: NextFunction) => {
try {
const response = await chefsService.updateSubmission(
req.query.formId as string,
req.params.formSubmissionId,
req.body
);
res.status(200).send(response);
} catch (e: unknown) {
next(e);
}
}
};

Expand Down
18 changes: 18 additions & 0 deletions app/src/routes/v1/chefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,22 @@ router.get(
}
);

// Submission endpoint
router.put(
'/submission/:formSubmissionId',
requireChefsFormConfigData,
(req: Request, res: Response, next: NextFunction): void => {
chefsController.updateSubmission(req, res, next);
}
);

// Submission status endpoint
router.get(
'/submission/:formSubmissionId/status',
requireChefsFormConfigData,
(req: Request, res: Response, next: NextFunction): void => {
chefsController.getSubmissionStatus(req, res, next);
}
);

export default router;
18 changes: 18 additions & 0 deletions app/src/services/chefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@
} catch (e: unknown) {
throw e;
}
},

getSubmissionStatus: async (formId: string, formSubmissionId: string) => {
try {
const response = await chefsAxios(formId).get(`submissions/${formSubmissionId}/status`);
return response.data;
} catch (e: unknown) {
throw e;
}
},

updateSubmission: async (formId: string, formSubmissionId: string, data: any) => {

Check failure on line 54 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (16.x)

Unexpected any. Specify a different type

Check failure on line 54 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (18.x)

Unexpected any. Specify a different type

Check failure on line 54 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (20.x)

Unexpected any. Specify a different type

Check failure on line 54 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (16.x)

Unexpected any. Specify a different type

Check failure on line 54 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (18.x)

Unexpected any. Specify a different type

Check failure on line 54 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (20.x)

Unexpected any. Specify a different type
try {
console.log('updateSubmission');

Check warning on line 56 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (16.x)

Unexpected console statement

Check warning on line 56 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (18.x)

Unexpected console statement

Check warning on line 56 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (20.x)

Unexpected console statement

Check warning on line 56 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (16.x)

Unexpected console statement

Check warning on line 56 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (18.x)

Unexpected console statement

Check warning on line 56 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (20.x)

Unexpected console statement
console.log(data);

Check warning on line 57 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (16.x)

Unexpected console statement

Check warning on line 57 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (18.x)

Unexpected console statement

Check warning on line 57 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (20.x)

Unexpected console statement

Check warning on line 57 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (16.x)

Unexpected console statement

Check warning on line 57 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (18.x)

Unexpected console statement

Check warning on line 57 in app/src/services/chefs.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (App) (20.x)

Unexpected console statement
} catch (e: unknown) {
throw e;
}
}
};

Expand Down
1 change: 1 addition & 0 deletions frontend/src/assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ a:visited {
}

.p-button {
border-width: 2px;
&:not(.p-button-secondary, .p-button-success, .p-button-info, .p-button-warning, .p-button-help, .p-button-danger) {
color: $app-primary;
&:not(.p-button-outlined, .p-button-text) {
Expand Down
43 changes: 43 additions & 0 deletions frontend/src/components/form/Calendar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<script setup lang="ts">
import { toRef } from 'vue';
import { useField, ErrorMessage } from 'vee-validate';

import { Calendar } from '@/lib/primevue';

// Props
type Props = {
helpText?: string;
label?: string;
name: string;
disabled?: boolean;
};

const props = withDefaults(defineProps<Props>(), {
helpText: '',
type: 'text',
label: '',
disabled: false
});

const { errorMessage, value } = useField<string>(toRef(props, 'name'));
</script>

<template>
<div class="field col">
<label :for="name">{{ label }}</label>
<Calendar
v-model.trim="value"
:aria-describedby="`${name}-help`"
:name="name"
:class="'w-full ' + { 'p-invalid': errorMessage }"
:disabled="disabled"
show-time
hour-format="24"
show-icon
icon-display="input"
date-format="yy/mm/dd"
/>
<small :id="`${name}-help`">{{ helpText }}</small>
<ErrorMessage :name="name" />
</div>
</template>
43 changes: 43 additions & 0 deletions frontend/src/components/form/Dropdown.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<script setup lang="ts">
import { toRef } from 'vue';
import { useField, ErrorMessage } from 'vee-validate';

import { Dropdown } from '@/lib/primevue';

// Props
type Props = {
helpText?: string;
label?: string;
name: string;
placeholder?: string;
disabled?: boolean;
options: Array<string>;
};

const props = withDefaults(defineProps<Props>(), {
helpText: '',
type: 'text',
label: '',
placeholder: '',
disabled: false
});

const { errorMessage, value } = useField<string>(toRef(props, 'name'));
</script>

<template>
<div class="field col">
<label :for="name">{{ label }}</label>
<Dropdown
v-model.trim="value"
:aria-describedby="`${name}-help`"
:name="name"
:placeholder="placeholder"
:class="'w-full ' + { 'p-invalid': errorMessage }"
:disabled="disabled"
:options="props.options"
/>
<small :id="`${name}-help`">{{ helpText }}</small>
<ErrorMessage :name="name" />
</div>
</template>
8 changes: 1 addition & 7 deletions frontend/src/components/form/Password.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const { errorMessage, value } = useField<string>(toRef(props, 'name'));
</script>

<template>
<div class="field">
<div class="field col">
<label :for="props.name">{{ props.label }}</label>
<Password
v-model.trim="value"
Expand All @@ -39,9 +39,3 @@ const { errorMessage, value } = useField<string>(toRef(props, 'name'));
<ErrorMessage :name="props.name" />
</div>
</template>

<style lang="scss" scoped>
.field * {
display: block;
}
</style>
42 changes: 42 additions & 0 deletions frontend/src/components/form/TextArea.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { toRef } from 'vue';
import { useField, ErrorMessage } from 'vee-validate';

import { Textarea } from '@/lib/primevue';

// Props
type Props = {
helpText?: string;
label?: string;
name: string;
placeholder?: string;
disabled?: boolean;
};

const props = withDefaults(defineProps<Props>(), {
helpText: '',
type: 'text',
label: '',
placeholder: '',
disabled: false
});

const { errorMessage, value } = useField<string>(toRef(props, 'name'));
</script>

<template>
<div class="field col">
<label :for="name">{{ label }}</label>
<Textarea
v-model.trim="value"
:aria-describedby="`${name}-help`"
:name="name"
:placeholder="placeholder"
:class="'w-full ' + { 'p-invalid': errorMessage }"
:disabled="disabled"
:rows="5"
/>
<small :id="`${name}-help`">{{ helpText }}</small>
<ErrorMessage :name="name" />
</div>
</template>
10 changes: 2 additions & 8 deletions frontend/src/components/form/TextInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,17 @@ const { errorMessage, value } = useField<string>(toRef(props, 'name'));
</script>

<template>
<div class="field">
<div class="field col">
<label :for="name">{{ label }}</label>
<InputText
v-model.trim="value"
:aria-describedby="`${name}-help`"
:name="name"
:placeholder="placeholder"
:class="{ 'p-invalid': errorMessage }"
:class="'w-full ' + { 'p-invalid': errorMessage }"
:disabled="disabled"
/>
<small :id="`${name}-help`">{{ helpText }}</small>
<ErrorMessage :name="name" />
</div>
</template>

<style lang="scss" scoped>
.field * {
display: block;
}
</style>
3 changes: 3 additions & 0 deletions frontend/src/components/form/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export { default as Calendar } from './Calendar.vue';
export { default as CopyToClipboard } from './CopyToClipboard.vue';
export { default as Dropdown } from './Dropdown.vue';
export { default as GridRow } from './GridRow.vue';
export { default as Password } from './Password.vue';
export { default as TextArea } from './TextArea.vue';
export { default as TextInput } from './TextInput.vue';
Loading
Loading