Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • kszk/devteam/kszkepzes/old/kszkepzes-frontend
  • kbgergely/kszkepzes-frontend
2 results
Show changes
Commits on Source (125)
Showing with 26576 additions and 17337 deletions
{
"extends": "airbnb",
"parser": "babel-eslint",
"globals": {
"document": false
},
"rules": {
"react/jsx-filename-extension": 0,
"react/no-danger": 0,
"jsx-quotes": ["error", "prefer-single"],
"import/prefer-default-export": 0,
"react/prop-types": 1,
"react/prop-types": 0,
"react/destructuring-assignment": 0,
"react/prefer-stateless-function": 0,
"no-case-declarations": 1
"camelcase": 0,
"no-alert": "off",
"no-undef": "off",
"no-console": "off",
"no-prototype-builtins": "off",
"import/no-cycle": "off",
"jsx-a11y/label-has-associated-control": "off",
"react/no-access-state-in-setstate": "off",
"consistent-return": "off",
"no-case-declarations": "off"
}
}
variables:
CONTAINER_IMAGE: 'harbor.sch.bme.hu/kszk-kepzes/frontend:$CI_COMMIT_REF_NAME'
stages:
- Pre Build
- Docker Build
- deploy
PreBuild:
stage: Pre Build
# tags: [kszk]
image: node:14.19-alpine3.14
script:
- 'echo -n "Node version: " && node --version \
&& echo -n "NPM version: " && npm --version'
- npm install
- npm run build
cache:
paths:
- build/
artifacts:
expire_in: 1 day
paths:
- build/
only:
- tags
Docker build:
stage: Docker Build
# tags: [kszk]
only:
- tags
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
script:
- echo "{\"auths\":{\"harbor.sch.bme.hu\":{\"username\":\"$REGISTRY_USER\",\"password\":\"$REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CONTAINER_IMAGE
Deploy to Kubernetes:
stage: deploy
image: alpine
tags: [k9r]
environment:
name: master
before_script:
- chmod 600 $KUBECONFIG
- apk add --no-cache curl
- curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- chmod +x ./kubectl
- mv ./kubectl /usr/local/bin/kubectl
- kubectl version
script:
- cd k8s
- sed -i "s|##IMAGETAG##|${CI_COMMIT_REF_NAME}|" deployment.yaml
- kubectl apply -f ./
only:
- tags
FROM node:10-alpine
FROM nginx:1.19.2
WORKDIR /opt/app
ENV TZ Europe/Budapest
RUN apk add --no-cache tzdata && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# copy the files builded with npm run build
COPY build /var/www
COPY nginx.conf /etc/nginx/nginx.conf
# Copying application files
COPY ./src ./src
COPY ./public ./public
COPY package.json yarn.lock package-lock.json ./
# Installing dependencies
RUN npm install
# Building the application
RUN npm run build
# Running
EXPOSE 3000
ENTRYPOINT ["npm", "run", "start"]
ENTRYPOINT ["nginx","-g","daemon off;"]
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kszkepzes-frontend
namespace: kszk-kepzes-site
spec:
replicas: 1
selector:
matchLabels:
app: kszkepzes-frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: kszkepzes-frontend
spec:
containers:
- name: kszkepzes-frontend
image: harbor.sch.bme.hu/kszk-kepzes/frontend:##IMAGETAG##
imagePullPolicy: 'Always'
ports:
- containerPort: 3000
resources:
limits:
memory: 200Mi
imagePullSecrets:
- name: harbor
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: kszk-kepzes-site
annotations:
cert-manager.io/cluster-issuer: letsencrypt
kubernetes.io/tls-acme: "true"
name: kszkepzes-frontend
spec:
rules:
- host: "ujonc.kszk.bme.hu"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kszkepzes-frontend
port:
number: 3000
tls:
- hosts:
- "ujonc.kszk.bme.hu"
secretName: kszkepzes-cert
\ No newline at end of file
---
apiVersion: v1
kind: Service
metadata:
name: kszkepzes-frontend
namespace: kszk-kepzes-site
spec:
type: ClusterIP
ports:
- port: 3000
targetPort: 3000
name: front
protocol: TCP
selector:
app: kszkepzes-frontend
# auto detects a good number of processes to run
worker_processes auto;
#Provides the configuration file context in which the directives that affect connection processing are specified.
events {
# Sets the maximum number of simultaneous connections that can be opened by a worker process.
worker_connections 8000;
# Tells the worker to accept multiple connections at a time
multi_accept on;
}
http {
# what times to include
include /etc/nginx/mime.types;
# what is the default one
default_type application/octet-stream;
# Sets the path, format, and configuration for a buffered log write
log_format compression '$remote_addr - $remote_user [$time_local] '
'"$request" $status $upstream_addr '
'"$http_referer" "$http_user_agent"';
server {
# listen on port 80
listen 3000;
# save logs here
access_log /var/log/nginx/access.log compression;
# where the root here
root /var/www;
# what file to server as index
index index.html index.htm;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to redirecting to index.html
try_files $uri $uri/ /index.html;
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# Javascript and CSS files
location ~* \.(?:css|js)$ {
try_files $uri =404;
expires 1y;
access_log off;
add_header Cache-Control "public, max-age=60";
}
# Any route containing a file extension (e.g. /devicesfile.js)
location ~ ^.+\..+$ {
try_files $uri =404;
}
}
}
This diff is collapsed.
{
"name": "kszkepzes-frontend",
"version": "0.2.0",
"proxy": "http://127.0.0.1:8000/",
"version": "0.2.8",
"private": false,
"dependencies": {
"axios": "^0.19.2",
"eslint-plugin-flowtype": "^4.6.0",
"http-proxy-middleware": "^0.20.0",
"moment": "^2.24.0",
"npm": "^6.13.7",
"axios": "^0.21.1",
"eslint-plugin-flowtype": "^4.7.0",
"http-proxy-middleware": "^1.0.6",
"moment": "^2.29.1",
"npm": "^6.14.11",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-datepicker": "^2.11.0",
"react-dom": "^16.12.0",
"react-redux": "^7.1.3",
"react-router-dom": "^5.1.2",
"react-scripts": "^3.3.0",
"react": "^16.14.0",
"react-datepicker": "^2.16.0",
"react-dom": "^16.14.0",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.4",
"react-slick": "^0.25.2",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
......@@ -33,10 +32,10 @@
},
"devDependencies": {
"eslint": "6.8.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.18.0"
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.22.0"
},
"browserslist": [
">0.2%",
......
<!doctype html>
<html lang="en">
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="stylesheet" href="index.css">
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link
rel="shortcut icon"
type="image/svg+xml"
href="%PUBLIC_URL%/kszk_circle_lightblue.svg"
/>
<link rel="stylesheet" href="%PUBLIC_URL%/index.css" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
......@@ -20,12 +29,10 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>KSZKépzés 2018</title>
<title>KSZKépzés 2025</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<noscript> You need to enable JavaScript to run this app. </noscript>
<div id="root" style="height: 100%"></div>
<!--
This HTML file is a template.
......
This diff is collapsed.
import {
GET_DEADLINE,
GET_USERDATA,
GROUP_CHANGE,
PROFILE_CHANGE,
} from './types';
import axios from './session';
import { GET_USERDATA, PROFILE_CHANGE, GROUP_CHANGE, GET_DEADLINE } from './types';
export const getUserData = () => async (dispatch) => {
try {
const user = await axios.get('/api/v1/profiles/me');
const {
id,
join_date: joinDate,
nick,
motivation_about: motivationAbout,
motivation_profession: motivationProfession,
motivation_exercise: motivationExercise,
full_name,
signed,
groups,
role,
bits,
} = user.data;
let permission;
switch (role) {
case 'Applicant':
permission = 1;
break;
case 'Student':
permission = 2;
break;
case 'Staff':
permission = 3;
break;
default:
permission = 0;
break;
}
export const getUserData = () => (
async (dispatch) => {
try {
const user = await axios.get('/api/v1/profiles/me');
const {
dispatch({
type: GET_USERDATA,
payload: {
id,
join_date: joinDate,
joinDate,
nick,
motivation_about: motivationAbout,
motivation_profession: motivationProfession,
motivation_exercise: motivationExercise,
motivationAbout,
motivationProfession,
motivationExercise,
full_name,
signed,
groups,
role,
bits
} = user.data;
let permission;
switch (role) {
case 'Applicant':
permission = 1;
break;
case 'Student':
permission = 2;
break;
case 'Staff':
permission = 3;
break;
default:
permission = 0;
break;
}
permission,
bits,
},
});
} catch (e) {
console.log(e);
dispatch({
type: GET_USERDATA,
payload: {
id, joinDate, nick, motivationAbout, motivationProfession, motivationExercise, full_name, signed, groups, role, permission, bits
},
});
} catch (e) {
console.log(e);
// Invalid session bug workaround
if (!e.response) {
window.location = "/oidc/logout"
}
}
);
};
export const getDeadline = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/profiles/deadline');
export const getDeadline = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/profiles/deadline');
dispatch({
type: GET_DEADLINE,
payload: response.data,
});
} catch (e) {
console.log(e);
}
dispatch({
type: GET_DEADLINE,
payload: response.data,
});
} catch (e) {
console.log(e);
}
);
};
export const textChange = ({ target: { name, value } }) => (
(dispatch) => {
dispatch({ type: PROFILE_CHANGE, payload: value, target: name });
}
);
export const textChange = ({ target: { name, value } }) => (dispatch) => {
dispatch({ type: PROFILE_CHANGE, payload: value, target: name });
};
export const groupChange = groups => (
dispatch => (dispatch({ type: GROUP_CHANGE, payload: groups }))
);
export const groupChange = (groups) => (dispatch) =>
dispatch({ type: GROUP_CHANGE, payload: groups });
export const submitRegistration = ({
nick, groups, signed, motivationAbout, motivationProfession, motivationExercise, id,
}) => (
async () => {
try {
const response = await axios.patch(`/api/v1/profiles/${id}/`, {
nick,
groups,
signed,
motivation_about: motivationAbout,
motivation_profession: motivationProfession,
motivation_exercise: motivationExercise,
});
if (response.data.id === id) {
alert('Sikeres mentés!');
} else {
alert('Mentés nem sikerült!');
}
} catch (e) {
console.log(e);
nick,
groups,
signed,
motivationAbout,
motivationProfession,
motivationExercise,
id,
}) => async () => {
try {
const response = await axios.patch(`/api/v1/profiles/${id}/`, {
nick,
groups,
signed,
motivation_about: motivationAbout,
motivation_profession: motivationProfession,
motivation_exercise: motivationExercise,
});
if (response.data.id === id) {
alert('Sikeres mentés!');
} else {
alert('Mentés nem sikerült!');
}
} catch (e) {
console.log(e, e.response);
alert('Mentés nem sikerült!');
}
);
};
import axios from './session';
import { GET_GROUPS } from './types';
import axios from './session';
export const getGroups = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/groups');
dispatch({
type: GET_GROUPS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
export const getGroups = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/groups');
dispatch({
type: GET_GROUPS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
);
};
import { GET_IMAGES } from './types';
import axios from './session';
export const getImages = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/images');
dispatch({
type: GET_IMAGES,
payload: response.data,
});
} catch (e) {
console.log(e);
}
};
import axios from './session';
import { GET_TASKS,
GET_SOLUTIONS,
import {
ADD_DOCUMENT,
ADD_SOLUTION,
ADD_TASK,
CHECK,
CLEAR_WRITE,
CORRECT_SOLUTION,
DELETE_TASK,
WRITE_TASK,
EDIT_TASK,
GET_DOCUMENTS,
GET_PROFILES,
GET_SOLUTIONS,
GET_TASKS,
SELECT_SOLUTION,
SELECT_TASK,
CLEAR_WRITE,
ADD_SOLUTION,
SETCHECKTRUE,
WRITE_SOLUTION,
WRITE_SOLUTION_FILE,
GET_PROFILES,
ADD_DOCUMENT,
GET_DOCUMENTS,
CORRECT_SOLUTION,
SELECT_SOLUTION,
CHECK } from './types';
WRITE_TASK,
} from './types';
export const getTasks = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/homework/tasks/');
import axios from './session';
export const getTasks = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/homework/tasks/');
dispatch({
type: GET_TASKS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
};
export const getSolutions = (taskId) => async (dispatch) => {
try {
const response = await axios.get('/api/v1/homework/solutions/', {
task: taskId,
});
dispatch({
type: GET_SOLUTIONS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
};
export const addTask = ({ title, text, deadline, bits }) => async (
dispatch
) => {
try {
const response = await axios.post('/api/v1/homework/tasks/', {
title,
text,
deadline,
bits,
});
if (response.data.id) {
dispatch({
type: GET_TASKS,
type: ADD_TASK,
payload: response.data,
});
} catch (e) {
console.log(e);
}
} catch (e) {
console.log(e);
}
);
};
export const getSolutions = taskId => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/homework/solutions/', { task: taskId });
export const editTask = ({ id, title, text, deadline, bits }) => async (
dispatch
) => {
try {
const response = await axios.patch(`/api/v1/homework/tasks/${id}/`, {
title,
text,
deadline,
bits,
});
if (response.data.id) {
dispatch({
type: GET_SOLUTIONS,
type: EDIT_TASK,
payload: response.data,
});
} catch (e) {
console.log(e);
}
} catch (e) {
console.log(e);
}
);
};
export const addTask = ({ title, text, deadline }) => (
async (dispatch) => {
try {
const response = await axios.post('/api/v1/homework/tasks/', {
title,
text,
deadline,
export const deleteTask = (task) => async (dispatch) => {
try {
const response = await axios.delete(`/api/v1/homework/tasks/${task.id}/`);
if (!response.data.id) {
dispatch({
type: DELETE_TASK,
payload: task,
});
if (response.data.id) {
dispatch({
type: ADD_TASK,
payload: response.data,
});
}
} catch (e) {
console.log(e);
}
} catch (e) {
console.log(e);
}
);
};
export const editTask = ({
id,
title,
text,
deadline,
}) => (
async (dispatch) => {
try {
const response = await axios.patch(`/api/v1/homework/tasks/${id}/`, {
title,
text,
deadline,
});
if (response.data.id) {
dispatch({
type: EDIT_TASK,
payload: response.data,
});
}
} catch (e) {
console.log(e);
}
}
);
export const setSelectedTask = (task) => (dispatch) => {
dispatch({ type: SELECT_TASK, payload: task });
};
export const deleteTask = task => (
async (dispatch) => {
try {
const response = await axios.delete(`/api/v1/homework/tasks/${task.id}/`);
if (!response.data.id) {
dispatch({
type: DELETE_TASK,
payload: task,
});
}
} catch (e) {
console.log(e);
}
});
export const setSelectedTask = task => (
(dispatch) => {
dispatch({ type: SELECT_TASK, payload: task });
}
);
export const addDocument = ({
name, description, file, solution,
}) => (
async (dispatch) => {
try {
const formData = new FormData();
formData.append('name', name);
formData.append('description', description);
formData.append('file', file);
formData.append('solution', solution);
const config = {
headers: {
'content-type': 'multipart/form-data',
},
};
const response = await axios.post('/api/v1/documents/', formData, config);
if (response.data.id) {
dispatch({
type: ADD_DOCUMENT,
payload: response.data,
});
}
} catch (e) {
console.log(e);
export const addDocument = ({ name, description, file, solution }) => async (
dispatch
) => {
try {
const formData = new FormData();
formData.append('name', name);
formData.append('description', description);
formData.append('file', file);
formData.append('solution', solution);
const config = {
headers: {
'content-type': 'multipart/form-data',
},
};
const response = await axios.post('/api/v1/documents/', formData, config);
if (response.data.id) {
dispatch({
type: ADD_DOCUMENT,
payload: response.data,
});
}
} catch (e) {
console.log(e);
}
);
};
export const addSolution = ({
task, accepted, corrected, note, name, description, file,
}) => (
async (dispatch) => {
try {
const response = await axios.post('/api/v1/homework/solutions/', {
task,
accepted,
corrected,
note,
task,
accepted,
corrected,
note,
name,
description,
file,
}) => async (dispatch) => {
try {
const response = await axios.post('/api/v1/homework/solutions/', {
task,
accepted,
corrected,
note,
});
if (response.data.id) {
dispatch({
type: ADD_SOLUTION,
payload: response.data,
});
if (response.data.id) {
dispatch({
type: ADD_SOLUTION,
payload: response.data,
});
}
const solution = response.data.id;
const formData = new FormData();
formData.append('name', name);
formData.append('description', description);
formData.append('file', file);
formData.append('solution', solution);
const config = {
headers: {
'content-type': 'multipart/form-data',
},
};
const responsedoc = await axios.post('/api/v1/documents/', formData, config);
if (responsedoc.data.id) {
dispatch({
type: ADD_DOCUMENT,
payload: responsedoc.data,
});
}
} catch (e) {
console.log(e);
}
}
);
export const getDocuments = (solutionID) => (
async (dispatch) => {
try {
const response =
await axios.get('/api/v1/documents', { params: { solution: solutionID } });
const solution = response.data.id;
const formData = new FormData();
formData.append('name', name);
formData.append('description', description);
formData.append('file', file);
formData.append('solution', solution);
const config = {
headers: {
'content-type': 'multipart/form-data',
},
};
const responsedoc = await axios.post(
'/api/v1/documents/',
formData,
config
);
if (responsedoc.data.id) {
dispatch({
type: GET_DOCUMENTS,
payload: response.data,
type: ADD_DOCUMENT,
payload: responsedoc.data,
});
} catch (e) {
console.log(e);
}
} catch (e) {
console.log(e);
}
);
};
export const writeSolution = ({ target: { name, value } }) => (
(dispatch) => {
dispatch({ type: WRITE_SOLUTION, payload: value, target: name });
export const getDocuments = (solutionID) => async (dispatch) => {
try {
const response = await axios.get('/api/v1/documents', {
params: { solution: solutionID },
});
dispatch({
type: GET_DOCUMENTS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
);
};
export const writeSolutionFile = ({ target: { files } }) => (
(dispatch) => {
dispatch({ type: WRITE_SOLUTION_FILE, payload: files[0], target: 'file' });
}
);
export const writeSolution = ({ target: { name, value } }) => (dispatch) => {
dispatch({ type: WRITE_SOLUTION, payload: value, target: name });
};
export const writeTask = ({ target: { name, value } }) => (
(dispatch) => {
dispatch({ type: WRITE_TASK, payload: value, target: name });
}
);
export const writeSolutionFile = ({ target: { files } }) => (dispatch) => {
dispatch({ type: WRITE_SOLUTION_FILE, payload: files[0], target: 'file' });
};
export const writeTaskDeadline = ({ name, value }) => (
(dispatch) => {
dispatch({ type: WRITE_TASK, payload: value, target: name });
}
);
export const writeTask = ({ target: { name, value } }) => (dispatch) => {
dispatch({ type: WRITE_TASK, payload: value, target: name });
};
export const writeTaskDeadline = ({ name, value }) => (dispatch) => {
dispatch({ type: WRITE_TASK, payload: value, target: name });
};
export const clearWrite = () => (
(dispatch) => {
dispatch({ type: CLEAR_WRITE });
export const clearWrite = () => (dispatch) => {
dispatch({ type: CLEAR_WRITE });
};
export const getProfiles = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/profiles/');
dispatch({
type: GET_PROFILES,
payload: response.data,
});
} catch (e) {
console.log(e);
}
);
};
export const getProfiles = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/profiles/');
export const correctSolution = (id, corrected, accepted, note) => async (
dispatch
) => {
try {
const response = await axios.patch(`/api/v1/homework/solutions/${id}/`, {
corrected,
accepted,
note,
});
if (response.data.id) {
dispatch({
type: GET_PROFILES,
type: CORRECT_SOLUTION,
payload: response.data,
});
} catch (e) {
console.log(e);
}
} catch (e) {
console.log(e);
}
);
};
export const correctSolution = (id, corrected, accepted, note) => (
async (dispatch) => {
try {
const response = await axios.patch(`/api/v1/homework/solutions/${id}/`, {
corrected,
accepted,
note,
});
if (response.data.id) {
dispatch({
type: CORRECT_SOLUTION,
payload: response.data,
export const check = (name) => (dispatch) => {
dispatch({ type: CHECK, target: name });
};
});
}
} catch (e) {
console.log(e);
}
}
);
export const check = name => (
(dispatch) => {
dispatch({ type: CHECK, target: name });
}
);
export const setchecktrue = (name) => (dispatch) => {
dispatch({ type: SETCHECKTRUE, target: name });
};
export const selectSolution = solution => (
(dispatch) => {
dispatch({
type: SELECT_SOLUTION,
payload: solution,
});
}
);
export const selectSolution = (solution) => (dispatch) => {
dispatch({
type: SELECT_SOLUTION,
payload: solution,
});
};
import axios from './session';
import { GET_MENTORS } from './types';
import axios from './session';
export const getMentors = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/mentors');
dispatch({
type: GET_MENTORS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
export const getMentors = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/mentors');
dispatch({
type: GET_MENTORS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
);
\ No newline at end of file
};
import {
ADD_NEWS,
CLEAR_WRITE,
DELETE_NEWS,
EDIT_NEWS,
GET_NEWS,
SELECT_NEWS,
WRITE_NEWS,
} from './types';
import axios from './session';
import { GET_NEWS, WRITE_NEWS, ADD_NEWS, DELETE_NEWS,
CLEAR_WRITE, SELECT_NEWS, EDIT_NEWS } from './types';
export const getNews = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/news');
export const getNews = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/news');
dispatch({
type: GET_NEWS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
};
export const postNews = ({ title, updated_by, text }) => async (dispatch) => {
try {
const response = await axios.post('/api/v1/news/', {
updated_by,
title,
text,
});
if (response.data.id) {
alert('Sikeres mentés!');
dispatch({
type: GET_NEWS,
type: ADD_NEWS,
payload: response.data,
});
} catch (e) {
console.log(e);
} else {
alert('Mentés nem sikerült!');
}
} catch (e) {
console.log(e);
}
);
};
export const postNews = ({ title, updated_by, text }) => (
async (dispatch) => {
try {
const response = await axios.post('/api/v1/news/', {
updated_by,
title,
text,
export const editNews = ({ id, title, text, updated_by }) => async (
dispatch
) => {
try {
const response = await axios.patch(`/api/v1/news/${id}/`, {
updated_by,
title,
text,
});
if (response.data.id) {
alert('Sikeres mentés!');
dispatch({
type: EDIT_NEWS,
payload: response.data,
});
if (response.data.id) {
alert('Sikeres mentés!');
dispatch({
type: ADD_NEWS,
payload: response.data,
});
} else {
alert('Mentés nem sikerült!');
}
} catch (e) {
console.log(e);
} else {
alert('Mentés nem sikerült!');
}
} catch (e) {
console.log(e);
}
);
};
export const editNews = ({ id, title, text, updated_by}) => (
async (dispatch) => {
try {
const response = await axios.patch(`/api/v1/news/${id}/`, {
updated_by,
title,
text,
export const deleteNews = (news) => async (dispatch) => {
try {
const response = await axios.delete(`/api/v1/news/${news.id}/`);
if (!response.data.id) {
alert('Sikeres törlés!');
dispatch({
type: DELETE_NEWS,
payload: news,
});
if (response.data.id) {
alert('Sikeres mentés!');
dispatch({
type: EDIT_NEWS,
payload: response.data,
});
} else {
alert('Mentés nem sikerült!');
}
} catch (e) {
console.log(e);
} else {
alert('A törlés nem sikerült!');
}
} catch (e) {
console.log(e);
}
);
export const deleteNews = news => (
async (dispatch) => {
try {
const response = await axios.delete(`/api/v1/news/${news.id}/`);
if (!response.data.id) {
alert('Sikeres törlés!');
dispatch({
type: DELETE_NEWS,
payload: news,
});
} else {
alert('A törlés nem sikerült!');
}
} catch (e) {
console.log(e);
}
});
};
export const writeNews = ({ target: { name, value } }) => (
(dispatch) => {
dispatch({ type: WRITE_NEWS, payload: value, target: name });
}
);
export const writeNews = ({ target: { name, value } }) => (dispatch) => {
dispatch({ type: WRITE_NEWS, payload: value, target: name });
};
export const clearWrite = () => (
(dispatch) => {
dispatch({ type: CLEAR_WRITE });
}
);
export const clearWrite = () => (dispatch) => {
dispatch({ type: CLEAR_WRITE });
};
export const setSelectedNews = item => (
(dispatch) => {
dispatch({ type: SELECT_NEWS, payload: item });
}
);
export const setSelectedNews = (item) => (dispatch) => {
dispatch({ type: SELECT_NEWS, payload: item });
};
import axios from './session';
import {
GET_NOTES_BY_EVENT,
WRITE_NOTE,
ADD_EVENT_NOTE,
CLEAR_WRITE,
GET_NOTES_BY_EVENT,
WRITE_NOTE,
} from './types';
export const getNotesByEvent = id => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/notes/', { params: { eventID: id } });
import axios from './session';
export const getNotesByEvent = (id) => async (dispatch) => {
try {
const response = await axios.get('/api/v1/notes/', {
params: { eventID: id },
});
dispatch({
type: GET_NOTES_BY_EVENT,
payload: response.data,
});
} catch (e) {
console.log(e);
}
};
export const writeNote = (event) => (dispatch) =>
dispatch({ type: WRITE_NOTE, payload: event.target.value });
export const postEventNote = ({ eventid, userid, note }) => async (
dispatch
) => {
try {
const response = await axios.post('/api/v1/notes/', {
event: eventid || '',
profile: userid || '',
note,
});
if (response.data.id) {
alert('Sikeres mentés!');
dispatch({
type: GET_NOTES_BY_EVENT,
type: ADD_EVENT_NOTE,
payload: response.data,
});
} catch (e) {
console.log(e);
}
} catch (e) {
console.log(e);
}
);
export const writeNote = (event) => {
return (dispatch => (dispatch({ type: WRITE_NOTE, payload: event.target.value })));
};
export const postEventNote = ({ eventid, userid, note }) => (
async (dispatch) => {
try {
const response = await axios.post('/api/v1/notes/', {
event: eventid ? eventid : '',
profile: userid ? userid : '',
note,
});
if (response.data.id) {
alert('Sikeres mentés!');
dispatch({
type: ADD_EVENT_NOTE,
payload: response.data,
});
}
} catch (e) {
console.log(e);
}
});
export const clearWrite = () => (
(dispatch) => {
dispatch({ type: CLEAR_WRITE });
}
);
export const clearWrite = () => (dispatch) => {
dispatch({ type: CLEAR_WRITE });
};
import axios from './session';
import {
GET_EVENTS,
GET_EVENT_BY_ID,
GET_TRAINEES,
VISITOR_CHANGE,
WRITE_EVENT,
ABSENT_CHANGE,
ADD_EVENT,
CHANGE_NO,
DELETE_EVENT,
GET_EVENTS,
GET_EVENT_BY_ID,
GET_PROFILES,
GET_SELECTED_PROFILE,
GET_TRAINEES,
SET_STATUS,
ABSENT_CHANGE,
CHANGE_NO,
VISITOR_CHANGE,
WRITE_EVENT,
} from './types';
export const getStaffEvents = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/staff_events/');
dispatch({
type: GET_EVENTS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
import axios from './session';
export const getStaffEvents = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/staff_events/');
dispatch({
type: GET_EVENTS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
);
};
export const getStudentEvents = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/student_events/');
dispatch({
type: GET_EVENTS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
export const getStudentEvents = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/student_events/');
dispatch({
type: GET_EVENTS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
);
};
export const getEventById = id => (
async (dispatch) => {
try {
const response = await axios.get(`/api/v1/staff_events/${id}`);
dispatch({
type: GET_EVENT_BY_ID,
payload: response.data,
});
} catch (e) {
console.log(e);
}
export const getEventById = (id) => async (dispatch) => {
try {
const response = await axios.get(`/api/v1/staff_events/${id}`);
dispatch({
type: GET_EVENT_BY_ID,
payload: response.data,
});
} catch (e) {
console.log(e);
}
);
};
export const getTrainees = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/profiles/');
dispatch({
type: GET_TRAINEES,
payload: response.data,
});
} catch (e) {
console.log(e);
}
export const getTrainees = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/profiles/');
dispatch({
type: GET_TRAINEES,
payload: response.data,
});
} catch (e) {
console.log(e);
}
);
};
export const visitorChange = ({ id, value }) => {
switch (value){
switch (value) {
case 'Visitor':
return (dispatch => (dispatch({ type: VISITOR_CHANGE, payload: id })));
return (dispatch) => dispatch({ type: VISITOR_CHANGE, payload: id });
case 'Absent':
return (dispatch => (dispatch({ type: ABSENT_CHANGE, payload: id })));
return (dispatch) => dispatch({ type: ABSENT_CHANGE, payload: id });
case 'No':
return (dispatch => (dispatch({ type: CHANGE_NO, payload: id })));
return (dispatch) => dispatch({ type: CHANGE_NO, payload: id });
default:
return null;
}
};
export const submitVisitors = ({ id, visitors, absent }) => (
async () => {
try {
const response = await axios.patch(`/api/v1/staff_events/${id}/`, {
visitors: visitors,
absent: absent
})
if(response.data.id === id) {
return true
} else {
return false
}
} catch (e) {
console.log(e);
return false
export const submitVisitors = ({ id, visitors, absent }) => async () => {
try {
const response = await axios.patch(`/api/v1/staff_events/${id}/`, {
visitors,
absent,
});
if (response.data.id === id) {
return true;
}
return false;
} catch (e) {
console.log(e);
return false;
}
);
export const writeEvent = ({ target: { name, value } }) => (
(dispatch) => {
dispatch({ type: WRITE_EVENT, payload: value, target: name });
}
);
};
export const writeEvent = ({ target: { name, value } }) => (dispatch) => {
dispatch({ type: WRITE_EVENT, payload: value, target: name });
};
export const eventDate = (name, value) => (
(dispatch) => {
dispatch({ type: WRITE_EVENT, payload: value, target: name });
}
);
export const eventDate = (name, value) => (dispatch) => {
dispatch({ type: WRITE_EVENT, payload: value, target: name });
};
export const addEvent = ({ name, date, description }) => (
async (dispatch) => {
try {
const response = await axios.post('/api/v1/staff_events/', {
name,
date,
description,
absent: [],
export const addEvent = ({ name, date, description }) => async (dispatch) => {
try {
const response = await axios.post('/api/v1/staff_events/', {
name,
date,
description,
absent: [],
});
if (response.data.id) {
alert('Sikeres mentés!');
dispatch({
type: ADD_EVENT,
payload: response.data,
});
if (response.data.id) {
alert('Sikeres mentés!');
dispatch({
type: ADD_EVENT,
payload: response.data,
});
} else {
alert('Mentés nem sikerült!');
}
} catch (e) {
console.log(e);
} else {
alert('Mentés nem sikerült!');
}
} catch (e) {
console.log(e);
}
);
export const deleteEvent = event => (
async (dispatch) => {
try {
const response = await axios.delete(`/api/v1/staff_events/${event.id}/`);
if (!response.data.id) {
alert('Sikeres törlés!');
dispatch({
type: DELETE_EVENT,
payload: event,
});
} else {
alert('A törlés nem sikerült!');
}
} catch (e) {
console.log(e);
}
});
};
export const getProfiles = () => (
async (dispatch) => {
try {
const response = await axios.get('/api/v1/profiles/');
export const deleteEvent = (event) => async (dispatch) => {
try {
const response = await axios.delete(`/api/v1/staff_events/${event.id}/`);
if (!response.data.id) {
alert('Sikeres törlés!');
dispatch({
type: GET_PROFILES,
payload: response.data,
type: DELETE_EVENT,
payload: event,
});
} catch (e) {
console.log(e);
} else {
alert('A törlés nem sikerült!');
}
} catch (e) {
console.log(e);
}
);
};
export const setStatus = (id, status) => (
async (dispatch) => {
try {
const response = await axios.patch(`/api/v1/profiles/${id}/`, {
role: status,
});
if (response.data.id) {
dispatch({
type: SET_STATUS,
payload: response.data,
});
}
} catch (e) {
console.log(e);
}
export const getProfiles = () => async (dispatch) => {
try {
const response = await axios.get('/api/v1/profiles/');
dispatch({
type: GET_PROFILES,
payload: response.data,
});
} catch (e) {
console.log(e);
}
);
};
export const getSelectedProfile = id => (
async (dispatch) => {
try {
const response = await axios.get(`/api/v1/profiles/${id}/`);
export const setStatus = (id, status) => async (dispatch) => {
try {
const response = await axios.patch(`/api/v1/profiles/${id}/`, {
role: status,
});
if (response.data.id) {
dispatch({
type: GET_SELECTED_PROFILE,
type: SET_STATUS,
payload: response.data,
});
} catch (e) {
console.log(e);
}
} catch (e) {
console.log(e);
}
);
};
export const getSelectedProfile = (id) => async (dispatch) => {
try {
const response = await axios.get(`/api/v1/profiles/${id}/`);
dispatch({
type: GET_SELECTED_PROFILE,
payload: response.data,
});
} catch (e) {
console.log(e);
}
};
......@@ -16,6 +16,8 @@ export const SELECT_NEWS = 'select_news';
export const GET_MENTORS = 'get_mentors';
export const GET_IMAGES = 'get_images';
export const GET_TASKS = 'get_homeworks';
export const ADD_TASK = 'add_task';
export const DELETE_TASK = 'delete_task';
......@@ -32,6 +34,7 @@ export const GET_DOCUMENTS = 'get_documents';
export const CORRECT_SOLUTION = 'correct_solution';
export const SELECT_SOLUTION = 'select_solution';
export const CHECK = 'check';
export const SETCHECKTRUE = 'setchecktrue';
export const GET_EVENTS = 'get_events';
export const GET_EVENT_BY_ID = 'get_event_by_id';
......