Commit 9286fd78 authored by Rainer Türner's avatar Rainer Türner
Browse files

MVP v1 developments by Net Group

parent 154f1153
Pipeline #3769 failed with stages
in 0 seconds
ARG node_version=node:lts
ARG nginx_version=nginx:1.21.3-alpine
ARG sonarscanner_version=sonarsource/sonar-scanner-cli
FROM $node_version as image
WORKDIR /usr/customer-service
COPY ./package*.json ./
FROM image AS build
ARG env=DEV
RUN npm ci
COPY . .
RUN npm run test:coverage
RUN npm run build
FROM $sonarscanner_version as sonar
ARG sonarscanner_params=-Dsonar.host.url=http://localhost:9000
COPY --from=build ./usr/customer-service .
RUN sonar-scanner $sonarscanner_params
FROM $nginx_version
COPY ./nginx/https-nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build ./usr/customer-service/build /usr/share/nginx/html/customer-service
EXPOSE 443
CMD ["nginx", "-g", "daemon off;"]
MIT License
Copyright (c) 2022 buerokratt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# byk-customer-service
# Bürokratt customer service portal
For local development log in with username/password on http://localhost:3000/et/dev-auth
Credentials are will be set in your local user table
## Getting started
## Licence
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://koodivaramu.eesti.ee/buerokratt/plug-and-play/byk-customer-service.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://koodivaramu.eesti.ee/buerokratt/plug-and-play/byk-customer-service/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
See licence [here](LICENCE.md).
server {
server_name localhost;
listen 443;
server_tokens off;
add_header Access-Control-Allow-Origin *;
location / {
root /usr/share/nginx/html/customer-service;
try_files $uri /index.html;
}
location /status {
access_log off;
default_type text/plain;
add_header Content-Type text/plain;
return 200 "alive";
}
}
server {
listen 80;
server_name localhost;
return 301 https://$host$request_uri;
}
server {
server_name localhost;
listen 443 ssl;
ssl_certificate /etc/tls/tls.crt;
ssl_certificate_key /etc/tls/tls.key;
server_tokens off;
location / {
root /usr/share/nginx/html/customer-service;
try_files $uri /index.html;
}
location /status {
access_log off;
default_type text/plain;
add_header Content-Type text/plain;
return 200 "alive";
}
}
server {
listen 80;
server_name localhost;
return 301 https://$host$request_uri;
}
This diff is collapsed.
{
"name": "byk-customer-service",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.6.1",
"@types/jest": "^24.9.1",
"@types/node": "^12.20.27",
"@types/react": "^16.14.16",
"@types/react-dom": "^16.9.14",
"@types/react-redux": "^7.1.18",
"@types/react-router-dom": "^5.3.0",
"@types/styled-components": "^5.1.18",
"axios": "^0.22.0",
"classnames": "^2.3.1",
"cross-env": "^7.0.3",
"framer-motion": "4.1.17",
"i18next": "^21.2.4",
"i18next-browser-languagedetector": "^6.1.2",
"linkify-react": "^3.0.3",
"linkifyjs": "^3.0.4",
"luxon": "^2.2.0",
"primeflex": "^3.1.2",
"primeicons": "^5.0.0",
"primereact": "^7.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^11.12.0",
"react-redux": "^7.2.5",
"react-router": "5.2.1",
"react-router-dom": "^5.3.0",
"react-scripts": "5.0.1",
"react-transition-group": "^4.4.2",
"sass": "^1.42.1",
"styled-components": "^5.3.3",
"timeago.js": "^4.0.2"
},
"devDependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^10.4.9",
"@testing-library/user-event": "^7.2.1",
"@types/luxon": "^2.0.8",
"eslint": "8.15.0",
"eslint-config-react-app": "7.0.1",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"history": "^5.1.0",
"husky": "^7.0.0",
"msw": "^0.36.3",
"prettier": "2.4.1",
"typescript": "^4.4.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --watchAll=false",
"test:watch": "react-scripts test",
"test:coverage": "cross-env CI=true npm run test -- --env=jsdom --coverage",
"lint": "eslint src --ext .js,.ts,.jsx,.tsx",
"lint:fix": "npm run lint -- --fix",
"prettier:check": "prettier --check \"{,src/**/,webpack/}*.{json,yml,html,js,ts,tsx,css,scss}\"",
"prettier:format": "prettier --write \"{,src/**/,webpack/}*.{json,yml,html,js,ts,tsx,css,scss}\"",
"prepare": "husky install"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!<rootDir>/node_modules/",
"!<rootDir>/src/store/index.ts"
],
"coveragePathIgnorePatterns": [
"<rootDir>/src/index.tsx",
"<rootDir>/src/i18n.ts"
],
"coverageThreshold": {
"global": {
"functions": 70,
"lines": 70
}
},
"coverageReporters": [
"text",
"lcov"
]
}
}
File added
window._env_ = {
RUUTER_API_URL: 'http://localhost:8443',
TIM_API_URL: 'http://localhost:8085',
ANALYTICS_URL: 'https://localhost:5601',
TARA_REDIRECT_URL: 'http://localhost:8085/tim/oauth2/authorization/tara?callback_url=http://localhost:8085',
MONITORING_URL: 'http://localhost:3003',
AUTHORITY_NAME: 'ASUTUSE NIMI',
PASSWORD_AUTH_ENABLED: true,
INSTITUTION_FORWARDING_ENABLED: true,
};
<!DOCTYPE html>
<html lang='et'>
<head>
<meta charset='utf-8' />
<link href='%PUBLIC_URL%/favicon.ico' rel='icon' />
<script src="%PUBLIC_URL%/env-config.js"></script>
<meta content='width=device-width, initial-scale=1' name='viewport' />
<meta content='#000000' name='theme-color' />
<meta content='Bürokrati vestlused' name='description' />
<title>Bürokratt</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id='byk-cs'></div>
</body>
</html>
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.test.inclusions=**/*.test.tsx, **/*.test.ts
sonar.coverage.exclusions=**/*.test.tsx, **/*.test.ts
sonar.sources=src
sonar.tests=src
import React from 'react';
import { Router } from 'react-router-dom';
import { createMemoryHistory } from 'history';
import App from './App';
import { render } from './utils/test.utils';
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (str: string) => str,
i18n: {
language: 'et',
options: {
supportedLngs: ['et'],
},
},
}),
}));
describe('App component', () => {
it('should be rendered', () => {
const history = createMemoryHistory();
render(
<Router history={history}>
<App />
</Router>,
);
});
});
import React, { ReactElement, RefObject, useEffect, useRef } from 'react';
import { Toast } from 'primereact/toast';
import { addLocale } from 'primereact/api';
import { Menu } from './components/menu/menu';
import Routes from './components/routes';
import { getUserinfo, verifyAuthentication } from './slices/authentication.slice';
import { useAppDispatch, useAppSelector } from './store';
import { SESSION_STORAGE_JWT_VERIFY } from './utils/constants';
import AuthenticationExpirationModal from './components/authentication-expiration-modal';
declare global {
interface Window {
_env_: {
RUUTER_API_URL: string;
TIM_API_URL: string;
TARA_REDIRECT_URL: string;
ANALYTICS_URL: string;
MONITORING_URL: string;
AUTHORITY_NAME: string;
PASSWORD_AUTH_ENABLED: boolean;
INSTITUTION_FORWARDING_ENABLED: boolean;
};
}
}
export const ToastContext = React.createContext<RefObject<Toast> | null>(null);
const App = (): ReactElement => {
const dispatch = useAppDispatch();
const toast = useRef<Toast>(null);
const isAuthenticated = useAppSelector((state) => state.authentication.isAuthenticated);
addLocale('et', {
firstDayOfWeek: 1,
dayNames: ['esmaspäev', 'teisipäev', 'kolmapäev', 'neljapäev', 'reede', 'laupäev', 'pühapäev'],
dayNamesShort: ['es', 'te', 'ko', 'ne', 're', 'la', ''],
dayNamesMin: ['E', 'T', 'K', 'N', 'R', 'L', 'P'],
monthNames: ['jaanuar', 'veebruar', 'märts', 'aprill', 'mai', 'juuni', 'juuli', 'august', 'september', 'oktoober', 'november', 'detsember'],
monthNamesShort: ['jan', 'feb', 'mar', 'apr', 'mai', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'det'],
today: 'Täna',
clear: 'Tühjenda',
});
useEffect(() => {
if (window.sessionStorage.getItem(SESSION_STORAGE_JWT_VERIFY)) dispatch(verifyAuthentication());
if (!isAuthenticated) return;
dispatch(getUserinfo());
window.sessionStorage.setItem(SESSION_STORAGE_JWT_VERIFY, 'true');
}, [isAuthenticated, dispatch]);
return (
<>
<ToastContext.Provider value={toast}>
<Toast ref={toast} />
{isAuthenticated && <AuthenticationExpirationModal />}
{isAuthenticated && <Menu />}
<Routes />
</ToastContext.Provider>
</>
);
};
export default App;
import { Chat } from '../model/chat.model';
import { MessageModel } from '../model/message.model';
import { AUTHOR_ROLES, CHAT_STATUS } from '../utils/constants';
export const mockChats: Chat[] = [
{
id: '2d426c21-c7b7-4882-aed3-22e5e25e7a85',
status: CHAT_STATUS.OPEN,
endUserId: 'General Grievous',
customerSupportDisplayName: 'MARY ÄNN O’CONNEŽ-ŠUSLIK',
lastMessage: 'Haiii',
created: '2022-01-26T16:16:42.718077296Z',
ended: '',
updated: '2022-01-26T16:19:05.549390Z',
},
{
id: '6cd19e51-8e91-4be2-8312-ee8bfbb29d5b',
status: CHAT_STATUS.OPEN,
endUserId: 'anonymous',
updated: '2021-12-16T15:39:01.000Z',
customerSupportDisplayName: '',
lastMessage:
'Vivamus pellentesque odio libero, sed congue orci ullamcorper non. Pellentesque volutpat eros non placerat blandit. Donec gravida finibus metus ut sollicitudin. Proin ante elit, feugiat tincidunt leo non, sollicitudin commodo purus. Ut quis faucibus diam. Suspendisse pellentesque rhoncus velit, et posuere sapien gravida in. Proin a mi ultrices, ullamcorper mauris semper, tincidunt nunc. Etiam cursus est quis maximus porttitor.',
created: '2021-12-16T15:39:02.000Z',
ended: '2021-12-16T15:45:00.000Z',
},
{
id: '6cd19e09-8e91-4be2-8312-ee8bfbb29d5b',
status: CHAT_STATUS.ENDED,
endUserId: '',
customerSupportId: 'EE60001019906',
lastMessage: 'Tere! Kuidas saan Teid aidata?',
created: '2021-12-16T15:39:02.000Z',
updated: '2021-12-16T15:44:00.000Z',
ended: '2021-12-16T15:45:00.000Z',
},
{
id: 'f72b251f-74ec-4228-b617-a03b1a6626a4',
status: CHAT_STATUS.ENDED,
endUserId: '',
customerSupportId: 'EE0000000007',
lastMessage: 'Ma olen Joonas',
created: '2021-12-16T11:58:52.000Z',
updated: '2021-12-16T15:44:00.000Z',
ended: '2021-12-16T12:04:24.000Z',
},
{
id: 'bedf43d0-954f-4775-992f-01b80ff9a5b2',
status: CHAT_STATUS.ENDED,
endUserId: '',
customerSupportId: 'EE60001019906',
lastMessage: 'Tere',
created: '2021-12-16T09:58:05.000Z',
updated: '2021-12-16T15:44:00.000Z',
ended: '2021-12-16T10:13:17.000Z',
},
{
id: 'be4d7b37-1cd9-4b2e-9932-d30674b1033f',
status: CHAT_STATUS.ENDED,
endUserId: '',
customerSupportId: 'EE60001019906',
lastMessage: '',
created: '2021-12-16T08:54:16.000Z',
updated: '2021-12-16T15:44:00.000Z',
ended: '2021-12-16T09:01:57.000Z',
},
{
id: 'cd5d62a3-7d9f-42a6-b500-09402c935405',
status: CHAT_STATUS.ENDED,
endUserId: '',
customerSupportId: 'EE0000000007',
lastMessage: 'alustan',
created: '2021-12-16T08:35:10.000Z',
updated: '2021-12-16T15:44:00.000Z',
ended: '2021-12-16T08:59:29.000Z',
},
{
id: '0b20bc82-f0ff-4ee0-9863-9b592c825415',
status: CHAT_STATUS.ENDED,
endUserId: '',
customerSupportId: 'EE0000000007',
lastMessage: 'tere',
created: '2021-12-15T14:55:46.000Z',
updated: '2021-12-16T15:44:00.000Z',
ended: '2021-12-15T15:01:45.000Z',
},
];
export const shortMockChatMessages: MessageModel[] = [
{
id: '0',
chatId: '6cd19e09-8e91-4be2-8312-ee8bfbb29d5b',
created: '2021-12-16T15:39:02.000Z',
authorTimestamp: '2021-12-16T15:39:02.000Z',
authorId: 'General Kenobi',
content: 'Hello, there!',
authorRole: AUTHOR_ROLES.END_USER,
authorFirstName: '',
event: '',
},
{
id: '1',
chatId: '6cd19e09-8e91-4be2-8312-ee8bfbb29d5b',
created: '2021-12-16T15:39:05.000Z',
authorTimestamp: '2021-12-16T15:39:19.000Z',
authorId: 'General Grievous',
content: 'General Kenobi!',
authorRole: AUTHOR_ROLES.END_USER,
authorFirstName: '',
event: '',
},
];
export const mockChatMessages: MessageModel[] = [
{
id: '0',
chatId: '6cd19e09-8e91-4be2-8312-ee8bfbb29d5b',
created: '2021-12-16T15:39:02.000Z',
authorTimestamp: '2021-12-16T15:39:02.000Z',
authorId: 'General Grievous',
content: 'Hello, there!',
authorRole: AUTHOR_ROLES.END_USER,
authorFirstName: '',
event: '',
},
{
id: '1',
chatId: '6cd19e09-8e91-4be2-8312-ee8bfbb29d5b',
created: '2021-12-16T15:39:05.000Z',
authorTimestamp: '2021-12-16T15:39:19.000Z',
authorId: 'General Grievous',
content: 'General Kenobi!',
authorRole: AUTHOR_ROLES.END_USER,
authorFirstName: '',
event: '',
},
{
id: '2',
chatId: '6cd19e09-8e91-4be2-8312-ee8bfbb29d5b',
created: '2021-12-16T15:39:05.000Z',
authorTimestamp: '2021-12-16T16:39:05.000Z',
authorId: '',
content:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec accumsan diam vel sapien sodales, interdum rhoncus est bibendum. Aliquam eget nisi sed turpis posuere facilisis. In sagittis ipsum justo, at semper ligula molestie quis. Phasellus ornare leo ac magna dictum, ac aliquet lorem tincidunt. Vivamus nec quam quam. Phasellus viverra, nibh sed pretium dignissim, nisi risus convallis enim, vitae pulvinar urna metus a arcu. Ut vehicula tincidunt volutpat. Cras sed volutpat erat. Aliquam eget dui nibh. Sed at viverra orci, vitae lobortis nulla. Etiam ac venenatis lorem. Nulla iaculis magna in lorem iaculis, at fermentum metus fringilla. Quisque fringilla purus non sapien posuere congue.',
authorRole: AUTHOR_ROLES.END_USER,
authorFirstName: '',
event: '',
},
{
id: '3',
chatId: '6cd19e09-8e91-4be2-8312-ee8bfbb29d5b',
created: '2021-12-16T15:39:05.000Z',
authorTimestamp: '2021-12-16T16:39:19.000Z',
authorId: 'customerSupportDisplayNameAgent',
content:
'Vivamus pellentesque odio libero, sed congue orci ullamcorper non. Pellentesque volutpat eros non placerat blandit. Donec gravida finibus metus ut sollicitudin. Proin ante elit, feugiat tincidunt leo non, sollicitudin commodo purus. Ut quis faucibus diam. Suspendisse pellentesque rhoncus velit, et posuere sapien gravida in. Proin a mi ultrices, ullamcorper mauris semper, tincidunt nunc. Etiam cursus est quis maximus porttitor.',
authorRole: AUTHOR_ROLES.END_USER,
authorFirstName: '',
event: '',
},
{
id: '4',
chatId: '6cd19e09-8e91-4be2-8312-ee8bfbb29d5b',
created: '2021-12-16T15:39:05.000Z',
authorTimestamp: '2021-12-16T16:39:05.000Z',
authorId: '',