Skip to content

Commit f4ba494

Browse files
karljogibaha-a
andauthored
15 participants send requests to start using bürokratt (#108)
* Add docker compose with Ruuter, Resql, Liquibase and DataMapper * Add GUI dummy code * Dummy end-to-end example * Add TIM service * Ignore tim-db folder * Implement invitation creation * Implement unique invitation id saving * Implement GUI * Fix create-table-invitation migration * Create translations, improve error handling * Clear error once new request is sent * Add auth mock to invitation creation * Rename DB table * Add missing translations * Fix sql query * Code styling fixes * Update invitations DB table with timestamp * Code styling fixes from PR review * Create template to validate administrator role * Move template to more suitable directory * Create DB table migrations * Update readme * Remove implementations from other PR-s * Update authentication script to match new logic * Add api endpoint documentation * Separate public and private ruuter * Add missing newline * Initial implementation of checking for unique ID * Separate public and private GUI * 18 Require unique ID for application request * Fix admin template wrong router host * Implement mock e-mail service * Add sending mock email to create-invitation DSL * Remove redundant string cast * Update API documentation * Simplify endpoint names * Update mock service with status code in return * Split API docs to 3 files * Implement initial application processing * Fix API path for invitation * Change request route to match API structure * Fix participants viewing & editing * Fix .gitignore * Fix docker compose * Fix merge issues * Implement updating and deleting participants * Code style fixes * Fix incorrect env port from merge changes * Remove redundant log * Add missing translation key * Update README.md * Remove unused DSL * Implement sending emails & status page --------- Co-authored-by: baha-a <bhlshrf@gmail.com>
1 parent 1869091 commit f4ba494

File tree

12 files changed

+161
-5
lines changed

12 files changed

+161
-5
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
INSERT INTO participants(name, institution_id, contact_email)
2-
VALUES (:name, :institution_id, :contact_email);
2+
VALUES (:name, :institution_id, :contact_email)
3+
RETURNING id, unique_identifier;

DSL/Ruuter.private/POST/invitation.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ get_invitation_code:
4242
user_email: ${email}
4343
result: invitationCodes
4444

45+
## ToDo use correct link to the application
4546
assign_email_content:
4647
assign:
4748
invitation_code: ${invitationCodes.response.body[0].invitationId}
@@ -50,7 +51,7 @@ assign_email_content:
5051
5152
5253
Thank you for your interest in Bürokratt!
53-
Please use this link to start filling in your application: http://localhost:3007/centops/application/${invitation_code}
54+
Please use this link to start filling in your application: http://localhost:8058/centops/application/${invitation_code}
5455
5556
5657
Best regards,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
check_body:
2+
switch:
3+
- condition: ${incoming.params.uniqueIdentifier == null}
4+
next: return_incorrect_request
5+
6+
get_participant:
7+
call: http.post
8+
args:
9+
url: http://resql:8052/get-participant-by-id
10+
body:
11+
unique_identifier: ${incoming.params.uniqueIdentifier}
12+
result: participant_result
13+
14+
return_success:
15+
status: 200
16+
return: ${participant_result.response.body[0].participantStatus}
17+
next: end
18+
19+
return_incorrect_request:
20+
status: 400
21+
return: "Missing required parameters"
22+
next: end

DSL/Ruuter.public/POST/participants/application.yml

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ create_participant:
4949
contact_email: ${email}
5050
institution_id: ${invitation.response.body[0].institutionId}
5151
name: ${name}
52-
result: institution
52+
result: participant
5353

5454
invalidate_invitation:
5555
call: http.post
@@ -61,9 +61,64 @@ invalidate_invitation:
6161
institution_id: ${invitation.response.body[0].institutionId}
6262
result: invalidated_invitation
6363

64+
assign_email_content:
65+
assign:
66+
invitation_code: ${invitation.response.body[0].invitationId}
67+
email_content: >
68+
Hello!
69+
70+
71+
There is a new application to start using Bürokratt!
72+
Participant name: ${name}
73+
Invitation id: ${invitation_code}
74+
Institution unique id: ${participant.response.body[0].uniqueIdentifier}
75+
Contact email: ${email}
76+
77+
Best regards,
78+
79+
Bürokratt team
80+
81+
send_email_to_buerokratt:
82+
call: http.post
83+
args:
84+
url: http://ruuter-private:8050/mocks/mock-email-service
85+
body:
86+
to: buerokratt@ria.ee ## TODO: Add correct email address
87+
subject: "A new application has been submitted"
88+
text: ${email_content}
89+
result: emailResponseData
90+
91+
## ToDo use correct link to the application
92+
assign_email_content_applicant:
93+
assign:
94+
applicant_email_content: >
95+
Hello!
96+
97+
98+
Thank you for applying to use Bürokratt! We will get back to you as soon as possible.
99+
100+
Your request id: ${participant.response.body[0].uniqueIdentifier}
101+
102+
In the meantime, you can check out the progress of your application here: https://localhost:8058/centops/application/status/${participant.response.body[0].uniqueIdentifier}
103+
104+
105+
Best regards,
106+
107+
Bürokratt team
108+
109+
send_email_to_applicant:
110+
call: http.post
111+
args:
112+
url: http://ruuter-private:8050/mocks/mock-email-service
113+
body:
114+
to: ${email}
115+
subject: "Your application has been submitted"
116+
text: ${applicant_email_content}
117+
result: emailResponseData
118+
64119
return_success:
65120
status: 201
66-
return: "Application created successfully"
121+
return: "Application submitted successfully"
67122
next: end
68123

69124
return_incorrect_request:

GUI.public/src/RootComponent.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import React from 'react';
22
import { Route, Routes } from 'react-router-dom';
33

44
import { Layout } from './components';
5-
import { ApplicationPage, OverviewPage, NotFoundPage } from './pages';
5+
import {
6+
ApplicationPage,
7+
ApplicationStatusPage,
8+
NotFoundPage,
9+
OverviewPage,
10+
} from './pages';
611
import { ROUTES } from './resources/routes-constants';
712
import './styles/main.scss';
813

@@ -15,6 +20,10 @@ const RootComponent: React.FC = () => {
1520
path={ROUTES.APPLICATION_ROUTE_WITH_ID}
1621
element={<ApplicationPage />}
1722
/>
23+
<Route
24+
path={ROUTES.APPLICATION_STATUS_ROUTE}
25+
element={<ApplicationStatusPage />}
26+
/>
1827
<Route path={ROUTES.OVERVIEW_ROUTE} element={<OverviewPage />} />
1928
<Route path="*" element={<NotFoundPage />} />
2029
</Route>

GUI.public/src/i18n/en/common.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@
1212
"validate-id": "Validate ID",
1313
"send-application": "Send application",
1414
"submit-success": "Thanks for your application!"
15+
},
16+
"application-status": {
17+
"processing": "Processing application, please wait",
18+
"processed": "Application processed, you can start using Bürokratt now!",
19+
"received": "Application received",
20+
"title": "Application status page"
1521
}
1622
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { useQuery } from '@tanstack/react-query';
2+
3+
import { useTranslation } from 'react-i18next';
4+
import { useParams } from 'react-router-dom';
5+
6+
import { getStatus } from '../services/status';
7+
import { Track } from '../components';
8+
import { ApplicationStatus } from '../types/applicationStatus';
9+
10+
const ApplicationStatusPage: React.FC = () => {
11+
const { uuid } = useParams();
12+
const { t } = useTranslation();
13+
14+
const { data: result } = useQuery<{ response: string }>(
15+
['participants/application'],
16+
async () => getStatus(uuid)
17+
);
18+
19+
return (
20+
<>
21+
<Track justify="between">
22+
<h1>{t('application-status.title')}</h1>
23+
</Track>
24+
{result?.response && (
25+
<Track justify="between">
26+
{result.response == ApplicationStatus.Unprocessed && (
27+
<h4>{t('application-status.received')}</h4>
28+
)}
29+
{result.response == ApplicationStatus.Inactive && (
30+
<h4>{t('application-status.processing')}</h4>
31+
)}
32+
{result.response == ApplicationStatus.Active && (
33+
<h4>{t('application-status.processed')}</h4>
34+
)}
35+
</Track>
36+
)}
37+
</>
38+
);
39+
};
40+
41+
export default ApplicationStatusPage;

GUI.public/src/pages/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { default as ApplicationPage } from './ApplicationPage';
2+
export { default as ApplicationStatusPage } from './ApplicationStatusPage';
23
export { default as NotFoundPage } from './NotFoundPage';
34
export { default as OverviewPage } from './OverviewPage';

GUI.public/src/resources/api-constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const baseUrl = process.env.REACT_APP_API_URL;
22

33
export const dummyApi = (): string => `${baseUrl}/dummy`;
4+
export const getApplicationStatus = (uuid: string): string =>
5+
`${baseUrl}/participants/application?uniqueIdentifier=${uuid}`;
46
export const sendApplication = (): string =>
57
`${baseUrl}/participants/application`;
68
export const toggleDummyApi = (): string => `${baseUrl}/toggle-dummy`;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const ROUTES = {
22
APPLICATION_ROUTE: '/centops/application/',
33
APPLICATION_ROUTE_WITH_ID: '/centops/application/:id',
4+
APPLICATION_STATUS_ROUTE: '/centops/application/status/:uuid',
45
OVERVIEW_ROUTE: '/centops/overview',
56
};

GUI.public/src/services/status.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import axios from 'axios';
2+
import { getApplicationStatus } from '../resources/api-constants';
3+
4+
export const getStatus = async (uuid?: string) => {
5+
if (!uuid) {
6+
return;
7+
}
8+
const { data } = await axios.get(getApplicationStatus(uuid));
9+
return data;
10+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export enum ApplicationStatus {
2+
Unprocessed = 'unprocessed',
3+
Inactive = 'inactive',
4+
Active = 'active',
5+
Deactivated = 'deactivated',
6+
Deleted = 'deleted',
7+
}

0 commit comments

Comments
 (0)