- N на секция:
+ N на секция:
Произход:
diff --git a/src/components/modules/filter_components/Municipalities.js b/src/components/modules/filter_components/Municipalities.js
index 6de3015..dea87fb 100644
--- a/src/components/modules/filter_components/Municipalities.js
+++ b/src/components/modules/filter_components/Municipalities.js
@@ -1,11 +1,11 @@
-import React from "react";
+import React from 'react';
export default (props) => {
let municipalities = [];
if (!props.isAbroad) {
municipalities = [
- { code: "00", name: "Всички", isAbroad: false },
+ { code: '00', name: 'Всички', isAbroad: false },
...props.municipalities,
];
} else {
@@ -13,13 +13,11 @@ export default (props) => {
}
const municipalityHandler = (event) => {
+ props.setSelectedMunicipality(event.target.value);
- props.setSelectedMunicipality(event.target.value)
-
- var selectMunicipality = document.getElementById("selectMunicipality");
+ var selectMunicipality = document.getElementById('selectMunicipality');
var selectedValue =
selectMunicipality.options[selectMunicipality.selectedIndex].value;
-
municipalities.map(({ code, name }) => {
if (selectedValue === name) {
props.setMunicipality(code);
@@ -28,9 +26,9 @@ export default (props) => {
};
const filters = municipalities
.sort((a, b) => (a.code > b.code ? 1 : -1))
- .map(({ code, name }) => {
+ .map(({ code, name }, idx) => {
return (
-
+
{name}
);
diff --git a/src/components/modules/filter_components/Regions.js b/src/components/modules/filter_components/Regions.js
index e016523..ba55fd6 100644
--- a/src/components/modules/filter_components/Regions.js
+++ b/src/components/modules/filter_components/Regions.js
@@ -1,11 +1,13 @@
-import React from "react";
+import React from 'react';
export default (props) => {
-
let regions = [];
if (!props.isAbroad) {
- regions = [{ code: "00", name: "Всички", isAbroad: false }, ...props.regions];
+ regions = [
+ { code: '00', name: 'Всички', isAbroad: false },
+ ...props.regions,
+ ];
} else {
regions = props.regions;
}
@@ -14,13 +16,21 @@ export default (props) => {
props.setCityRegion(event.target.value);
};
- const filters = regions.map(({ name, code }) => {
+ const filters = regions.map(({ name, code }, idx) => {
return (
-
+
{name}
);
});
- return {filters} ;
+ return (
+
+ {filters}
+
+ );
};
diff --git a/src/components/modules/filter_components/Roles.js b/src/components/modules/filter_components/Roles.js
new file mode 100644
index 0000000..0afb00f
--- /dev/null
+++ b/src/components/modules/filter_components/Roles.js
@@ -0,0 +1,28 @@
+import React, { useContext } from 'react';
+import { AuthContext } from '../../App';
+
+export default (props) => {
+ const roles = useContext(AuthContext).roles;
+
+ const { setRole, role } = props;
+
+ const allRoles = [{ role: '00', roleLocalized: 'Всички' }, ...roles];
+
+ const changeHandler = (event) => {
+ setRole(event.target.value);
+ };
+
+ const filters = allRoles.map((role, idx) => {
+ return (
+
+ {role.roleLocalized}
+
+ );
+ });
+
+ return (
+
+ {filters}
+
+ );
+};
diff --git a/src/components/modules/filter_components/SectionNumber.js b/src/components/modules/filter_components/TextInput.js
similarity index 55%
rename from src/components/modules/filter_components/SectionNumber.js
rename to src/components/modules/filter_components/TextInput.js
index 4d3dc23..179bb78 100644
--- a/src/components/modules/filter_components/SectionNumber.js
+++ b/src/components/modules/filter_components/TextInput.js
@@ -1,6 +1,6 @@
-import React from "react";
+import React from 'react';
-import styled from "styled-components";
+import styled from 'styled-components';
const InputField = styled.input`
background: white;
@@ -12,14 +12,12 @@ const InputField = styled.input`
`;
export default (props) => {
+ const { setTextInput } = props;
- const { setSection } = props;
-
const changeHandler = (event) => {
event.preventDefault();
- setSection(event.target.value);
+ setTextInput(event.target.value);
};
-
- return ;
+ return ;
};
diff --git a/src/components/modules/filter_components/Towns.js b/src/components/modules/filter_components/Towns.js
index 98dd0dd..3e78b30 100644
--- a/src/components/modules/filter_components/Towns.js
+++ b/src/components/modules/filter_components/Towns.js
@@ -1,21 +1,21 @@
-import React from "react";
+import React from 'react';
export default (props) => {
let towns = [];
if (!props.isAbroad) {
- towns = [{ id: "00", name: "Всички", isAbroad: false }, ...props.towns];
+ towns = [{ id: '00', name: 'Всички', isAbroad: false }, ...props.towns];
} else {
- towns = [{ id: "00", name: "Всички", isAbroad: true }, ...props.towns];
+ towns = [{ id: '00', name: 'Всички', isAbroad: true }, ...props.towns];
}
const townHandler = (event) => {
props.setSelectedTown(event.target.value);
- var selectTown = document.getElementById("selectTown");
+ var selectTown = document.getElementById('selectTown');
var selectedValue = selectTown.options[selectTown.selectedIndex].value;
if (!props.isAbroad) {
- if (selectedValue !== "Всички") {
+ if (selectedValue !== 'Всички') {
towns.map(({ name, cityRegions, id }) => {
if (selectedValue === name) {
props.setRegions(cityRegions);
@@ -23,10 +23,10 @@ export default (props) => {
}
});
} else {
- props.setTown("");
+ props.setTown('');
}
} else {
- props.setRegions([{ name: "Всички", code: "00" }]);
+ props.setRegions([{ name: 'Всички', code: '00' }]);
towns
.sort((a, b) => (a.id > b.id ? 1 : -1))
.map(({ name, id }) => {
@@ -49,7 +49,6 @@ export default (props) => {
return (
{
- const { logOut, user } = useContext(AuthContext);
+export default (props) => {
+ const { logOut, user } = useContext(AuthContext);
- const requireRoles = roles => {
- for(const role of roles) {
- if(user.roles.includes(role))
- return true;
- }
- return false;
- };
+ const requireRoles = (roles) => {
+ for (const role of roles) {
+ if (user.roles.includes(role)) return true;
+ }
+ return false;
+ };
- return(
-
-
-
-
-
-
- Профил
-
- { !requireRoles(['validator', 'external-validator', 'admin'])? null :
-
- Проверявай
-
- }
- { !requireRoles(['admin'])? null :
-
- Протоколи
-
- }
- { !requireRoles(['lawyer', 'admin'])? null :
-
- Сигнали
-
- }
- {/* { !requireRoles(['admin'])? null :
-
- Администрация
-
- } */}
- {/*
+ return (
+
+
+
+
+
+
+ Профил
+
+ {!requireRoles(['validator', 'external-validator', 'admin']) ? null : (
+
+ Проверявай
+
+ )}
+ {!requireRoles(['admin']) ? null : (
+
+ Протоколи
+
+ )}
+ {!requireRoles(['lawyer', 'admin']) ? null : (
+
+ Сигнали
+
+ )}
+ {!requireRoles(['admin']) ? null : (
+
+ Администрация
+
+ )}
+ {/*
Статии
*/}
-
- Изход
-
-
-
- „Демократична България - обединение“ © 2021
-
-
- )
+
+ Изход
+
+
+ „Демократична България - обединение“ © 2021
+
+ );
};
diff --git a/src/components/modules/protocols/ProtocolDetails.js b/src/components/modules/protocols/ProtocolDetails.js
index 038dd0c..d22e3c2 100644
--- a/src/components/modules/protocols/ProtocolDetails.js
+++ b/src/components/modules/protocols/ProtocolDetails.js
@@ -5,103 +5,118 @@ import { ContentPanel } from '../Modules';
import { useHistory, useParams } from 'react-router-dom';
import { AuthContext } from '../../App';
-import ImageGallery from '../../ImageGallery';
+import ImageGallery from '../../utils/ImageGallery';
import Loading from '../../layout/Loading';
import { TableStyle } from '../Profile';
-export default props => {
- const { authGet } = useContext(AuthContext);
- const { protocol } = useParams();
- const history = useHistory();
- const [data, setData] = useState(null);
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { faChevronLeft } from '@fortawesome/free-solid-svg-icons';
+import { BackButton } from '../violations/ViolationDetails';
- useEffect(() => {
- authGet(`/protocols/${protocol}`).then(res => {
- setData(res.data);
- });
- }, []);
+export default (props) => {
+ const { authGet } = useContext(AuthContext);
+ const { protocol } = useParams();
+ const history = useHistory();
+ const [data, setData] = useState(null);
- const goBack = () => {
- history.goBack()
- }
+ useEffect(() => {
+ authGet(`/protocols/${protocol}`).then((res) => {
+ setData(res.data);
+ });
+ }, []);
- return(
-
- Назад
- Протокол {protocol}
-
- {
- !data? :
-
-
Секция
-
-
-
- Номер
- {data.section.id}
-
-
- Адрес
- {data.section.place}
-
-
-
-
-
Протокол
-
-
-
- Изпратен от (организация)
- {data.author.organization.name}
-
- {
- data.assignees.map(assignee =>
-
- Проверява се от
- {assignee.firstName} {assignee.lastName}
-
- )
- }
-
- Действителни гласове
- {data.results.validVotesCount}
-
-
- Недействителни гласове
- {data.results.invalidVotesCount}
-
-
- Машинни гласове
- {data.results.machineVotesCount}
-
-
-
-
-
Резултати
-
-
- {
- data.results.results.map(result =>
-
- {result.party.name}
- {result.validVotesCount}
- {result.invalidVotesCount}
- {result.machineVotesCount}
- {result.nonMachineVotesCount}
-
- )
- }
-
-
-
-
Снимки
-
({
- original: picture.url
- }))}
- />
-
- }
-
- );
+ const goBack = () => {
+ history.goBack();
+ };
+
+ return (
+
+
+
+
+
+
+ Протокол {protocol}
+
+
+
+ {!data ? (
+
+ ) : (
+
+
Секция
+
+
+
+ Номер
+ {data.section.id}
+
+
+ Адрес
+ {data.section.place}
+
+
+
+
+
Протокол
+
+
+
+ Изпратен от (организация)
+ {data.author.organization.name}
+
+ {data.assignees.map((assignee, idx) => (
+
+ Проверява се от
+
+ {assignee.firstName} {assignee.lastName}
+
+
+ ))}
+
+ Действителни гласове
+ {data.results.validVotesCount}
+
+
+ Недействителни гласове
+ {data.results.invalidVotesCount}
+
+
+ Машинни гласове
+ {data.results.machineVotesCount}
+
+
+
+
+
Резултати
+
+
+ {data.results.results.map((result, idx) => (
+
+ {result.party.name}
+ {result.validVotesCount}
+ {result.invalidVotesCount}
+ {result.machineVotesCount}
+ {result.nonMachineVotesCount}
+
+ ))}
+
+
+
+
Снимки
+
({
+ original: picture.url,
+ }))}
+ />
+
+ )}
+
+ );
};
diff --git a/src/components/modules/protocols/ProtocolFilter.js b/src/components/modules/protocols/ProtocolFilter.js
index eb1469d..1a10ff1 100644
--- a/src/components/modules/protocols/ProtocolFilter.js
+++ b/src/components/modules/protocols/ProtocolFilter.js
@@ -1,22 +1,22 @@
-import React, { useState, useEffect, useContext } from "react";
-import { Link } from "react-router-dom";
+import React, { useState, useEffect, useContext } from 'react';
+import { Link } from 'react-router-dom';
-import { AuthContext } from "../../App";
+import { AuthContext } from '../../App';
-import Statuses from "../filter_components/Statuses";
-import SectionNumber from "../filter_components/SectionNumber";
-import Origins from "../filter_components/Origins";
-import SendBy from "../filter_components/SendBy";
+import Statuses from '../filter_components/Statuses';
+import TextInput from '../filter_components/TextInput';
+import Origins from '../filter_components/Origins';
+import SendBy from '../filter_components/SendBy';
-import Countries from "../filter_components/Countries";
-import MIRs from "../filter_components/MIRs";
-import Municipalities from "../filter_components/Municipalities";
-import Towns from "../filter_components/Towns";
-import Regions from "../filter_components/Regions";
+import Countries from '../filter_components/Countries';
+import MIRs from '../filter_components/MIRs';
+import Municipalities from '../filter_components/Municipalities';
+import Towns from '../filter_components/Towns';
+import Regions from '../filter_components/Regions';
-import styled from "styled-components";
+import styled from 'styled-components';
-const FilterlTable = styled.table`
+const FilterTable = styled.table`
width: 100%;
border-collapse: collapse;
@@ -55,39 +55,39 @@ const ButtonStyle = styled.button`
export default (props) => {
const { authGet } = useContext(AuthContext);
- const [section, setSection] = useState("");
+ const [section, setSection] = useState('');
- const [organization, setOrganization] = useState("");
+ const [organization, setOrganization] = useState('');
- const [country, setCountry] = useState("00");
- const [selectedCountry, setSelectedCountry] = useState("");
+ const [country, setCountry] = useState('00');
+ const [selectedCountry, setSelectedCountry] = useState('');
const [disabled, setDisabled] = useState(true); //sets callback function for disabling field
const [mirs, setMirs] = useState([]); //sets all MIRs in Bulgaria
- const [electionRegion, setElectionRegion] = useState("00");
- const [selectedElectionRegion, setSelectedElectionRegion] = useState("");
+ const [electionRegion, setElectionRegion] = useState('00');
+ const [selectedElectionRegion, setSelectedElectionRegion] = useState('');
const [municipalities, setMunicipalities] = useState([]); //sets the municipalities in one MIR
- const [municipality, setMunicipality] = useState("00"); //gets the chosen municipality
- const [selectedMunicipality, setSelectedMunicipality] = useState("");
+ const [municipality, setMunicipality] = useState('00'); //gets the chosen municipality
+ const [selectedMunicipality, setSelectedMunicipality] = useState('');
const [towns, setTowns] = useState([]); //sets all towns in one municipality
- const [town, setTown] = useState("00");
- const [selectedTown, setSelectedTown] = useState("");
+ const [town, setTown] = useState('00');
+ const [selectedTown, setSelectedTown] = useState('');
const [regions, setRegions] = useState([]); //sets the election regions in one town
- const [cityRegion, setCityRegion] = useState("00");
+ const [cityRegion, setCityRegion] = useState('00');
const [statuses, setStatuses] = useState([]);
- const [status, setStatus] = useState("");
+ const [status, setStatus] = useState('');
const [origins, setOrigins] = useState([]);
- const [origin, setOrigin] = useState("");
+ const [origin, setOrigin] = useState('');
const [isAbroad, setIsAbroad] = useState(false); //sets if country is Bulgaria or not
- let url = "";
+ let url = '';
let params = {
country: country,
@@ -102,26 +102,26 @@ export default (props) => {
};
for (const [key, value] of Object.entries(params)) {
- if (value !== "00" && value !== "" && value) {
+ if (value !== '00' && value !== '' && value) {
url += `&${key}=${value}`;
} else {
- url.replace(`&${key}=${value}`, "");
+ url.replace(`&${key}=${value}`, '');
}
}
useEffect(async () => {
//gets all the MIRs
- const resElectionRegions = await authGet("/election_regions");
+ const resElectionRegions = await authGet('/election_regions');
- const resStatuses = await authGet("/protocols/statuses");
+ const resStatuses = await authGet('/protocols/statuses');
setStatuses(resStatuses.data);
- const resOrigins = await authGet("/protocols/origins");
+ const resOrigins = await authGet('/protocols/origins');
setOrigins(resOrigins.data);
//if country is NOT Bulgaria: gets all the cities in the foreign country
- if (country !== "00") {
- setElectionRegion("32");
+ if (country !== '00') {
+ setElectionRegion('32');
const resForeignTowns = await authGet(`/towns?country=${country}`);
//sets the cities in the foreign country and sets MIR to the last one which is "Abroad"
@@ -139,37 +139,37 @@ export default (props) => {
}, [country, municipality, electionRegion, town]);
const clearAll = () => {
- setOrganization("");
- setOrigin("");
- setStatus("");
- setSelectedCountry("");
- setCountry("00");
- setSelectedElectionRegion("");
+ setOrganization('');
+ setOrigin('');
+ setStatus('');
+ setSelectedCountry('');
+ setCountry('00');
+ setSelectedElectionRegion('');
setIsAbroad(false);
setDisabled(true);
- setSelectedMunicipality("Всички");
- setSelectedTown("Всички");
- setCityRegion("");
- setMunicipality("00");
- setElectionRegion("00");
- setTown("");
- setSection("");
+ setSelectedMunicipality('Всички');
+ setSelectedTown('Всички');
+ setCityRegion('');
+ setMunicipality('00');
+ setElectionRegion('00');
+ setTown('');
+ setSection('');
};
return (
-
+
- N на секция: {" "}
-
+ N на секция: {' '}
+
- Произход: {" "}
+ Произход: {' '}
- Подаден от: {" "}
+ Подаден от: {' '}
{
-
+
);
};
diff --git a/src/components/modules/protocols/ProtocolsHome.js b/src/components/modules/protocols/ProtocolsHome.js
index 274b97a..0f28985 100644
--- a/src/components/modules/protocols/ProtocolsHome.js
+++ b/src/components/modules/protocols/ProtocolsHome.js
@@ -1,25 +1,25 @@
-import React, { useEffect, useContext, useState } from "react";
+import React, { useEffect, useContext, useState } from 'react';
-import { Link, useLocation, useHistory } from "react-router-dom";
+import { Link, useLocation, useHistory } from 'react-router-dom';
-import { AuthContext } from "../../App";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { AuthContext } from '../../App';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faChevronLeft,
faChevronRight,
faFastForward,
faFastBackward,
-} from "@fortawesome/free-solid-svg-icons";
+} from '@fortawesome/free-solid-svg-icons';
-import styled from "styled-components";
-import Loading from "../../layout/Loading";
+import styled from 'styled-components';
+import Loading from '../../layout/Loading';
-import ProtocolFilter from "./ProtocolFilter";
+import ProtocolFilter from './ProtocolFilter';
-import firebase from "firebase/app";
-import "firebase/auth";
+import firebase from 'firebase/app';
+import 'firebase/auth';
-import axios from "axios";
+import axios from 'axios';
const TableViewContainer = styled.div`
padding: 40px;
@@ -97,24 +97,23 @@ export default (props) => {
const history = useHistory();
useEffect(() => {
- let url = "/protocols";
-
- const page = query.get("page");
- const limit = query.get("limit");
- const country = query.get("country");
- const electionRegion = query.get("electionRegion");
- const assignee = query.get("assignee");
- const section = query.get("section");
- const municipality = query.get("municipality");
- const town = query.get("town");
- const cityRegion = query.get("cityRegion");
- const status = query.get("status");
- const organization = query.get("organization");
- const origin = query.get("origin");
+ let url = '/protocols';
+
+ const page = query.get('page');
+ // const limit = query.get('limit');
+ const country = query.get('country');
+ const electionRegion = query.get('electionRegion');
+ const assignee = query.get('assignee');
+ const section = query.get('section');
+ const municipality = query.get('municipality');
+ const town = query.get('town');
+ const cityRegion = query.get('cityRegion');
+ const status = query.get('status');
+ const organization = query.get('organization');
+ const origin = query.get('origin');
if (
page ||
- limit ||
country ||
electionRegion ||
assignee ||
@@ -125,8 +124,9 @@ export default (props) => {
status ||
organization ||
origin
- ) url += "?";
-
+ )
+ url += '?';
+
if (country) url += `country=${country}`;
if (electionRegion) url += `&electionRegion=${electionRegion}`;
if (municipality) url += `&municipality=${municipality}`;
@@ -138,7 +138,7 @@ export default (props) => {
if (organization) url += `&organization=${organization}`;
if (origin) url += `&origin=${origin}`;
if (page) url += `page=${page}`;
- if (limit) url += `limit=${limit}`;
+ // if (limit) url += `limit=${limit}`;
setLoading(true);
authGet(url).then((res) => {
@@ -146,50 +146,60 @@ export default (props) => {
setData(res.data);
});
}, [
- query.get("page"),
- query.get("country"),
- query.get("electionRegion"),
- query.get("assignee"),
- query.get("section"),
- query.get("municipality"),
- query.get("town"),
- query.get("cityRegion"),
- query.get("status"),
- query.get("organization"),
- query.get("origin"),
+ query.get('page'),
+ query.get('country'),
+ query.get('electionRegion'),
+ query.get('assignee'),
+ query.get('section'),
+ query.get('municipality'),
+ query.get('town'),
+ query.get('cityRegion'),
+ query.get('status'),
+ query.get('organization'),
+ query.get('origin'),
]);
const origin = (apiOrigin) => {
switch (apiOrigin) {
- case "ti-broish":
- return "Ти Броиш";
+ case 'ti-broish':
+ return 'Ти Броиш';
default:
return apiOrigin;
}
};
-
+
const status = (apiStatus) => {
switch (apiStatus) {
- case "received":
+ case 'received':
return (
- Получен
+ Получен
);
- case "rejected":
+ case 'rejected':
return (
-
+
Отхвърлен
);
- case "approved":
+ case 'approved':
return (
- Одобрен
+ Одобрен
);
- case "replaced":
+ case 'replaced':
return (
-
+
Редактиран
);
+ case 'published':
+ return (
+
+ Публикуван
+
+ );
+ case 'ready':
+ return (
+ Готов
+ );
default:
return apiStatus;
}
@@ -203,26 +213,26 @@ export default (props) => {
return (
-
+
Първа
-
+
Предишна
{data.meta.currentPage} / {data.meta.totalPages}
-
+
Следваща
-
+
Последна
@@ -234,50 +244,48 @@ export default (props) => {
};
return (
- <>
-
- Протоколи
-
-
- {!data ? (
-
- ) : (
- [
- renderLinks(),
-
-
-
- № на секция
- Произход
- Адрес
- Статус
+
+ Протоколи
+
+
+ {!data ? (
+
+ ) : (
+ <>
+ {renderLinks()}
+
+
+
+ № на секция
+ Произход
+ Адрес
+ Статут
+
+
+
+ {loading ? (
+
+
+
+
-
-
- {loading ? (
-
-
-
+ ) : (
+ data.items.map((protocol, i) => (
+ openProtocol(protocol.id)}>
+
+ {protocol.section.id}
+ {origin(protocol.origin)}
+ {protocol.section.place}
+ {status(protocol.status)}
- ) : (
- data.items.map((protocol, i) => (
- openProtocol(protocol.id)}>
-
- {protocol.section.id}
-
- {origin(protocol.origin)}
- {protocol.section.place}
- {status(protocol.status)}
-
- ))
- )}
-
- ,
- renderLinks(),
- ]
- )}
-
- >
+ ))
+ )}
+