onChange(e.target.value)}\r\n id=\"outlined-basic\"\r\n label=\"Search\"\r\n variant=\"outlined\"\r\n InputProps={{\r\n startAdornment: (\r\n \r\n \r\n \r\n ),\r\n }}\r\n />\r\n >\r\n );\r\n}\r\n\r\nexport default SearchBar;\r\n","import {\r\n Box,\r\n makeStyles,\r\n Table,\r\n TableCell,\r\n TableHead,\r\n TablePagination,\r\n TableRow,\r\n TableSortLabel,\r\n} from \"@material-ui/core\";\r\nimport React from \"react\";\r\nimport { useState } from \"react\";\r\nimport _ from \"lodash\";\r\nimport { useEffect } from \"react\";\r\nimport SearchBar from \"./searchBar\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n table: {\r\n minWidth: \"800px\",\r\n marginTop: \"10px\",\r\n [theme.breakpoints.down(\"sm\")]: {\r\n minWidth: \"auto\",\r\n width:\"100%\",\r\n display:\"block\",\r\n overflowX:\"auto\"\r\n },\r\n \"& thead th\": {\r\n fontWeight: \"600\",\r\n color: theme.palette.primary.main,\r\n backgroundColor: theme.palette.primary.light,\r\n },\r\n \"& tbody td\": {\r\n fontWeight: \"300\",\r\n },\r\n \"& tbody tr:hover\": {\r\n cursor: \"pointer\",\r\n },\r\n \r\n },\r\n}));\r\n\r\nexport default function useTable(records, headCells, searchKeys) {\r\n const classes = useStyles();\r\n const pages = [5, 10, 25];\r\n const [page, setPage] = useState(0);\r\n let [filteredRecords, setFilteredRecords] = useState(records);\r\n const [rowsPerPage, setRowsPerPage] = useState(5);\r\n const [search, setSearch] = useState(\"\");\r\n // order is asc or desc\r\n const [order, setOrder] = useState();\r\n // orderby einai to id tou cell sto opoio exw pathsei\r\n const [orderBy, setOrderBy] = useState();\r\n\r\n useEffect(() => {\r\n setFilteredRecords(records === null ? [] : records);\r\n }, [records]);\r\n\r\n useEffect(() => {\r\n const newFilter = records.filter((record) => {\r\n //console.log(record);\r\n let satisfied = false;\r\n searchKeys.forEach((item) => {\r\n if (item.avoidSearch) return;\r\n var showKey = _.get(record, item);\r\n var result = String(_.get(record, item))\r\n .toLowerCase()\r\n .includes(search.toLowerCase());\r\n //console.log(\"To result\", result);\r\n if (result) {\r\n satisfied = true;\r\n return true;\r\n }\r\n });\r\n if (satisfied) return true;\r\n return false;\r\n });\r\n setFilteredRecords(newFilter);\r\n }, [search]);\r\n\r\n const TableContainer = (props) => (\r\n \r\n \r\n \r\n {props.children}\r\n
\r\n \r\n );\r\n\r\n const TableHeader = (props) => {\r\n const handleSortRequest = (cellId) => {\r\n const isAsc = orderBy === cellId && order === \"asc\";\r\n setOrder(isAsc ? \"desc\" : \"asc\");\r\n setOrderBy(cellId);\r\n };\r\n return (\r\n \r\n \r\n {headCells.map((headCell) => (\r\n \r\n {\r\n handleSortRequest(headCell.id);\r\n }}\r\n >\r\n {headCell.label}\r\n \r\n \r\n ))}\r\n \r\n \r\n );\r\n };\r\n\r\n const handleChangePage = (event, newPage) => {\r\n setPage(newPage);\r\n };\r\n\r\n const handleChangeRowsPerPage = (event) => {\r\n setRowsPerPage(parseInt(event.target.value, 10));\r\n setPage(0);\r\n };\r\n\r\n const TablePaginationCustom = () => (\r\n \r\n );\r\n\r\n function stableSort(array) {\r\n return _.orderBy(array, [orderBy], [order]);\r\n }\r\n\r\n const recordsAfterPaging = () => {\r\n return stableSort(filteredRecords).slice(\r\n page * rowsPerPage,\r\n (page + 1) * rowsPerPage\r\n );\r\n };\r\n\r\n return {\r\n TableContainer,\r\n TableHeader,\r\n TablePaginationCustom,\r\n recordsAfterPaging,\r\n };\r\n}\r\n","import React, { useContext, useEffect, useState } from \"react\";\r\n\r\nimport { TabContext } from \"../../contexts/tabContext\";\r\nimport { tabs } from \"../../config.json\";\r\nimport { useLocation, useNavigate } from \"react-router-dom\";\r\nimport {\r\n getStoreById,\r\n getStoreByEmail,\r\n deleteStore,\r\n} from \"../../services/storeService\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport {\r\n Box,\r\n Button,\r\n Container,\r\n IconButton,\r\n TableBody,\r\n TableCell,\r\n TableRow,\r\n Typography,\r\n} from \"@material-ui/core\";\r\nimport { Edit, DeleteOutline, Add, ArrowBack } from \"@material-ui/icons\";\r\nimport { ConfirmationDialogContext } from \"../../contexts/confirmationDialogContext\";\r\nimport { red } from \"@material-ui/core/colors\";\r\nimport useTable from \"../../components/common/useTable\";\r\n\r\nexport default function Stores() {\r\n const { changeTab } = useContext(TabContext);\r\n const [locationState, setLocationState] = useState();\r\n const { isAdmin, authed } = useContext(UserContext);\r\n const [admin, setAdmin] = useState(isAdmin());\r\n const [stores, setStores] = useState([]);\r\n const { openDialog } = useContext(ConfirmationDialogContext);\r\n const navigate = useNavigate();\r\n const location = useLocation();\r\n const storesColumn = [\r\n { id: \"address\", label: \"Address\" },\r\n { id: \"actions\", label: \"Actions\", avoidSearch: true },\r\n ];\r\n const {\r\n TableContainer,\r\n TableHeader,\r\n TablePaginationCustom,\r\n recordsAfterPaging,\r\n } = useTable(stores, storesColumn, [\"address\"]);\r\n\r\n const handleDelete = async (id) => {\r\n // try catch? prwta 8a kanw to set state wste na dei3w oti ola comple\r\n // kai meta 8a kalesw to api gia na kanw delete!!!\r\n let storesInitial = [...stores];\r\n try {\r\n if (id === null) return;\r\n let storesTemp = stores.filter((c) => c.id !== id);\r\n setStores([...storesTemp]);\r\n // call the api!!\r\n await deleteStore(id);\r\n } catch (e) {\r\n // delete the store here!!!\r\n setStores([...storesInitial]);\r\n }\r\n };\r\n\r\n const handleAddStore = (e) => {\r\n e.preventDefault();\r\n const addPath = location.pathname + \"/add\";\r\n navigate(addPath, { state: { ...locationState } });\r\n };\r\n\r\n const handleAssignUser = () => {\r\n navigate(`${location.pathname}/assignUser`, { state: locationState });\r\n };\r\n\r\n useEffect(() => {\r\n const Init = async () => {\r\n try {\r\n // console.log(`To company id:${companyId}`);\r\n if (isAdmin()) {\r\n changeTab(tabs.Companies);\r\n const { data: allStores } = await getStoreById(location.state.id);\r\n setStores(allStores);\r\n setLocationState({ CompanyId: location.state.id });\r\n } else {\r\n changeTab(tabs.Stores);\r\n const { data: store } = await getStoreByEmail(authed.email);\r\n setStores(store);\r\n // setCompanyId(authed.companyId);\r\n setLocationState({ OwnerEmail: authed.email });\r\n }\r\n } catch (ex) {\r\n // show snackbar? that something went wrong on loading the data!\r\n }\r\n };\r\n Init();\r\n }, [authed]);\r\n\r\n const handleEditClick = (row) => {\r\n navigate(`${location.pathname}/${row.id}`, {\r\n state: {\r\n ...row,\r\n },\r\n });\r\n };\r\n\r\n return (\r\n \r\n \r\n {admin ? (\r\n navigate(-1)}>\r\n \r\n \r\n ) : (\r\n
\r\n )}\r\n\r\n Καταστήματα \r\n \r\n }\r\n style={{ marginRight: \"10px\" }}\r\n variant=\"contained\"\r\n size=\"small\"\r\n >\r\n Αναθεση Χρηστη \r\n \r\n }\r\n variant=\"contained\"\r\n size=\"small\"\r\n >\r\n Προσθηκη Καταστηματος\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {recordsAfterPaging()?.length === 0 ? (\r\n \r\n \r\n No Results \r\n \r\n \r\n ) : (\r\n <>\r\n {recordsAfterPaging().map((item) => (\r\n \r\n {item.address} \r\n \r\n \r\n handleEditClick(item)}\r\n color=\"primary\"\r\n >\r\n \r\n \r\n {\r\n openDialog({\r\n title: \"Delete store?\",\r\n body: \"Are you sure you want to delete this store?\",\r\n yesButton: \"Yes\",\r\n noButton: \"No\",\r\n callback: () => handleDelete(item.id),\r\n });\r\n }}\r\n >\r\n \r\n \r\n \r\n \r\n \r\n ))}\r\n >\r\n )}\r\n \r\n \r\n \r\n \r\n \r\n );\r\n}\r\n","import http from \"./httpService\";\r\nimport { apiUrl } from \"../config.json\";\r\n\r\n\r\nconst apiEndpoint = apiUrl + \"/companies/\";\r\n\r\nexport async function getAllCompanies()\r\n{\r\n let allCompanies = apiEndpoint + \"getAllCompanies\";\r\n const { data } = await http.get(allCompanies);\r\n return data;\r\n}\r\n\r\nexport async function addCompany(newCompany)\r\n{\r\n newCompany.pointsToEuroRatio = newCompany.pointsToEuro;\r\n newCompany.euroToPointsRatio = newCompany.euroToPoints;\r\n newCompany.email = newCompany.ownerEmail;\r\n const formData = new FormData();\r\n formData.append(\"name\",newCompany.name);\r\n formData.append(\"logo\",newCompany.logo);\r\n formData.append(\"logoFile\",newCompany.logoFile);\r\n formData.append(\"website\",newCompany.website);\r\n formData.append(\"twitter\",newCompany.twitter);\r\n formData.append(\"instagram\",newCompany.instagram);\r\n formData.append(\"facebook\",newCompany.facebook);\r\n formData.append(\"euroToPointsRatio\",newCompany.euroToPointsRatio);\r\n formData.append(\"pointsToEuroRatio\",newCompany.pointsToEuro);\r\n formData.append(\"email\", newCompany.ownerEmail);\r\n formData.append(\"categoryId\",newCompany.categoryId);\r\n \r\n let addNew = apiEndpoint + \"addCompany\";\r\n const { data } = await http.post(addNew, formData);\r\n return data;\r\n}\r\n\r\nexport async function getCompanyById(id)\r\n{\r\n let getCompany = apiEndpoint+`getcompanybyid?Id=${id}`;\r\n const { data } = await http.get(getCompany);\r\n return data;\r\n}\r\n\r\nexport async function updateCompany(company)\r\n{\r\n company.pointsToEuroRatio = company.pointsToEuro;\r\n company.euroToPointsRatio = company.euroToPoints;\r\n const formData = new FormData();\r\n formData.append(\"id\",company.id)\r\n formData.append(\"name\",company.name);\r\n formData.append(\"logo\",company.logo);\r\n formData.append(\"logoFile\",company.logoFile);\r\n formData.append(\"website\",company.website);\r\n formData.append(\"twitter\",company.twitter);\r\n formData.append(\"instagram\",company.instagram);\r\n formData.append(\"facebook\",company.facebook);\r\n formData.append(\"euroToPointsRatio\",company.euroToPointsRatio);\r\n formData.append(\"pointsToEuroRatio\", company.pointsToEuro);\r\n formData.append(\"ownerEmail\", company.ownerEmail);\r\n formData.append(\"categoryId\",company.categoryId);\r\n let updateCompany = apiEndpoint + `updateCompany`;\r\n const { data } = await http.put(updateCompany, formData);\r\n return data;\r\n}\r\n\r\nexport async function getCompanyByUserEmail(email)\r\n{\r\n let getCompany = apiEndpoint+`getcompanybyemail?email=${email}`;\r\n const { data } = await http.get(getCompany);\r\n return data;\r\n}\r\n\r\n\r\nexport async function assignUserToCompany(model)\r\n{\r\n // let model = { Id: companyId, email: userEmail };\r\n let assignToCompany = apiEndpoint + `addUserToCompany`;\r\n const { data } = await http.post(assignToCompany, model);\r\n return data;\r\n}\r\n\r\n\r\nexport async function deleteCompany(id)\r\n{\r\n let deleteCompany = apiEndpoint + `deleteCompany?Id=${id}`;\r\n const { data } = await http.delete(deleteCompany);\r\n return data;\r\n}","import React, { useContext, useEffect, useState } from \"react\";\r\nimport { TabContext } from \"../../contexts/tabContext\";\r\nimport { tabs } from \"../../config.json\";\r\nimport { useNavigate, useSearchParams } from \"react-router-dom\";\r\nimport { getAllCompanies, deleteCompany } from \"../../services/companyService\";\r\nimport {\r\n Box,\r\n Button,\r\n Container,\r\n IconButton,\r\n TableBody,\r\n TableCell,\r\n TableRow,\r\n Tooltip,\r\n Typography,\r\n} from \"@material-ui/core\";\r\nimport {\r\n Edit,\r\n Visibility,\r\n DeleteOutline,\r\n Add,\r\n Loyalty,\r\n ArrowBack,\r\n} from \"@material-ui/icons\";\r\nimport { ConfirmationDialogContext } from \"../../contexts/confirmationDialogContext\";\r\nimport useTable from \"../../components/common/useTable\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\n\r\nfunction Company() {\r\n const [companies, setCompanies] = useState([]);\r\n const [fromCategories, setFromCategories] = useState(false);\r\n const { changeTab } = useContext(TabContext);\r\n const { openDialog } = useContext(ConfirmationDialogContext);\r\n const { changeCompanyOnwer } = useContext(UserContext);\r\n const navigate = useNavigate();\r\n const [searchParams] = useSearchParams();\r\n const companiesColumn = [\r\n { id: \"name\", label: \"Name\" },\r\n { id: \"category\", label: \"Category\" },\r\n { id: \"ownerEmail\", label: \"Owner\" },\r\n { id: \"actions\", label: \"Actions\", avoidSearch: true },\r\n ];\r\n const {\r\n TableContainer,\r\n TableHeader,\r\n TablePaginationCustom,\r\n recordsAfterPaging,\r\n } = useTable(companies, companiesColumn, [\"name\", \"ownerEmail\"]);\r\n\r\n useEffect(async () => {\r\n changeTab(tabs.Companies);\r\n const { data } = await getAllCompanies();\r\n const categoryId = searchParams.get(\"category\");\r\n if (categoryId !== null) {\r\n setFromCategories(true);\r\n setCompanies(data.filter((c) => c.categoryId === parseInt(categoryId)));\r\n } else {\r\n setCompanies(data);\r\n }\r\n }, []);\r\n\r\n const handleEditClick = (stateDemo) => {\r\n navigate(`/companies/${stateDemo.id}`, {\r\n state: {\r\n euroToPoints: stateDemo.euroToPointsRatio,\r\n pointsToEuro: stateDemo.pointsToEuroRatio,\r\n ...stateDemo,\r\n },\r\n });\r\n };\r\n\r\n const handleDelete = async (id) => {\r\n let companiesInitial = [...companies];\r\n try {\r\n if (id === null) return;\r\n let companiesTemp = companies.filter((c) => c.id !== id);\r\n setCompanies([...companiesTemp]);\r\n await deleteCompany(id);\r\n } catch (e) {\r\n setCompanies([...companiesInitial]);\r\n }\r\n };\r\n\r\n const handleViewClick = (row) => {\r\n changeCompanyOnwer(row.ownerEmail);\r\n navigate(`/companies/${row.id}/stores`, {\r\n state: {\r\n id: row.id,\r\n },\r\n });\r\n };\r\n\r\n const handleViewSales = (row) => {\r\n changeCompanyOnwer(row.ownerEmail);\r\n navigate(\"/companies/sales\", {\r\n state: {\r\n id: row.id,\r\n },\r\n });\r\n };\r\n\r\n return (\r\n \r\n \r\n {fromCategories ? (\r\n navigate(-1)}>\r\n \r\n \r\n ) : (\r\n
\r\n )}\r\n Companies \r\n navigate(\"/companies/add\")}\r\n color=\"primary\"\r\n startIcon={ }\r\n variant=\"contained\"\r\n size=\"small\"\r\n >\r\n Add Company\r\n \r\n \r\n \r\n \r\n \r\n \r\n {recordsAfterPaging()?.length === 0 ? (\r\n \r\n \r\n No Results \r\n \r\n \r\n ) : (\r\n <>\r\n {recordsAfterPaging().map((item) => (\r\n \r\n {item.name} \r\n \r\n {item.category ? item.category : \"None\"}\r\n \r\n \r\n {item.ownerEmail ? item.ownerEmail : \"Not found\"}\r\n \r\n \r\n \r\n \r\n handleViewClick(item)}\r\n color=\"primary\"\r\n >\r\n \r\n \r\n \r\n \r\n handleViewSales(item)}\r\n color=\"primary\"\r\n >\r\n \r\n \r\n \r\n \r\n handleEditClick(item)}\r\n color=\"primary\"\r\n >\r\n \r\n \r\n \r\n \r\n {\r\n openDialog({\r\n title: \"Delete company?\",\r\n body: \"Are you sure you want to delete this company?\",\r\n yesButton: \"Yes\",\r\n noButton: \"No\",\r\n callback: () => handleDelete(item.id),\r\n });\r\n }}\r\n >\r\n \r\n \r\n \r\n \r\n \r\n \r\n ))}\r\n >\r\n )}\r\n \r\n \r\n \r\n \r\n \r\n );\r\n}\r\n\r\nexport default Company;\r\n","import http from \"./httpService\";\r\nimport { apiUrl } from \"../config.json\";\r\n\r\nconst apiEndpoint = apiUrl + \"/useraccount/\";\r\n\r\nexport async function getAllUsers()\r\n{\r\n let users = apiEndpoint + \"getAllUsers\";\r\n const { data } = await http.get(users);\r\n return data;\r\n}\r\n\r\n\r\nexport async function getUsersByCompany(email)\r\n{\r\n let users = apiEndpoint+`getUsersByCompany?email=${email}`;\r\n const { data } = await http.get(users);\r\n return data;\r\n}\r\n\r\nexport async function deleteUser(email)\r\n{\r\n let deleteUser = apiEndpoint + `deleteUser?email=${email}`;\r\n const result = await http.delete(deleteUser);\r\n}\r\n\r\nexport async function getUser(email)\r\n{\r\n let user = apiEndpoint + `getUser?email=${email}`;\r\n const { data } = await http.get(user);\r\n return data;\r\n}\r\n\r\nexport async function authenticateUser()\r\n{\r\n let endpoint = apiEndpoint + \"authenticateUser\";\r\n const { data } = await http.post(endpoint);\r\n return data;\r\n}\r\n\r\nexport async function logOut()\r\n{\r\n let endpoint = apiEndpoint + \"logout\";\r\n const result = await http.post(endpoint);\r\n}\r\n\r\n\r\n","import React, { createContext, useState } from \"react\";\r\n\r\nexport const FormContext = createContext();\r\nfunction FormContextProvoder(props) {\r\n const [data, setData] = useState({\r\n data: \"\",\r\n methods: {\r\n addMethod: () => {},\r\n updateMethod: () => {},\r\n },\r\n validation: () => {},\r\n });\r\n return (\r\n \r\n {props.children}\r\n \r\n );\r\n}\r\n\r\nexport default FormContextProvoder;\r\n","import React, { useContext, useEffect, useState } from \"react\";\r\n\r\nimport { useLocation } from \"react-router\";\r\nimport { TabContext } from \"../../contexts/tabContext\";\r\nimport { tabs } from \"../../config.json\";\r\nimport { useNavigate } from \"react-router-dom\";\r\nimport {\r\n getAllUsers,\r\n deleteUser,\r\n getUsersByCompany,\r\n} from \"../../services/userService\";\r\nimport { FormContext } from \"../../contexts/formContext\";\r\nimport {\r\n Box,\r\n Button,\r\n Container,\r\n IconButton,\r\n TableBody,\r\n TableCell,\r\n TableRow,\r\n Typography,\r\n} from \"@material-ui/core\";\r\nimport { Edit, Visibility, DeleteOutline, Add } from \"@material-ui/icons\";\r\nimport { ConfirmationDialogContext } from \"../../contexts/confirmationDialogContext\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport useTable from \"../../components/common/useTable\";\r\n\r\nfunction Users() {\r\n const [users, setUsers] = useState([]);\r\n const { authed, isAdmin } = useContext(UserContext);\r\n const [admin, setAdmin] = useState(isAdmin());\r\n const data = useContext(FormContext);\r\n const { changeTab } = useContext(TabContext);\r\n const { openDialog } = useContext(ConfirmationDialogContext);\r\n const location = useLocation();\r\n const navigate = useNavigate();\r\n const [locationState, setLocationState] = useState();\r\n const usersColumn = [\r\n // { id: \"userName\", label: \"UserName\" },\r\n { id: \"email\", label: \"Email\" },\r\n { id: \"actions\", label: \"Actions\", avoidSearch: true },\r\n ];\r\n const {\r\n TableContainer,\r\n TableHeader,\r\n TablePaginationCustom,\r\n recordsAfterPaging,\r\n } = useTable(users, usersColumn, [\"email\"]);\r\n\r\n useEffect(() => {\r\n const Init = async () => {\r\n if (authed.email === \"\") return;\r\n changeTab(tabs.Users);\r\n try {\r\n if (isAdmin()) {\r\n setAdmin(true);\r\n var { data } = await getAllUsers();\r\n } else {\r\n setAdmin(false);\r\n var { data } = await getUsersByCompany(authed.email);\r\n }\r\n setUsers(data);\r\n setLocationState({ OwnerEmail: authed.email });\r\n } catch (ex) {}\r\n };\r\n Init();\r\n }, [authed]);\r\n\r\n const handleEditClick = (row) => {\r\n navigate(`${location.pathname}/${row.id}`, {\r\n state: {\r\n ...row,\r\n },\r\n });\r\n };\r\n\r\n const handleDelete = async (email) => {\r\n let usersInitial = [...users];\r\n try {\r\n if (email === null) return;\r\n let usersTemp = users.filter((c) => c.email !== email);\r\n setUsers([...usersTemp]);\r\n // call the api!!\r\n await deleteUser(email);\r\n } catch (e) {\r\n // delete the store here!!!\r\n setUsers([...usersInitial]);\r\n }\r\n };\r\n\r\n const handleViewClick = (row) => {\r\n navigate(`${location.pathname}/userPoints/${row.id}`, {\r\n state: {\r\n email: row.email,\r\n },\r\n });\r\n };\r\n\r\n const handleAssignUser = () => {\r\n navigate(`../stores/assignUser`, { state: locationState });\r\n };\r\n\r\n\r\n return (\r\n <>\r\n \r\n \r\n
\r\n Χρηστες \r\n \r\n \r\n {!admin ?\r\n }\r\n style={{ marginRight: \"10px\" }}\r\n variant=\"contained\"\r\n size=\"small\"\r\n >\r\n Αναθεση Χρηστη \r\n \r\n :
}\r\n }\r\n variant=\"contained\"\r\n onClick={() => {\r\n navigate(\"/users/add\");\r\n }}\r\n >\r\n Προσθηκη Χρηστη\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {recordsAfterPaging()?.length === 0 ? (\r\n \r\n \r\n No Results \r\n \r\n \r\n ) : (\r\n <>\r\n {recordsAfterPaging().map((item) => (\r\n \r\n {/* {item.userName} */}\r\n {item.email} \r\n \r\n \r\n handleViewClick(item)}\r\n startIcon={ }\r\n >\r\n View Points\r\n \r\n {admin && (\r\n \r\n handleEditClick(item)}\r\n color=\"primary\"\r\n >\r\n \r\n \r\n {\r\n openDialog({\r\n title: \"Delete user?\",\r\n body: \"Are you sure you want to delete this user?\",\r\n yesButton: \"Yes\",\r\n noButton: \"No\",\r\n callback: () => handleDelete(item.email),\r\n });\r\n }}\r\n >\r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n ))}\r\n >\r\n )}\r\n \r\n \r\n \r\n \r\n \r\n >\r\n );\r\n}\r\n\r\nexport default Users;\r\n","import http from \"./httpService\";\r\nimport { apiUrl } from \"../config.json\";\r\n\r\n\r\nconst apiEndpoint = apiUrl + \"/sales/\";\r\n\r\nexport async function getAllSales()\r\n{\r\n let allSales = apiEndpoint + \"getAllSales\";\r\n const { data } = await http.get(allSales);\r\n return data;\r\n}\r\n\r\nexport async function addSale(newSale)\r\n{\r\n const formData = new FormData();\r\n formData.append(\"imageFile\",newSale.imageFile);\r\n formData.append(\"image\",newSale.image)\r\n formData.append(\"title\", newSale.title)\r\n formData.append(\"dateStart\", newSale.dateStart);\r\n formData.append(\"dateEnd\", newSale.dateEnd);\r\n formData.append(\"description\", newSale.description);\r\n formData.append(\"email\", newSale.email);\r\n let addNew = apiEndpoint + \"addSale\";\r\n console.log(\"addNew: \"+addNew);\r\n console.log(\"formData: \"+formData);\r\n const { data } = await http.post(addNew, formData);\r\n return data;\r\n}\r\n\r\nexport async function getSaleById(email,id=null)\r\n{\r\n let getSales = apiEndpoint+`getSales?`;\r\n if (id !== null)\r\n {\r\n getSales += `id=${id}`;\r\n }\r\n else {\r\n getSales+=`email=${email}`\r\n }\r\n const { data } = await http.get(getSales);\r\n return data;\r\n}\r\n\r\nexport async function updateSale(sale)\r\n{\r\n const formData = new FormData();\r\n formData.append(\"imageFile\",sale.imageFile);\r\n formData.append(\"image\",sale.image)\r\n formData.append(\"title\", sale.title)\r\n formData.append(\"dateStart\", sale.dateStart);\r\n formData.append(\"dateEnd\", sale.dateEnd);\r\n formData.append(\"description\", sale.description);\r\n formData.append(\"email\", sale.email);\r\n formData.append(\"id\", sale.id);\r\n let updateCompany = apiEndpoint + `updateSale`;\r\n const { data } = await http.put(updateCompany, formData);\r\n return data;\r\n}\r\n\r\n\r\nexport async function deleteSale(id)\r\n{\r\n let deleteSale = apiEndpoint + `deleteSale?Id=${id}`;\r\n const { data } = await http.delete(deleteSale);\r\n return data;\r\n}","export function dateConfiguration(dateString)\r\n{\r\n if (dateString)\r\n {\r\n \r\n const splitArrayTemp = dateString.split(\"T\");\r\n return splitArrayTemp[0];\r\n }\r\n else {\r\n return \"\";\r\n }\r\n}","import React, { useContext } from \"react\";\r\nimport { TabContext } from \"../../contexts/tabContext\";\r\nimport { tabs } from \"../../config.json\";\r\nimport { Link, useLocation, useNavigate } from \"react-router-dom\";\r\nimport {\r\n getSaleById,\r\n getAllSales,\r\n addSale,\r\n updateSale,\r\n deleteSale,\r\n} from \"../../services/salesService\";\r\nimport { useState } from \"react\";\r\nimport { useEffect } from \"react\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport {\r\n Box,\r\n Button,\r\n Container,\r\n IconButton,\r\n TableBody,\r\n TableCell,\r\n TableRow,\r\n Typography,\r\n Grid\r\n} from \"@material-ui/core\";\r\nimport { Edit, DeleteOutline, ArrowBack, Add } from \"@material-ui/icons\";\r\nimport { red } from \"@material-ui/core/colors\";\r\nimport { ConfirmationDialogContext } from \"../../contexts/confirmationDialogContext\";\r\nimport useTable from \"../../components/common/useTable\";\r\nimport { dateConfiguration } from \"../../utilities/dataConfiguration\";\r\n\r\nfunction Sales() {\r\n const [sales, setSales] = useState([]);\r\n const { authed, isAdmin, companyOwnerEmail } = useContext(UserContext);\r\n const [admin, setAdmin] = useState(isAdmin());\r\n const { openDialog } = useContext(ConfirmationDialogContext);\r\n const location = useLocation();\r\n const userEmail = isAdmin() ? companyOwnerEmail : authed.email;\r\n const navigate = useNavigate();\r\n const salesColumn = [\r\n { id: \"title\", label: \"Title\" },\r\n { id: \"dateStart\", label: \"Date Start\" },\r\n { id: \"dateEnd\", label: \"Date End\" },\r\n { id: \"actions\", label: \"Action\", avoidSearch: true },\r\n ];\r\n const {\r\n TableContainer,\r\n TableHeader,\r\n TablePaginationCustom,\r\n recordsAfterPaging,\r\n } = useTable(sales, salesColumn, [\"title\", \"dateStart\", \"dateEnd\"]);\r\n useEffect(() => {\r\n const Init = async () => {\r\n const { data } = await getSaleById(userEmail);\r\n setSales(data);\r\n };\r\n Init();\r\n }, [authed, companyOwnerEmail]);\r\n\r\n useEffect(() => {\r\n setAdmin(isAdmin());\r\n }, [authed]);\r\n\r\n const handleAddSale = (e) => {\r\n e.preventDefault();\r\n let addPath = location.pathname + \"/add\";\r\n navigate(addPath);\r\n };\r\n\r\n const handleAdd = async (neew) => {\r\n await addSale(neew);\r\n };\r\n\r\n const handleOnDelete = (params) => {\r\n openDialog({\r\n title: \"Delete sale?\",\r\n body: \"Are you sure you want to delete this sale?\",\r\n yesButton: \"Yes\",\r\n noButton: \"No\",\r\n callback: () => handleDelete(params.row.id),\r\n });\r\n };\r\n\r\n const handleDelete = async (id) => {\r\n let salesInitial = [...sales];\r\n try {\r\n if (id === null) return;\r\n let salesTemp = sales.filter((c) => c.id !== id);\r\n setSales([...salesTemp]);\r\n // call the api!!\r\n await deleteSale(id);\r\n } catch (e) {\r\n // delete the store here!!!\r\n setSales([...salesInitial]);\r\n }\r\n };\r\n\r\n const handleEditClick = (row) => {\r\n navigate(`/sales/${row.id}`, {\r\n state: {\r\n ...row,\r\n },\r\n });\r\n };\r\n\r\n \r\n return (\r\n \r\n \r\n {admin ? (\r\n navigate(-1)}>\r\n \r\n \r\n ) : (\r\n
\r\n )}\r\n\r\n {/* navigate(-1)}>\r\n \r\n */}\r\n Προσφορές \r\n }\r\n variant=\"contained\"\r\n size=\"small\"\r\n >\r\n Προσθηκη Προσφορας\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {recordsAfterPaging()?.length === 0 ? (\r\n \r\n \r\n No Results \r\n \r\n \r\n ) : (\r\n <>\r\n {recordsAfterPaging().map((item) => (\r\n \r\n {item.title} \r\n {dateConfiguration(item.dateStart)} \r\n {dateConfiguration(item.dateEnd)} \r\n \r\n \r\n handleEditClick(item)}\r\n color=\"primary\"\r\n >\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n ))}\r\n >\r\n )}\r\n\r\n {/* */}\r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n}\r\n\r\nexport default Sales;\r\n","import {\r\n Box,\r\n makeStyles,\r\n Menu,\r\n MenuItem,\r\n Select,\r\n Typography,\r\n} from \"@material-ui/core\";\r\nimport _ from \"lodash\";\r\nimport React from \"react\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n formInputField: {\r\n \"& input:not([type=file]),& textarea\": {\r\n border: \"none\",\r\n backgroundColor: \"rgb(234,239,239)\",\r\n padding: \"10px\",\r\n outline: \"none\",\r\n width: \"100%\",\r\n borderRadius: \"5px\",\r\n fontSize: \"15px\",\r\n resize: \"none\",\r\n color: \"rgb(120,130,146)\",\r\n },\r\n \"& img\": {\r\n width: \"80px\",\r\n height: \"80px\",\r\n borderRadius: \"15px\",\r\n },\r\n },\r\n}));\r\n\r\nfunction FormInput({\r\n label,\r\n value,\r\n objKey,\r\n valueChange,\r\n disableInput,\r\n maxPrice,\r\n minPrice,\r\n type,\r\n imageObj,\r\n updateImage,\r\n imageName,\r\n imageFile,\r\n selectList,\r\n selectValueKey,\r\n selectNameKey,\r\n}) {\r\n const inputType = type ?? \"text\";\r\n const classes = useStyles();\r\n const handleOnChange = (e) => {\r\n if (inputType === \"checkbox\") {\r\n valueChange(objKey, e.target.checked);\r\n } else if (inputType === \"select\") {\r\n valueChange(objKey, e.target.value);\r\n } else {\r\n if (maxPrice) {\r\n if (e.currentTarget.value > maxPrice) return;\r\n }\r\n if (minPrice !== null) {\r\n if (e.currentTarget.value < minPrice) {\r\n valueChange(objKey, \"\");\r\n return;\r\n }\r\n }\r\n valueChange(objKey, e.currentTarget.value);\r\n }\r\n };\r\n\r\n const handleImageChange = (e) => {\r\n // check if we selected an image!!!\r\n if (e.target.files && e.target.files[0]) {\r\n let imageFileTemp = e.target.files[0];\r\n const reader = new FileReader();\r\n reader.onload = (x) => {\r\n updateImage(x.target.result, imageFileTemp);\r\n };\r\n reader.readAsDataURL(imageFileTemp);\r\n } else {\r\n updateImage(\"\", null);\r\n }\r\n };\r\n\r\n const renderInput = () => {\r\n switch (inputType) {\r\n case \"checkbox\":\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n case \"image\":\r\n return (\r\n <>\r\n \r\n {imageName !== null && imageName !== \"\" && (\r\n \r\n )}\r\n\r\n \r\n \r\n >\r\n );\r\n case \"tel\":\r\n return (\r\n \r\n );\r\n case \"textarea\":\r\n return (\r\n \r\n );\r\n case \"select\":\r\n console.log(\"To value poio einai?:\", value);\r\n return (\r\n \r\n None \r\n {selectList?.map((model) => (\r\n \r\n {_.get(model, selectNameKey)}\r\n \r\n ))}\r\n \r\n );\r\n default:\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n }\r\n };\r\n\r\n return (\r\n <>\r\n \r\n \r\n {label}\r\n \r\n {/* \r\n
{label} \r\n */}\r\n {renderInput()}
\r\n \r\n >\r\n );\r\n}\r\n\r\nexport default FormInput;\r\n","export function handleErrors(ex,setErrors)\r\n{\r\n const { response } = ex;\r\n if (response) {\r\n const {\r\n response: {\r\n data: { errorMessage },\r\n },\r\n } = ex;\r\n if (errorMessage) {\r\n if (typeof errorMessage === \"string\") {\r\n setErrors([errorMessage]);\r\n } else {\r\n setErrors(errorMessage);\r\n }\r\n }\r\n }\r\n else {\r\n setErrors([ex]);\r\n }\r\n}","import React from \"react\";\r\nimport { useState } from \"react\";\r\nimport _ from \"lodash\";\r\nimport { formTypes } from \"../../config.json\";\r\nimport { handleErrors } from \"../../utilities/handleErrors\";\r\nimport Snackbar from \"@material-ui/core/Snackbar\";\r\nimport MuiAlert from \"@material-ui/lab/Alert\";\r\nimport { useEffect } from \"react\";\r\nimport { useNavigate } from \"react-router-dom\";\r\nimport { ArrowBack } from \"@material-ui/icons\";\r\nimport { green } from \"@material-ui/core/colors\";\r\nimport {\r\n Box,\r\n Button,\r\n CircularProgress,\r\n Container,\r\n Grid,\r\n IconButton,\r\n makeStyles,\r\n Paper,\r\n} from \"@material-ui/core\";\r\nconst Alert = React.forwardRef(function Alert(props, ref) {\r\n return ;\r\n});\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n wrapper: {\r\n margin: \"5px\",\r\n position: \"relative\",\r\n },\r\n buttonProgress: {\r\n color: green[500],\r\n position: \"absolute\",\r\n top: \"50%\",\r\n left: \"50%\",\r\n marginTop: -12,\r\n marginLeft: -12,\r\n },\r\n errors: {\r\n margin: \"5px\",\r\n \"& ul\": {\r\n listStyle: \"none\",\r\n },\r\n \"& li\": {\r\n display: \"flex\",\r\n color: \"red\",\r\n },\r\n },\r\n}));\r\n\r\nfunction FormTemplate({\r\n dataForm,\r\n setDataForm,\r\n addMethod,\r\n updateMethod,\r\n formType,\r\n children,\r\n handleDisableInput,\r\n addText,\r\n validations,\r\n customHandleClick,\r\n}) {\r\n const [errors, setErrors] = useState([]);\r\n const [showSnackbar, setShowSnackbar] = useState(false);\r\n const [edit, setEdit] = useState(false);\r\n const [loading, setLoading] = useState(false);\r\n const navigate = useNavigate();\r\n const addTextTitle = addText ? addText : \"Add\";\r\n const checkValidations = validations ? validations : () => [];\r\n const classes = useStyles();\r\n\r\n useEffect(() => {\r\n handleDisableInput(edit);\r\n }, [edit]);\r\n\r\n const handleClick = async () => {\r\n if (loading) return;\r\n if (formType === formTypes.view && !edit) {\r\n // ara einai sto view ara handle to edit click edw pera!!\r\n setEdit(true);\r\n return;\r\n }\r\n try {\r\n setLoading(true);\r\n setErrors([]);\r\n if (formType === formTypes.add) {\r\n // handle the add click\r\n let addErrors = checkValidations();\r\n if (addErrors.length > 0) {\r\n setErrors([...addErrors]);\r\n } else {\r\n console.log({ ...dataForm.details });\r\n await addMethod({ ...dataForm.details });\r\n setShowSnackbar(true);\r\n }\r\n } else {\r\n let updateErrors = checkValidations();\r\n if (updateErrors.length > 0) {\r\n setErrors([...updateErrors]);\r\n } else {\r\n await updateMethod({ ...dataForm.details });\r\n setDataForm({ ...dataForm, initialData: { ...dataForm.details } });\r\n setEdit(false);\r\n setShowSnackbar(true);\r\n }\r\n }\r\n } catch (ex) {\r\n handleErrors(ex, setErrors);\r\n } finally {\r\n setLoading(false);\r\n }\r\n };\r\n\r\n const handleSnackbarClose = (event, reason) => {\r\n if (reason === \"clickaway\") {\r\n return;\r\n }\r\n setShowSnackbar(false);\r\n };\r\n\r\n const handleCancelClick = () => {\r\n setEdit(false);\r\n setDataForm({ ...dataForm, details: { ...dataForm.initialData } });\r\n };\r\n return (\r\n <>\r\n \r\n \r\n navigate(-1)}>\r\n \r\n \r\n \r\n \r\n \r\n {children}\r\n \r\n {edit && (\r\n \r\n \r\n Cancel\r\n \r\n
\r\n )}\r\n \r\n \r\n {formType === formTypes.view && (\r\n <>{edit ? \"Update\" : \"Edit\"}>\r\n )}\r\n {formType === formTypes.add && addTextTitle}\r\n \r\n {loading && (\r\n \r\n )}\r\n
\r\n \r\n \r\n
\r\n {errors.map((error, index) => (\r\n {error} \r\n ))}\r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Changes applied successfully!!\r\n \r\n \r\n >\r\n );\r\n}\r\n\r\nexport default FormTemplate;\r\n","import React, { useEffect } from \"react\";\r\nimport { useLocation } from \"react-router-dom\";\r\nimport { useState } from \"react\";\r\nimport { formTypes } from \"../config.json\";\r\nimport _ from \"lodash\";\r\nexport function FormInputHook({ defaultData, formType }) {\r\n const location = useLocation();\r\n const data = location.state;\r\n const [dataForm, setDataForm] = useState({\r\n initialData: { ...defaultData, ...data },\r\n details: { ...defaultData, ...data },\r\n });\r\n const [disableInput, setDisableInput] = useState(true);\r\n useEffect(() => {\r\n if (formType === formTypes.add) setDisableInput(false);\r\n }, []);\r\n // const initialValue = data;\r\n const updateValue = (key, newValue) => {\r\n const prevState = { ...dataForm.details };\r\n _.set(prevState, key, newValue);\r\n setDataForm({ ...dataForm, details: { ...prevState } });\r\n };\r\n\r\n const handleDisableInput = (edit) => {\r\n if (formType == formTypes.view && !edit) setDisableInput(true);\r\n else setDisableInput(false);\r\n };\r\n return {\r\n dataForm,\r\n setDataForm,\r\n disableInput,\r\n setDisableInput,\r\n updateValue,\r\n handleDisableInput,\r\n };\r\n}\r\n","import React from \"react\";\r\nimport FormInput from \"../../components/common/formInput\";\r\nimport { addSale, updateSale } from \"../../services/salesService\";\r\nimport FormTemplate from \"../../components/common/formTemplate\";\r\nimport { FormInputHook } from \"../../utilities/formInputHook\";\r\nimport { formTypes } from \"../../config.json\";\r\nimport { useContext } from \"react\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport { useEffect } from \"react\";\r\n\r\nfunction SalesForm({ defaultData, formType }) {\r\n const { authed, companyOwnerEmail, isAdmin } = useContext(UserContext);\r\n const {\r\n dataForm,\r\n setDataForm,\r\n disableInput,\r\n updateValue,\r\n handleDisableInput,\r\n } = FormInputHook({ defaultData, formType });\r\n const updateImage = (imageName, imageFile) => {\r\n setDataForm({\r\n ...dataForm,\r\n details: {\r\n ...dataForm.details,\r\n image: imageName,\r\n imageFile,\r\n email: isAdmin() ? companyOwnerEmail : authed.email,\r\n },\r\n });\r\n };\r\n\r\n useEffect(() => {\r\n setDataForm({\r\n ...dataForm,\r\n details: {\r\n ...dataForm.details,\r\n email: isAdmin() ? companyOwnerEmail : authed.email,\r\n },\r\n });\r\n }, [authed]);\r\n\r\n const addSaleValidation = () => {\r\n const errors = [];\r\n const data = { ...dataForm.details };\r\n if (data.title === null || data.title.trim() === \"\") {\r\n errors.push(\"Title is required.\");\r\n }\r\n if (data.description === null || data.description.trim() === \"\") {\r\n errors.push(\"Description is required.\");\r\n }\r\n if (data.dateStart === 0) {\r\n errors.push(\"Date start is required.\");\r\n }\r\n if (data.dateEnd === 0) {\r\n errors.push(\"Date end is required.\");\r\n }\r\n if (data.dateStart !== 0 && data.dataEnd !== 0) {\r\n if (Date.parse(data.dateStart) >= Date.parse(data.dateEnd)) {\r\n errors.push(\"Date start must be less than date end\");\r\n }\r\n }\r\n return errors;\r\n };\r\n const updateSaleValidation = () => {\r\n const errors = [];\r\n const data = { ...dataForm.details };\r\n if (data.title === null || data.title.trim() === \"\") {\r\n errors.push(\"Title is required.\");\r\n }\r\n if (data.description === null || data.description.trim() === \"\") {\r\n errors.push(\"Description is required.\");\r\n }\r\n if (data.dateStart === 0) {\r\n errors.push(\"Date start is required.\");\r\n }\r\n if (data.dateEnd === 0) {\r\n errors.push(\"Date end is required.\");\r\n }\r\n if (data.dateStart !== 0 && data.dataEnd !== 0) {\r\n if (Date.parse(data.dateStart) >= Date.parse(data.dateEnd)) {\r\n errors.push(\"Date start must be less than date end\");\r\n }\r\n }\r\n return errors;\r\n };\r\n const validations = () => {\r\n if (formType === formTypes.add) {\r\n return addSaleValidation();\r\n } else {\r\n return updateSaleValidation();\r\n }\r\n };\r\n\r\n return (\r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n \r\n );\r\n}\r\n\r\nexport default SalesForm;\r\n","import React, { useState, useContext, useEffect } from \"react\";\r\nimport FormInput from \"../../components/common/formInput\";\r\nimport FormTemplate from \"../../components/common/formTemplate\";\r\nimport { FormInputHook } from \"../../utilities/formInputHook\";\r\nimport { updateAccount } from \"../../services/userAccountService\";\r\nimport { getUser } from \"../../services/userService\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport { formTypes } from \"../../config.json\";\r\n\r\nfunction Profile() {\r\n const formType = formTypes.view;\r\n const defaultData = {};\r\n const {\r\n dataForm,\r\n setDataForm,\r\n disableInput,\r\n updateValue,\r\n handleDisableInput,\r\n } = FormInputHook({ defaultData, formType });\r\n const { authed } = useContext(UserContext);\r\n useEffect(() => {\r\n const Init = async () => {\r\n // get the user details!!\r\n if (authed.email === \"\") return;\r\n const { data } = await getUser(authed.email);\r\n setDataForm({\r\n ...dataForm,\r\n initialData: { ...data },\r\n details: { ...data },\r\n });\r\n };\r\n Init();\r\n }, [authed]);\r\n return (\r\n \r\n \r\n \r\n );\r\n}\r\n\r\nexport default Profile;\r\n","import React, { useCallback, useRef, useState } from \"react\";\r\nimport { GoogleMap, useLoadScript, Marker } from \"@react-google-maps/api\";\r\nimport mapStyles from \"../../utilities/mapStyles\";\r\nimport { Box, makeStyles, Typography } from \"@material-ui/core\";\r\nimport config from \"../../config.json\";\r\n\r\nconst mapContainerStyle = {\r\n width: \"100%\",\r\n height: \"100%\",\r\n};\r\n\r\nconst options = {\r\n styles: mapStyles,\r\n disableDefaultUI: true,\r\n zoomControl: true,\r\n};\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n mapWrapper: {\r\n position: \"relative\",\r\n width: \"100%\",\r\n height: \"100%\",\r\n },\r\n mapHeader: {\r\n position: \"absolute\",\r\n top: \"1%\",\r\n left: \"1%\",\r\n zIndex: \"2\",\r\n },\r\n}));\r\n\r\nexport function GoogleMapContainer({ marker }) {\r\n const center = {\r\n lat: marker.lat,\r\n lng: marker.lng,\r\n };\r\n const { isLoaded, loadError } = useLoadScript({\r\n // googleMapsApiKey: process.env.REACT_APP_GOOGLE_MAPS_API_KEY,\r\n googleMapsApiKey: config.REACT_APP_GOOGLE_MAPS_API_KEY,\r\n libraries: [\"places\"],\r\n });\r\n const classes = useStyles();\r\n const [markers, setMarkers] = useState([]);\r\n // const onMapClick = useCallback((event) => {\r\n // setMarkers([\r\n // ...markers,\r\n // {\r\n // lat: event.latLng.lat(),\r\n // lng: event.latLng.lng(),\r\n // time: new Date(),\r\n // },\r\n // ]);\r\n // }, []);\r\n\r\n const mapRef = useRef();\r\n const onMapLoad = useCallback((map) => {\r\n mapRef.current = map;\r\n }, []);\r\n\r\n if (loadError) return \"Error loading maps\";\r\n if (!isLoaded) return \"Loading Maps\";\r\n return (\r\n <>\r\n \r\n
\r\n \r\n Λειβαδιά Loayalty \r\n \r\n
\r\n \r\n \r\n
\r\n >\r\n );\r\n}\r\n\r\nexport default GoogleMapContainer;\r\n","export default [\r\n {\r\n \"featureType\": \"water\",\r\n \"elementType\": \"geometry\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#e9e9e9\"\r\n },\r\n {\r\n \"lightness\": 17\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"landscape\",\r\n \"elementType\": \"geometry\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#f5f5f5\"\r\n },\r\n {\r\n \"lightness\": 20\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"road.highway\",\r\n \"elementType\": \"geometry.fill\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#ffffff\"\r\n },\r\n {\r\n \"lightness\": 17\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"road.highway\",\r\n \"elementType\": \"geometry.stroke\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#ffffff\"\r\n },\r\n {\r\n \"lightness\": 29\r\n },\r\n {\r\n \"weight\": 0.2\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"road.arterial\",\r\n \"elementType\": \"geometry\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#ffffff\"\r\n },\r\n {\r\n \"lightness\": 18\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"road.local\",\r\n \"elementType\": \"geometry\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#ffffff\"\r\n },\r\n {\r\n \"lightness\": 16\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"poi\",\r\n \"elementType\": \"geometry\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#f5f5f5\"\r\n },\r\n {\r\n \"lightness\": 21\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"poi.park\",\r\n \"elementType\": \"geometry\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#dedede\"\r\n },\r\n {\r\n \"lightness\": 21\r\n }\r\n ]\r\n },\r\n {\r\n \"elementType\": \"labels.text.stroke\",\r\n \"stylers\": [\r\n {\r\n \"visibility\": \"on\"\r\n },\r\n {\r\n \"color\": \"#ffffff\"\r\n },\r\n {\r\n \"lightness\": 16\r\n }\r\n ]\r\n },\r\n {\r\n \"elementType\": \"labels.text.fill\",\r\n \"stylers\": [\r\n {\r\n \"saturation\": 36\r\n },\r\n {\r\n \"color\": \"#333333\"\r\n },\r\n {\r\n \"lightness\": 40\r\n }\r\n ]\r\n },\r\n {\r\n \"elementType\": \"labels.icon\",\r\n \"stylers\": [\r\n {\r\n \"visibility\": \"off\"\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"transit\",\r\n \"elementType\": \"geometry\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#f2f2f2\"\r\n },\r\n {\r\n \"lightness\": 19\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"administrative\",\r\n \"elementType\": \"geometry.fill\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#fefefe\"\r\n },\r\n {\r\n \"lightness\": 20\r\n }\r\n ]\r\n },\r\n {\r\n \"featureType\": \"administrative\",\r\n \"elementType\": \"geometry.stroke\",\r\n \"stylers\": [\r\n {\r\n \"color\": \"#fefefe\"\r\n },\r\n {\r\n \"lightness\": 17\r\n },\r\n {\r\n \"weight\": 1.2\r\n }\r\n ]\r\n }\r\n]","import React, { useEffect } from \"react\";\r\nimport FormInput from \"../../components/common/formInput\";\r\nimport { useLocation } from \"react-router-dom\";\r\nimport { useState } from \"react\";\r\nimport { formTypes } from \"../../config.json\";\r\nimport FormTemplate from \"../../components/common/formTemplate\";\r\nimport { addStore, updateStore } from \"../../services/storeService\";\r\nimport _ from \"lodash\";\r\nimport { FormInputHook } from \"../../utilities/formInputHook\";\r\nimport { useContext } from \"react\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport config from \"../../config.json\";\r\nimport {\r\n Box,\r\n Button,\r\n Dialog,\r\n DialogActions,\r\n DialogContent,\r\n DialogContentText,\r\n DialogTitle,\r\n} from \"@material-ui/core\";\r\nimport Geocode from \"react-geocode\";\r\nimport { Typography } from \"@material-ui/core\";\r\nimport { GoogleMapContainer } from \"../../components/common/GoogleMap\";\r\n\r\nfunction StoresForm({ defaultData, formType }) {\r\n Geocode.setApiKey(process.env.REACT_APP_GOOGLE_MAPS_API_KEY);\r\n Geocode.setApiKey(config.REACT_APP_GOOGLE_MAPS_API_KEY);\r\n const { authed } = useContext(UserContext);\r\n const [open, setOpen] = useState(false);\r\n const location = useLocation();\r\n const [marker, setMarker] = useState({\r\n lat: 0,\r\n long: 0,\r\n });\r\n const {\r\n dataForm,\r\n setDataForm,\r\n disableInput,\r\n updateValue,\r\n handleDisableInput,\r\n } = FormInputHook({\r\n defaultData: { ...defaultData, ...location.state },\r\n formType,\r\n });\r\n\r\n // console.log(location.state);\r\n const [locationError, setLocationError] = useState(\"\");\r\n const validations = () => {\r\n const errors = [];\r\n const data = { ...dataForm.details };\r\n console.log(data);\r\n if (data.address === null || data.address.trim() === \"\") {\r\n errors.push(\"Address is required.\");\r\n }\r\n return errors;\r\n };\r\n\r\n const handleClickOpen = async (s) => {\r\n // edw to geocode na dw an einai legit to address !!!\r\n console.log(\"To address:\", dataForm.details.address);\r\n try {\r\n var response = await Geocode.fromAddress(dataForm.details.address);\r\n // take the lng and lat!!!\r\n const { lat, lng } = response.results[0].geometry.location;\r\n const sendModel = { ...dataForm.details, latitude: lat, longitude: lng };\r\n console.log(response);\r\n await addStore(sendModel);\r\n setDataForm({ ...dataForm, details: { ...sendModel } });\r\n console.log(response);\r\n } catch (ex) {\r\n console.log(ex);\r\n throw \"Address is not valid!\";\r\n }\r\n console.log(\"open\");\r\n //setOpen(true);\r\n };\r\n\r\n const handleUpdate = async () => {\r\n // edw to geocode na dw an einai legit to address !!!\r\n console.log(\"To address sto update:\", dataForm.details.address);\r\n try {\r\n var response = await Geocode.fromAddress(dataForm.details.address);\r\n // take the lng and lat!!!\r\n const { lat, lng } = response.results[0].geometry.location;\r\n const sendModel = { ...dataForm.details, latitude: lat, longitude: lng };\r\n console.log(response);\r\n await updateStore(sendModel);\r\n setDataForm({ ...dataForm, details: { ...sendModel } });\r\n console.log(response);\r\n } catch (ex) {\r\n console.log(ex);\r\n throw \"Address is not valid!\";\r\n }\r\n console.log(\"open\");\r\n };\r\n\r\n const handleClose = (s) => {\r\n setOpen(false);\r\n };\r\n\r\n const handleCheck = async () => {\r\n // check the validation first and then check if the address is valid!!\r\n // if it is valid then open the dialog with the map and pass the marker\r\n const data = { ...dataForm.details };\r\n console.log(\"sto edit:\", data);\r\n setLocationError(\"\");\r\n\r\n if (data.address === null || data.address.trim() === \"\") {\r\n setLocationError(\"Address field is required!\");\r\n return;\r\n }\r\n try {\r\n console.log(\"To details address\", dataForm.details.address);\r\n var response = await Geocode.fromAddress(dataForm.details.address);\r\n const { lat, lng } = response.results[0].geometry.location;\r\n setMarker({ lat, lng });\r\n setOpen(true);\r\n } catch (ex) {\r\n setLocationError(\"Address is not valid\");\r\n }\r\n };\r\n\r\n const handleCustomClick = (r) => {\r\n console.log(dataForm);\r\n //var resposne = await Geocode.fromAddress(dataForm.details.address);\r\n //setOpen(true);\r\n };\r\n\r\n const handleConfirm = () => {\r\n console.log(\"Confirm!!\");\r\n };\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n For more accurate location please pass the postal code or location\r\n for example:\r\n Filonos 49-43, 321 00 or Filonos 49-43, Leivadia \r\n \r\n \r\n \r\n \r\n Check\r\n \r\n \r\n {locationError}\r\n \r\n
\r\n \r\n \r\n
\r\n \r\n \r\n {\"Confirm location\"} \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Cancel\r\n \r\n Confirm \r\n \r\n \r\n >\r\n );\r\n}\r\n\r\nexport default StoresForm;\r\n","import React from \"react\";\r\nimport FormInput from \"../../components/common/formInput\";\r\nimport FormTemplate from \"../../components/common/formTemplate\";\r\nimport { FormInputHook } from \"../../utilities/formInputHook\";\r\nimport { assignUserToCompany } from \"../../services/companyService\";\r\n\r\nfunction AssignUserToCompany({ defaultData, formType }) {\r\n const {\r\n dataForm,\r\n setDataForm,\r\n disableInput,\r\n updateValue,\r\n handleDisableInput,\r\n } = FormInputHook({ defaultData, formType });\r\n const validations = () => {\r\n const errors = [];\r\n const data = { ...dataForm.details };\r\n if (data.email === null || data.email.trim() === \"\") {\r\n errors.push(\"User email is required.\");\r\n }\r\n return errors;\r\n };\r\n return (\r\n null}\r\n handleDisableInput={handleDisableInput}\r\n validations={validations}\r\n >\r\n \r\n \r\n );\r\n}\r\n\r\nexport default AssignUserToCompany;\r\n","import http from \"./httpService\";\r\nimport { apiUrl } from \"../config.json\";\r\n\r\n\r\nconst apiEndpoint = apiUrl + \"/categories/\";\r\n\r\nexport async function getCategories()\r\n{\r\n let categories = apiEndpoint + \"getCategories\";\r\n const { data } = await http.get(categories);\r\n return data;\r\n}\r\n\r\nexport async function getCategoryById(id)\r\n{\r\n let category = apiEndpoint + `getCategory?Id=${id}`;\r\n const { data } = await http.get(category);\r\n return data;\r\n}\r\n\r\nexport async function updateCategory(category)\r\n{\r\n let updateCategory = apiEndpoint + \"updateCategory\";\r\n const { data } = await http.put(updateCategory, category);\r\n return data;\r\n}\r\n\r\nexport async function addCategory(category)\r\n{\r\n let addCategory = apiEndpoint + \"addCategory\";\r\n const { data } = await http.post(addCategory,category);\r\n}\r\n\r\nexport async function deleteCategory(id)\r\n{\r\n let deleteCategory = apiEndpoint + `deleteCategory?id=${id}`;\r\n const { data } = await http.delete(deleteCategory);\r\n return data;\r\n}","import { DetailsOutlined, Forward } from \"@material-ui/icons\";\r\nimport React, { useEffect } from \"react\";\r\nimport FormInput from \"../../components/common/formInput\";\r\nimport FormTemplate from \"../../components/common/formTemplate\";\r\nimport { FormInputHook } from \"../../utilities/formInputHook\";\r\nimport { addCompany, updateCompany } from \"../../services/companyService\";\r\nimport { getCategories } from \"../../services/categoriesService\";\r\nimport {\r\n Box,\r\n Divider,\r\n Grid,\r\n Paper,\r\n TextField,\r\n Typography,\r\n} from \"@material-ui/core\";\r\nimport { useState } from \"react\";\r\n\r\nexport function CompanyForm({ defaultData, formType }) {\r\n // const handleUpdate =\r\n const {\r\n dataForm,\r\n setDataForm,\r\n disableInput,\r\n updateValue,\r\n handleDisableInput,\r\n } = FormInputHook({ defaultData, formType });\r\n const updateImage = (imageName, imageFile) => {\r\n setDataForm({\r\n ...dataForm,\r\n details: { ...dataForm.details, logo: imageName, logoFile: imageFile },\r\n });\r\n };\r\n\r\n const [redeemPoints, setRedeemPoints] = useState(1);\r\n const [categories, setCategories] = useState([]);\r\n const [redeemEuroResult, setRedeemEuroResult] = useState(\r\n dataForm.details[\"pointsToEuro\"] * redeemPoints\r\n );\r\n\r\n const [exchangeEuro, setExchangeEuro] = useState(1);\r\n const [earnPoints, setEarnPoints] = useState(\r\n dataForm.details[\"euroToPoints\"] * exchangeEuro\r\n );\r\n\r\n useEffect(() => {\r\n const Init = async () => {\r\n const { data } = await getCategories();\r\n setCategories(data);\r\n };\r\n Init();\r\n }, []);\r\n\r\n useEffect(() => {\r\n setRedeemEuroResult(redeemPoints / dataForm.details[\"pointsToEuro\"]);\r\n }, [redeemPoints]);\r\n\r\n useEffect(() => {\r\n setEarnPoints(dataForm.details[\"euroToPoints\"] * exchangeEuro);\r\n }, [exchangeEuro]);\r\n\r\n const validations = () => {\r\n const errors = [];\r\n const data = { ...dataForm.details };\r\n if (data.name === null || data.name.trim() === \"\") {\r\n errors.push(\"Company name is required\");\r\n }\r\n if (data.euroToPoints === null || data.euroToPoints <= 0) {\r\n errors.push(\"Euro to points ratio must be positive and greater than 0.\");\r\n }\r\n if (data.pointsToEuro === null || data.pointsToEuro <= 0) {\r\n errors.push(\"Points to euro ratio must be positive and greater than 0.\");\r\n }\r\n return errors;\r\n };\r\n\r\n return (\r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n \r\n Loyalty points\r\n \r\n \r\n \r\n or you can test it below\r\n \r\n \r\n setRedeemPoints(e.target.value)}\r\n type=\"number\"\r\n variant=\"outlined\"\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n setExchangeEuro(e.target.value)}\r\n type=\"number\"\r\n variant=\"outlined\"\r\n />\r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n \r\n );\r\n}\r\n\r\nexport default CompanyForm;\r\n","import React, { useEffect, useContext, useState } from \"react\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport {\r\n getCompanyByUserEmail,\r\n addCompany,\r\n updateCompany,\r\n} from \"../../services/companyService\";\r\nimport { formTypes } from \"../../config.json\";\r\nimport FormTemplate from \"../../components/common/formTemplate\";\r\nimport { FormInputHook } from \"../../utilities/formInputHook\";\r\nimport FormInput from \"../../components/common/formInput\";\r\nimport { getCategories } from \"../../services/categoriesService\";\r\n\r\nfunction MyComapny({}) {\r\n const { authed } = useContext(UserContext);\r\n const formType = formTypes.view;\r\n const [data, setData] = useState({});\r\n const [categories, setCategories] = useState([]);\r\n const {\r\n dataForm,\r\n setDataForm,\r\n disableInput,\r\n updateValue,\r\n handleDisableInput,\r\n } = FormInputHook({ defaultData: data, formType });\r\n useEffect(() => {\r\n const Init = async () => {\r\n if (authed.email === \"\") return;\r\n const { data } = await getCategories();\r\n setCategories(data);\r\n const dataResponse = await getCompanyByUserEmail(authed.email);\r\n console.log(\"To mycompany:\", dataResponse);\r\n dataResponse.ownerEmail = dataResponse.owner.email;\r\n dataResponse.pointsToEuro = dataResponse.pointsToEuroRatio;\r\n dataResponse.euroToPoints = dataResponse.euroToPointsRatio;\r\n setDataForm({\r\n ...dataForm,\r\n initialData: { ...dataResponse },\r\n details: { ...dataResponse },\r\n });\r\n };\r\n Init();\r\n }, [authed]);\r\n\r\n const updateImage = (imageName, imageFile) => {\r\n setDataForm({\r\n ...dataForm,\r\n details: { ...dataForm.details, logo: imageName, logoFile: imageFile },\r\n });\r\n };\r\n return (\r\n <>\r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n\r\n
Πόντοι Loyalty ανά Ευρώ \r\n
\r\n
\r\n
\r\n Για κάθε {dataForm.details[\"pointsToEuro\"]} πόντους εξαργυρώνεται\r\n 1 €\r\n
\r\n
\r\n
\r\n
\r\n Για κάθε 1 € ανατίθενται {dataForm.details[\"euroToPoints\"]} πόντοι\r\n
\r\n
\r\n
\r\n
\r\n \r\n >\r\n );\r\n}\r\n\r\nexport default MyComapny;\r\n","import React, { useContext, useState } from \"react\";\r\nimport { useEffect } from \"react\";\r\nimport FormInput from \"../../components/common/formInput\";\r\nimport { formTypes } from \"../../config.json\";\r\nimport { checkUserRole } from \"../../services/userAccountService\";\r\nimport { FormInputHook } from \"../../utilities/formInputHook\";\r\nimport FormTemplate from \"../../components/common/formTemplate\";\r\nimport { register, updateAccount } from \"../../services/userAccountService\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\n\r\nfunction UserForm({ defaultData, formType }) {\r\n const {\r\n dataForm,\r\n setDataForm,\r\n disableInput,\r\n updateValue,\r\n handleDisableInput,\r\n } = FormInputHook({ defaultData, formType });\r\n const { authed, isAdmin } = useContext(UserContext);\r\n useEffect(() => {\r\n const init = async () => {\r\n if (formType === formTypes.view) {\r\n // get user role!!! check if his roles!!\r\n let result = await checkUserRole(dataForm.details[\"email\"]);\r\n setDataForm({\r\n initialData: { ...dataForm.initialData, owner: result },\r\n details: { ...dataForm.details, owner: result },\r\n });\r\n } else {\r\n // to formtype einai view!!! ara dwse to email tou company owner!!\r\n // alliws ama einai admin tote dwse to emfanise to checkbox ean 8elei o\r\n // xrhsths na valei enan companyowner user!!!\r\n if (isAdmin()) {\r\n // kane aplo register!!!\r\n } else {\r\n // einai company owner!!! passare to company owner email!!!\r\n setDataForm({\r\n initialData: {\r\n ...dataForm.initialData,\r\n companyOwnerEmail: authed.email,\r\n },\r\n details: {\r\n ...dataForm.details,\r\n companyOwnerEmail: authed.email,\r\n },\r\n });\r\n }\r\n }\r\n };\r\n init();\r\n }, []);\r\n\r\n const addUserValidation = () => {\r\n const errors = [];\r\n const data = { ...dataForm.details };\r\n if (data.userName === null || data.userName.trim() === \"\") {\r\n errors.push(\"Username is required.\");\r\n }\r\n if (data.email === null || data.email.trim() === \"\") {\r\n errors.push(\"Email is required.\");\r\n }\r\n return errors;\r\n };\r\n const updateUserValidation = () => {\r\n const errors = [];\r\n const data = { ...dataForm.details };\r\n if (data.userName === null || data.userName.trim() === \"\") {\r\n errors.push(\"Username is required.\");\r\n }\r\n if (data.email === null || data.email.trim() === \"\") {\r\n errors.push(\"Email is required.\");\r\n }\r\n return errors;\r\n };\r\n const validations = () => {\r\n if (formType === formTypes.add) {\r\n return addUserValidation();\r\n } else {\r\n return updateUserValidation();\r\n }\r\n };\r\n\r\n return (\r\n \r\n \r\n
\r\n \r\n \r\n {isAdmin() && (\r\n \r\n )}\r\n
\r\n
\r\n \r\n );\r\n}\r\n\r\nexport default UserForm;\r\n","import http from \"./httpService\";\r\nimport { apiUrl } from \"../config.json\";\r\n\r\nconst apiEndpoint = apiUrl + \"/points/\";\r\n\r\nexport async function updatePoints(user)\r\n{\r\n let updatePoints = apiEndpoint + `setPoints`;\r\n const { data } = await http.put(updatePoints, user);\r\n return data;\r\n}\r\n\r\nexport async function getUserPointsPerCompany(email,ownerEmail)\r\n{\r\n let userPoints = apiEndpoint + `getUserPointsPerCompany?email=${email}&ownerEmail=${ownerEmail}`;\r\n const { data } = await http.get(userPoints);\r\n return data;\r\n}\r\n\r\nexport async function getUserPointsAllCompanies(email)\r\n{\r\n let userPoints = apiEndpoint + `getUserPointsAllCompanies?email=${email}`;\r\n const { data } = await http.get(userPoints);\r\n return data;\r\n}\r\n\r\nexport async function assignUserToCompany()\r\n{\r\n \r\n}\r\n\r\nexport async function addPoints(model)\r\n{\r\n\r\n let points = model.euro * model.euroToPointsRatio;\r\n let addPoints = apiEndpoint + \"addPoints\";\r\n model.points = points;\r\n const { data } = await http.post(addPoints, model);\r\n return data;\r\n}\r\n\r\n\r\nexport async function redeemPoints(model)\r\n{\r\n let redeemPoints = apiEndpoint + \"addPoints\";\r\n model.points = model.redeem*-1;\r\n const { data } = await http.post(redeemPoints, model);\r\n console.log();\r\n return data;\r\n}","import React, { useEffect, useState } from \"react\";\r\nimport { useLocation, useNavigate } from \"react-router-dom\";\r\nimport {\r\n getUserPointsAllCompanies,\r\n getUserPointsPerCompany,\r\n} from \"../../services/pointsService\";\r\nimport {\r\n Box,\r\n Button,\r\n Container,\r\n IconButton,\r\n TableBody,\r\n TableCell,\r\n TableRow,\r\n Typography,\r\n} from \"@material-ui/core\";\r\nimport { Add, AttachMoney, ArrowBack } from \"@material-ui/icons\";\r\nimport useTable from \"../../components/common/useTable\";\r\nimport { useContext } from \"react\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\n\r\nfunction UserPoints() {\r\n const [userPoints, setUserPoints] = useState([]);\r\n const { authed, isAdmin } = useContext(UserContext);\r\n const location = useLocation();\r\n const navigate = useNavigate();\r\n const userPointsColumns = [\r\n { id: \"name\", label: \"Company Name\" },\r\n { id: \"total\", label: \"Points\" },\r\n { id: \"actions\", label: \"Actions\" },\r\n ];\r\n const {\r\n TableContainer,\r\n TableHeader,\r\n TablePaginationCustom,\r\n recordsAfterPaging,\r\n } = useTable(userPoints, userPointsColumns, [\"company.name\", \"total\"]);\r\n useEffect(async () => {\r\n // call the api to get the user's points!!\r\n try {\r\n if (isAdmin())\r\n var { data } = await getUserPointsAllCompanies(location.state.email);\r\n else\r\n var { data } = await getUserPointsPerCompany(\r\n location.state.email,\r\n authed.email\r\n );\r\n setUserPoints(data);\r\n } catch (ex) {}\r\n }, []);\r\n\r\n const handleViewCompany = (row) => {\r\n navigate(`${location.pathname}/${row.company.name}`, {\r\n state: {\r\n ...row,\r\n },\r\n });\r\n };\r\n\r\n const handleAddRemovePoints = (row) => {\r\n navigate(`${location.pathname}/setPoints`, {\r\n state: {\r\n companyId: row.company.id,\r\n userId: row.applicationUserId,\r\n euroToPointsRatio: row.company.euroToPointsRatio,\r\n },\r\n });\r\n };\r\n\r\n const handleRedeemPoints = (row) => {\r\n navigate(`${location.pathname}/redeemPoints`, {\r\n state: {\r\n companyId: row.company.id,\r\n userId: row.applicationUserId,\r\n pointsToEuroRatio: row.company.pointsToEuroRatio,\r\n points: row.total,\r\n },\r\n });\r\n };\r\n\r\n return (\r\n <>\r\n \r\n \r\n navigate(-1)}>\r\n \r\n \r\n \r\n Πόντοι Χρήστη \r\n ({location.state.email}) \r\n
\r\n \r\n \r\n \r\n \r\n \r\n {recordsAfterPaging()?.length === 0 ? (\r\n \r\n \r\n No Results \r\n \r\n \r\n ) : (\r\n <>\r\n {recordsAfterPaging().map((item) => (\r\n \r\n {item.company.name} \r\n {item.total} \r\n \r\n \r\n handleAddRemovePoints(item)}\r\n startIcon={ }\r\n >\r\n Προσθηκη Ποντων\r\n \r\n\r\n \r\n handleRedeemPoints(item)}\r\n color=\"primary\"\r\n startIcon={ }\r\n >\r\n Εξαργυρωση\r\n \r\n \r\n \r\n \r\n \r\n ))}\r\n >\r\n )}\r\n \r\n \r\n \r\n \r\n \r\n >\r\n );\r\n}\r\n\r\nexport default UserPoints;\r\n","import React from \"react\";\r\nimport FormInput from \"../../components/common/formInput\";\r\nimport { FormInputHook } from \"../../utilities/formInputHook\";\r\nimport {\r\n addPoints,\r\n updatePoints,\r\n redeemPoints,\r\n} from \"../../services/pointsService\";\r\nimport FormTemplate from \"../../components/common/formTemplate\";\r\n\r\nfunction PointsForm({ defaultData, formType, redeem }) {\r\n const {\r\n dataForm,\r\n setDataForm,\r\n disableInput,\r\n updateValue,\r\n handleDisableInput,\r\n } = FormInputHook({ defaultData, formType });\r\n const redeemForm = redeem ?? false;\r\n const title = redeemForm ? \"Εξαργυρωση\" : \"Προσθηκη\";\r\n const pointsAddMethod = async (data) => {\r\n if (redeemForm) {\r\n await redeemPoints(data);\r\n } else {\r\n await addPoints(data);\r\n }\r\n };\r\n\r\n const addPointsValidation = () => {\r\n const data = { ...dataForm.details };\r\n const errors = [];\r\n if (data.euro <= 0) {\r\n errors.push(\"Please input a valid number of euro\");\r\n }\r\n return errors;\r\n };\r\n\r\n const redeemPointsValidation = () => {\r\n const data = { ...dataForm.details };\r\n const errors = [];\r\n if (data.redeem <= 0) {\r\n errors.push(\"Please input a valid number of points.\");\r\n }\r\n if (data.redeem > data.points) {\r\n errors.push(\"Not enought points\");\r\n }\r\n return errors;\r\n };\r\n\r\n const validations = () => {\r\n if (redeemForm) {\r\n return redeemPointsValidation();\r\n } else {\r\n return addPointsValidation();\r\n }\r\n };\r\n\r\n const pointsBodyRender = () => {\r\n if (redeemForm) {\r\n return (\r\n <>\r\n Ο χρήστης {dataForm.details[\"username\"]} έχει {dataForm.details[\"points\"]} Loyalty πόντους \r\n \r\n Για κάθε {dataForm.details[\"pointsToEuroRatio\"]} πόντοι αντιστοιχεί 1 €\r\n \r\n \r\n \r\n Σε ευρώ:\r\n {dataForm.details[\"redeem\"] / dataForm.details[\"pointsToEuroRatio\"] } €\r\n
\r\n >\r\n );\r\n } else {\r\n return (\r\n <>\r\n \r\n Για κάθε 1 € αντιστοιχεί {dataForm.details[\"euroToPointsRatio\"]} Loyalty πόντοι\r\n \r\n \r\n \r\n Σε πόντους:\r\n {dataForm.details[\"euroToPointsRatio\"] * dataForm.details[\"euro\"]}\r\n
\r\n >\r\n );\r\n }\r\n };\r\n\r\n return (\r\n \r\n
\r\n <>\r\n \r\n {pointsBodyRender()}\r\n \r\n >\r\n
\r\n
\r\n );\r\n}\r\n\r\nexport default PointsForm;\r\n","import { Box, makeStyles } from \"@material-ui/core\";\r\n//import \"./LoginCustomInput.css\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n inputWrapper: {\r\n marginBottom: \"5px\",\r\n backgroundColor: \"lightgray\",\r\n borderRadius: \"5px\",\r\n padding: \"2px\",\r\n \"& input\": {\r\n border: \"0\",\r\n padding: \"10px\",\r\n fontSize: \"20px\",\r\n width: \"100%\",\r\n outline: \"none !important\",\r\n },\r\n },\r\n inputWrapperIcon: {\r\n padding: \"8px\",\r\n },\r\n}));\r\n\r\nexport default function LoginCustomInput({\r\n Icon,\r\n value,\r\n handleOnChange,\r\n type,\r\n placeHolder,\r\n}) {\r\n const classes = useStyles();\r\n const inputType = type != null ? type : \"text\";\r\n return (\r\n <>\r\n \r\n {Icon}
\r\n handleOnChange(newValue)}\r\n />\r\n \r\n >\r\n );\r\n}\r\n","import { Person, Lock, Facebook } from \"@material-ui/icons\";\r\nimport LoginCustomInput from \"./LoginCustomInput\";\r\nimport { useContext, useState, useEffect } from \"react\";\r\nimport { useNavigate } from \"react-router-dom\";\r\nimport { handleErrors } from \"../../utilities/handleErrors\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport { useLocation } from \"react-router-dom\";\r\nimport {\r\n Box,\r\n Button,\r\n makeStyles,\r\n Paper,\r\n Typography,\r\n TextField,\r\n} from \"@material-ui/core\";\r\nimport { applicationColors, apiUrl } from \"../../config.json\";\r\nimport { authenticateUser } from \"../../services/userService\";\r\nimport Modal from \"@material-ui/core/Modal\";\r\nimport { requestResetPassword } from \"../../services/userAccountService\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n boxWrapper: {\r\n height: \"100vh\",\r\n backgroundColor: \"black\",\r\n opacity: \"0.7\",\r\n justifyContent: \"center\",\r\n alignItems: \"center\",\r\n },\r\n loginPageWrapper: {\r\n width: \"700px\",\r\n borderRadius: \"15px\",\r\n position: \"relative\",\r\n [theme.breakpoints.down(\"sm\")]: {\r\n width: \"550px\",\r\n },\r\n },\r\n personIcon: {\r\n position: \"absolute\",\r\n right: \"50%\",\r\n bottom: \"0\",\r\n width: \"100px\",\r\n borderRadius: \"50%\",\r\n height: \"100px\",\r\n backgroundColor: applicationColors.greenBg,\r\n top: \"-50px\",\r\n color: \"white\",\r\n padding: \"10px\",\r\n transform: \"translateX(50px)\",\r\n marginLeft: \"50px\",\r\n },\r\n loginFormWrapper: {\r\n paddingLeft: \"60px\",\r\n paddingTop: \"80px\",\r\n paddingRight: \"60px\",\r\n paddingBottom: \"50px\",\r\n [theme.breakpoints.down(\"sm\")]: {\r\n padding: \"20px\",\r\n paddingTop: \"50px\",\r\n },\r\n },\r\n loginInput: {},\r\n signInButton: {\r\n margin: \"10px\",\r\n backgroundColor: applicationColors.greenBg,\r\n \"&:hover\": {\r\n backgroundColor: applicationColors.greenBgHover,\r\n },\r\n padding: \"10px 100px\",\r\n },\r\n signInGoogle: {\r\n backgroundColor: \"white\",\r\n color: \"black\",\r\n },\r\n\r\n errorsList: {\r\n \"& li\": {\r\n color: \"red\",\r\n marginTop: \"10px\",\r\n listStylePosition: \"inside\",\r\n wordWrap: \"break-word\",\r\n },\r\n },\r\n}));\r\n\r\nconst style = {\r\n position: \"absolute\",\r\n top: \"50%\",\r\n left: \"50%\",\r\n transform: \"translate(-50%, -50%)\",\r\n width: 400,\r\n bgcolor: \"background.paper\",\r\n border: \"2px solid #000\",\r\n boxShadow: 24,\r\n p: 4,\r\n};\r\n\r\nexport default function LoginPage() {\r\n const [errors, setErrors] = useState([]);\r\n const [email, setEmail] = useState(\"\");\r\n const [password, setPassword] = useState(\"\");\r\n const person = ;\r\n const passwordIcon = ;\r\n const location = useLocation();\r\n const { userLogin } = useContext(UserContext);\r\n const classes = useStyles();\r\n let navigate = useNavigate();\r\n const [openModal, setOpenModal] = useState(false);\r\n const handleOpen = () => setOpenModal(true);\r\n const handleClose = () => setOpenModal(false);\r\n const [forgotPassRespond, setForgotPassRespond] = useState(\"\");\r\n const [forgotEmail, setForgotEmail] = useState(\"\");\r\n\r\n const handleLoginClick = async () => {\r\n try {\r\n setErrors([]);\r\n await userLogin({ email, password });\r\n navigate(\"/\");\r\n } catch (ex) {\r\n handleErrors(ex, setErrors);\r\n }\r\n };\r\n\r\n const handleResetPassword = () => {\r\n handleOpen();\r\n };\r\n\r\n const handleResetPasswordButton = async () => {\r\n const result = await requestResetPassword(forgotEmail);\r\n setForgotPassRespond(\"A reset email was send. Check your emails \");\r\n };\r\n\r\n useEffect(() => {\r\n const Init = async () => {\r\n try {\r\n const result = await authenticateUser();\r\n if (result.roles.length === 0) return;\r\n navigate(\"/\");\r\n } catch (ex) {}\r\n if (location.state === null) return;\r\n setErrors([location.state.error.ex]);\r\n };\r\n Init();\r\n }, []);\r\n\r\n const handleEmailChange = (newValue) => {\r\n setEmail(newValue.target.value);\r\n };\r\n const handlePasswordChange = (newValue) => {\r\n setPassword(newValue.target.value);\r\n };\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {/* \r\n \r\n */}\r\n \r\n \r\n Reset Password\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n RESET PASSWORD\r\n \r\n setForgotEmail(e.currentTarget.value)}\r\n value={forgotEmail}\r\n />\r\n \r\n Reset Password\r\n \r\n \r\n {forgotPassRespond}\r\n \r\n \r\n \r\n >\r\n );\r\n}\r\n","import React, { createContext, useState } from \"react\";\r\n\r\nexport const TabBarSectionContext = createContext();\r\nexport function TabbarSectionContextProvider(props) {\r\n const [display, setDisplay] = useState(true);\r\n return (\r\n \r\n {props.children}\r\n \r\n );\r\n}\r\n","import React, { useContext } from \"react\";\r\nimport { ArrowForwardIos } from \"@material-ui/icons\";\r\nimport { TabContext } from \"../../contexts/tabContext\";\r\nimport { tabs } from \"../../config.json\";\r\nimport { Link } from \"react-router-dom\";\r\nimport clsx from \"clsx\";\r\nimport { makeStyles } from \"@material-ui/core\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n menuTileWrapper: {\r\n padding: \"20px\",\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"space-between\",\r\n cursor: \"pointer\",\r\n color: \"rgb(120, 130, 146)\",\r\n textDecoration: \"none\",\r\n \"&:hover\": {\r\n backgroundColor: \"rgb(48,57,75)\",\r\n borderLeft: \"3px solid rgb(45,197,139)\",\r\n color: \"white\",\r\n },\r\n },\r\n menuTileIconTitle: {\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n },\r\n menuTileIcon: {\r\n marginRight: \"10px\",\r\n },\r\n active: {\r\n color: \"white\",\r\n backgroundColor: \"rgb(48,57,75)\",\r\n borderLeft: \"3px solid rgb(45,197,139)\",\r\n },\r\n activeMobile: {\r\n color: \"white\",\r\n borderLeft: \"3px solid rgb(45,197,139)\",\r\n },\r\n menuTileWrapperMobile: {\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n color: \"rgb(120,130,146)\",\r\n textDecoration: \"none\",\r\n },\r\n}));\r\n\r\nexport default function MenuTile({ item, mobile }) {\r\n const classes = useStyles();\r\n // const { tab, changeTab } = useContext(TabContextProvider);\r\n const { tab, changeTab } = useContext(TabContext);\r\n let newTab;\r\n switch (item.tab) {\r\n case tabs.Dashboard:\r\n newTab = \"/\";\r\n break;\r\n case tabs.Stores:\r\n newTab = \"/stores\";\r\n break;\r\n case tabs.Analytics:\r\n newTab = \"/analytics\";\r\n break;\r\n case tabs[\"Product Sales\"]:\r\n newTab = \"/productSales\";\r\n break;\r\n case tabs.Users:\r\n newTab = \"/users\";\r\n break;\r\n case tabs.Reports:\r\n newTab = \"/reports\";\r\n break;\r\n case tabs.Sales:\r\n newTab = \"/sales\";\r\n break;\r\n case tabs.Companies:\r\n newTab = \"/companies\";\r\n break;\r\n case tabs.Categories:\r\n newTab = \"/categories\";\r\n break;\r\n default:\r\n newTab = \"/\";\r\n break;\r\n }\r\n\r\n let styles = clsx({\r\n [classes.menuTileWrapper]: !mobile,\r\n [classes.active]: item.tab === tab && !mobile,\r\n });\r\n\r\n return (\r\n changeTab(item.tab)}>\r\n \r\n {/*
*/}\r\n {!mobile && item.icon}\r\n
{item.title}
\r\n
\r\n {!mobile && }\r\n \r\n );\r\n}\r\n","import React from \"react\";\r\nimport { useContext } from \"react\";\r\nimport { useEffect } from \"react\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport MenuTile from \"./MenuTile\";\r\n\r\nexport default function MenuComponent({ items }) {\r\n const { isAdmin, authed } = useContext(UserContext);\r\n return (\r\n \r\n {items.map((item) => (\r\n \r\n ))}\r\n
\r\n );\r\n}\r\n","import { Facebook } from \"@material-ui/icons\";\r\nimport React from \"react\";\r\nimport MenuComponent from \"./MenuComponent\";\r\nimport { makeStyles, Typography } from \"@material-ui/core\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n sidebar: {\r\n height: \"100vh\",\r\n backgroundColor: \"rgb(57,67,87)\",\r\n color: \"rgb(120,130,146)\",\r\n },\r\n sidebarTitle: {\r\n color: \"white\",\r\n padding: \"20px\",\r\n },\r\n divider: {\r\n border: \"1px solid rgb(120,130,146)\",\r\n },\r\n sidebarTitleWrapper: {\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n marginLeft: \"0px\",\r\n height: \"60px\",\r\n },\r\n sidebarLogo: {\r\n color: \"rgb(45,197,139)\",\r\n },\r\n logo: {\r\n height: \"60px\",\r\n width: \"60px\",\r\n },\r\n}));\r\nexport default function Sidebar({ menu }) {\r\n const classes = useStyles();\r\n return (\r\n \r\n
\r\n {/*
*/}\r\n
\r\n
\r\n Loyalty Admin\r\n \r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n );\r\n}\r\n","import { useNavigate } from \"react-router-dom\";\r\nimport { useContext, useEffect } from \"react\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport { useState } from \"react\";\r\nimport {\r\n Box,\r\n List,\r\n ListItem,\r\n ListItemIcon,\r\n ListItemText,\r\n makeStyles,\r\n} from \"@material-ui/core\";\r\nimport clsx from \"clsx\";\r\nimport { AccountBox, Business, PowerSettingsNew } from \"@material-ui/icons\";\r\nimport { logOut } from \"../../services/userService\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n topbarSectionWrapper: {\r\n position: \"fixed\",\r\n height: \"auto\",\r\n padding: \"0px\",\r\n width: \"200px\",\r\n top: \"60px\",\r\n backgroundColor: \"white\",\r\n borderRadius: \"0px 0px 5px 5px\",\r\n right: \"20px\",\r\n zIndex: \"999\",\r\n },\r\n hideTopbarSection: {\r\n display: \"none\",\r\n },\r\n}));\r\n\r\nexport default function TopbarSection({ hide, handleClick }) {\r\n const { authed, isAdmin } = useContext(UserContext);\r\n const [hideCompany, setHideCompany] = useState(false);\r\n const navigate = useNavigate();\r\n const classes = useStyles();\r\n useEffect(() => {\r\n if (authed.email === \"\") return;\r\n if (isAdmin()) {\r\n setHideCompany(true);\r\n } else {\r\n setHideCompany(false);\r\n }\r\n }, [authed]);\r\n const styles = clsx({\r\n [classes.topbarSectionWrapper]: true,\r\n [classes.hideTopbarSection]: hide,\r\n });\r\n const handleLogout = async () => {\r\n // clear local storage and then redirect to login page!!\r\n const result = await logOut();\r\n navigate(\"/login\");\r\n };\r\n return (\r\n <>\r\n \r\n \r\n navigate(\"/profile\")}>\r\n \r\n \r\n \r\n \r\n \r\n {!hideCompany && (\r\n navigate(\"/mycompany\")}>\r\n \r\n \r\n \r\n \r\n \r\n )}\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n >\r\n );\r\n}\r\n","import { Notifications, Settings, Menu } from \"@material-ui/icons\";\r\n\r\nimport TopbarSection from \"./TopbarSection\";\r\nimport { useAuth, UserContext } from \"../../contexts/userContext\";\r\nimport { useContext } from \"react\";\r\nimport { Avatar, Box, Grid, makeStyles, Typography } from \"@material-ui/core\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n tobar: {\r\n backgroundColor: \"white\",\r\n height: \"60px\",\r\n padding: \"10px\",\r\n },\r\n hamburgerMenu: {\r\n fontDisplay: \"flex\",\r\n alignSelf: \"center\",\r\n paddingLeft: \"20px\",\r\n transition: \"all 0.2ms ease-out\",\r\n \"&:hover\": {\r\n transform: \"scale(1.1)\",\r\n cursor: \"pointer\",\r\n },\r\n },\r\n marginRightAndLeft: {\r\n marginRight: \"10px\",\r\n marginLeft: \"10px\",\r\n },\r\n}));\r\n\r\nexport default function Topbar({ showMenu, toggle, setToggle }) {\r\n const classes = useStyles();\r\n const { authed } = useContext(UserContext);\r\n const toggleTopbarSection = () => {\r\n setToggle(!toggle);\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n {authed.username} \r\n \r\n \r\n \r\n \r\n );\r\n}\r\n","import { makeStyles } from \"@material-ui/core\";\r\nimport { Close } from \"@material-ui/icons\";\r\nimport React from \"react\";\r\nimport MenuTile from \"./sidebar/MenuTile\";\r\nimport clsx from \"clsx\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n mobileNavigation: {\r\n height: \"100vh\",\r\n width: \"100vw\",\r\n position: \"fixed\",\r\n zIndex: \"999\",\r\n \"& ul li\": {\r\n padding: \"20px\",\r\n fontSize: \"20px\",\r\n fontWeight: \"bold\",\r\n letterSpacing: \"2px\",\r\n borderRadius: \"5px\",\r\n listStyle: \"none\",\r\n },\r\n \"& ul li a\": {\r\n textDecoration: \"none\",\r\n color: \"inherit\",\r\n },\r\n \"& ul li:hover\": {\r\n backgroundColor: \"rgb(45, 197, 139)\",\r\n cursor: \"pointer\",\r\n color: \"white\",\r\n },\r\n },\r\n mobileNavigationList: {\r\n display: \"flex\",\r\n height: \"60%\",\r\n alignItems: \"center\",\r\n justifyContent: \"center\",\r\n },\r\n mobileNavigationClose: {\r\n boxShadow: \"5px 5px 15px 5px rgb(45, 197, 139)\",\r\n display: \"inline-block\",\r\n margin: \"20px\",\r\n borderRadius: \"50%\",\r\n padding: \"10px\",\r\n cursor: \"pointer\",\r\n transition: \"all 0.2ms ease-out\",\r\n \"&:hover\": {\r\n transform: \"scale(1.1)\",\r\n },\r\n },\r\n mobileNavigationCloseIcon: {\r\n color: \"white\",\r\n transition: \"all 0.2ms ease-out\",\r\n },\r\n hideMenu: {\r\n display: \"none\",\r\n },\r\n sidebarGrayBg: {\r\n backgroundColor: \"rgb(58,67,87)\",\r\n },\r\n}));\r\n\r\nfunction MobileNavigation({ hide, hideMenu, menu }) {\r\n const classes = useStyles();\r\n const styles = clsx({\r\n [classes.mobileNavigation]: true,\r\n [classes.hideMenu]: hide,\r\n [classes.sidebarGrayBg]: true,\r\n });\r\n return (\r\n <>\r\n \r\n
\r\n \r\n
\r\n
\r\n
\r\n {menu.map((item) => (\r\n hideMenu()}>\r\n \r\n \r\n ))}\r\n \r\n
\r\n
\r\n >\r\n );\r\n}\r\n\r\nexport default MobileNavigation;\r\n","import React, { useState, useEffect, useContext } from \"react\";\r\nimport { TabContextProvider } from \"../contexts/tabContext\";\r\nimport { Grid, Box } from \"@material-ui/core\";\r\nimport { TabbarSectionContextProvider } from \"../contexts/tabbarSectionContext\";\r\nimport Sidebar from \"../components/sidebar/Sidebar\";\r\nimport Topbar from \"../components/topbar/Topbar\";\r\nimport { UserContext } from \"../contexts/userContext\";\r\nimport FormContextProvoder from \"../contexts/formContext\";\r\nimport { createRoutes } from \"../routes\";\r\nimport MobileNavigation from \"../components/mobileNavigation\";\r\nimport { authenticateUser } from \"../services/userService\";\r\nimport { useNavigate } from \"react-router-dom\";\r\n\r\nfunction MainPage() {\r\n const [hide, setHide] = useState(true);\r\n const routes = createRoutes();\r\n const navigate = useNavigate();\r\n const { userDetailObject, menu, authed, setAuthed } = useContext(UserContext);\r\n const [toggleTopbarSection, setToggleTopbarSection] = useState(true);\r\n const hideMenu = () => {\r\n setHide(!hide);\r\n };\r\n\r\n useEffect(() => {\r\n const Init = async () => {\r\n if (authed.email === \"\") {\r\n try {\r\n console.log(\"------------------> Check MainaPage\");\r\n const response = await authenticateUser();\r\n if (response.roles.length === 0) throw \"asdfasdf\";\r\n const obj = userDetailObject(response);\r\n setAuthed({ ...obj });\r\n return;\r\n } catch (ex) {\r\n navigate(\"/login\");\r\n }\r\n }\r\n };\r\n Init();\r\n }, []);\r\n\r\n const handleClick = () => {\r\n if (!toggleTopbarSection) {\r\n setToggleTopbarSection(!toggleTopbarSection);\r\n }\r\n };\r\n return (\r\n \r\n \r\n \r\n \r\n handleClick()}>\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n {routes}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n}\r\n\r\nexport default MainPage;\r\n","import React, { useEffect, useContext } from \"react\";\r\nimport { Link, useSearchParams, useNavigate } from \"react-router-dom\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\n\r\nfunction ExternalLoginPage() {\r\n const { userLogin, authed } = useContext(UserContext);\r\n const [searchParams] = useSearchParams();\r\n const navigate = useNavigate();\r\n useEffect(() => {\r\n const Init = async () => {\r\n // take the params from there and show it to the console!!!!\r\n const email = searchParams.get(\"email\");\r\n const providerKey = searchParams.get(\"providerKey\");\r\n const loginProvider = searchParams.get(\"loginProvider\");\r\n if (email !== null && providerKey !== null && loginProvider !== null) {\r\n // go to the login\r\n try {\r\n await userLogin({ email, providerKey, loginProvider });\r\n navigate(\"/\");\r\n } catch (ex) {\r\n console.log(ex);\r\n //let response = ex.response.data.errorMessage;\r\n navigate(\"/login\", {\r\n state: {\r\n error: { ex },\r\n },\r\n });\r\n }\r\n }\r\n };\r\n Init();\r\n }, []);\r\n\r\n return Redirecting please wait....
;\r\n}\r\n\r\nexport default ExternalLoginPage;\r\n","import React from \"react\";\r\nimport \"./WidgetLg.css\";\r\n\r\nexport default function WidgetLg({\r\n style,\r\n title,\r\n bodyNumber,\r\n Icon,\r\n footerNumber,\r\n footerTitle,\r\n}) {\r\n return (\r\n \r\n
{title}
\r\n
\r\n
{bodyNumber} \r\n {Icon}\r\n \r\n
\r\n );\r\n}\r\n","import http from \"./httpService\";\r\nimport { apiUrl } from \"../config.json\";\r\n\r\nconst apiEndpoint = apiUrl + \"/Statistics/\";\r\n\r\n\r\nexport async function getTotalUsers(email = null)\r\n{\r\n let totalUsers = apiEndpoint + \"getTotalUsers\";\r\n const { data } = await http.post(totalUsers, {\r\n companyOwnerEmail:email\r\n });\r\n return data;\r\n}\r\n\r\n\r\nexport async function getTotalStores(email = null)\r\n{\r\n let totalStores = apiEndpoint + \"getTotalStores\";\r\n const { data } = await http.post(totalStores, {\r\n companyOwnerEmail:email\r\n });\r\n return data;\r\n}\r\n\r\nexport async function getTotalActiveSales(email = null)\r\n{\r\n let totalActiveSales = apiEndpoint + \"getTotalActiveSales\";\r\n const { data } = await http.post(totalActiveSales, {\r\n companyOwnerEmail:email\r\n });\r\n return data;\r\n}\r\n\r\n\r\nexport async function getLast6Months(email = null)\r\n{\r\n let last6monthts = apiEndpoint + \"getLast6Months\";\r\n const { data } = await http.post(last6monthts, {\r\n companyOwnerEmail:email\r\n });\r\n return data;\r\n}\r\n\r\nexport async function getTotalRedeemEarnedPoints(email = null)\r\n{\r\n let totalRedeemEarnedPoints = apiEndpoint + \"getTotalEarnedAndRedeemPoint\";\r\n const { data } = await http.post(totalRedeemEarnedPoints, {\r\n companyOwnerEmail:email\r\n });\r\n return data;\r\n}\r\n\r\nexport async function getTop30Users(email = null)\r\n{\r\n let top30Users = apiEndpoint + \"getTop30Users\";\r\n const { data } = await http.post(top30Users, {\r\n companyOwnerEmail:email\r\n });\r\n return data;\r\n}\r\n\r\n","import { Typography } from \"@material-ui/core\";\r\nimport React from \"react\";\r\nimport {\r\n Bar,\r\n BarChart,\r\n CartesianGrid,\r\n Rectangle,\r\n ResponsiveContainer,\r\n Tooltip,\r\n XAxis,\r\n YAxis,\r\n} from \"recharts\";\r\n\r\nfunction HorizontalBarChart({ data }) {\r\n return (\r\n <>\r\n \r\n Last 6 months\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n }\r\n >\r\n \r\n \r\n >\r\n );\r\n}\r\n\r\nexport default HorizontalBarChart;\r\n","import { useContext } from \"react\";\r\nimport {\r\n Box,\r\n Container,\r\n Divider,\r\n Grid,\r\n TableBody,\r\n TableCell,\r\n TableRow,\r\n Typography,\r\n} from \"@material-ui/core\";\r\nimport WidgetLg from \"../../components/widgets/WidgetLg\";\r\nimport _ from \"lodash\";\r\nimport { Store, Loyalty, PermIdentity } from \"@material-ui/icons\";\r\nimport { useEffect } from \"react\";\r\nimport { useState } from \"react\";\r\nimport {\r\n getLast6Months,\r\n getTop30Users,\r\n getTotalActiveSales,\r\n getTotalRedeemEarnedPoints,\r\n getTotalStores,\r\n getTotalUsers,\r\n} from \"../../services/statistics\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\nimport useTable from \"../../components/common/useTable\";\r\nimport HorizontalBarChart from \"../../components/common/horizontalBarChart\";\r\nimport {\r\n Bar,\r\n BarChart,\r\n CartesianGrid,\r\n Legend,\r\n Tooltip,\r\n XAxis,\r\n YAxis,\r\n ResponsiveContainer\r\n} from \"recharts\";\r\nimport { makeStyles } from \"@material-ui/styles\";\r\nimport { dateConfiguration } from \"../../utilities/dataConfiguration\";\r\n\r\nconst useStyles = makeStyles((theme) => ({\r\n tableWrapper: {\r\n marginTop: \"20px\",\r\n },\r\n horizontalChartWrapper: {},\r\n verticalChartWrapper: {},\r\n}));\r\nexport default function Analytics() {\r\n \r\n const { isAdmin, authed } = useContext(UserContext);\r\n const [totalUsers, setTotalUsers] = useState(0);\r\n const [totalStores, setTotalStores] = useState(0);\r\n const [totalSales, setTotalSales] = useState(0);\r\n const [last6Months, setLast6Months] = useState([]);\r\n const [top30Users, setTop30Users] = useState([]);\r\n const classes = useStyles();\r\n const top30UsersColumns = [\r\n { id: \"username\", label: \"Username\" },\r\n { id: \"email\", label: \"Email\" },\r\n { id: \"total\", label: \"Total\" },\r\n { id: \"dateJoined\", label: \"Date Joined\" },\r\n ];\r\n const {\r\n TableContainer,\r\n TableHeader,\r\n TablePaginationCustom,\r\n recordsAfterPaging,\r\n } = useTable(top30Users, top30UsersColumns, [\"username\", \"email\", \"total\"]);\r\n const totalRedeemAdmin = [\r\n {\r\n name: \"Redeem\",\r\n value: 0,\r\n },\r\n {\r\n name: \"Earned\",\r\n value: 0,\r\n },\r\n ];\r\n const last6MonthsAdmin = [\r\n {\r\n name: \"Month1\",\r\n value: 0,\r\n },\r\n {\r\n name: \"Month2\",\r\n value: 0,\r\n },\r\n {\r\n name: \"Month3\",\r\n value: 0,\r\n },\r\n {\r\n name: \"Month4\",\r\n value: 0,\r\n },\r\n {\r\n name: \"Month5\",\r\n value: 0,\r\n },\r\n {\r\n name: \"Month6\",\r\n value: 0,\r\n },\r\n ];\r\n\r\n \r\n useEffect(() => {\r\n const Init = async () => {\r\n try {\r\n const userEmail = isAdmin() ? null : authed.email;\r\n const activeSales = await getTotalActiveSales(userEmail);\r\n const users = await getTotalUsers(userEmail);\r\n const stores = await getTotalStores(userEmail);\r\n let last6Months;\r\n let totalPoints;\r\n const top30Users = await getTop30Users(userEmail);\r\n setTop30Users(top30Users.data);\r\n if (isAdmin()) {\r\n last6Months = await getLast6Months(authed.email); \r\n // last6Months = [...last6MonthsAdmin];\r\n // totalPoints = [...totalRedeemAdmin];\r\n // console.log(last6Months);\r\n setLast6Months(last6Months.data);\r\n } else {\r\n last6Months = await getLast6Months(userEmail);\r\n setLast6Months(last6Months.data);\r\n }\r\n\r\n setTotalUsers(users.data);\r\n setTotalStores(stores.data);\r\n setTotalSales(activeSales.data);\r\n } catch (ex) {}\r\n };\r\n Init();\r\n }, [authed]);\r\n\r\n return (\r\n \r\n \r\n \r\n }\r\n footerNumber={20}\r\n footerTitle=\"Last Month\"\r\n />\r\n \r\n \r\n }\r\n footerNumber={2}\r\n footerTitle=\"Last Month\"\r\n />\r\n \r\n \r\n }\r\n footerNumber={30}\r\n footerTitle=\"Last Month\"\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Top 30 Users\r\n \r\n \r\n \r\n \r\n {recordsAfterPaging().map((item) => (\r\n \r\n {item.username} \r\n {item.email} \r\n {item.total} \r\n {dateConfiguration(item.dateJoined)} \r\n \r\n ))}\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Total Earned and Redeem Points in the last 6 Months\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n );\r\n}\r\n","import {\r\n Box,\r\n Button,\r\n Container,\r\n IconButton,\r\n TableBody,\r\n TableCell,\r\n TableRow,\r\n Tooltip,\r\n Typography,\r\n} from \"@material-ui/core\";\r\nimport {\r\n Add,\r\n DeleteOutline,\r\n Edit,\r\n Loyalty,\r\n Visibility,\r\n} from \"@material-ui/icons\";\r\nimport { tabs } from \"../../config.json\";\r\nimport React, { useContext, useEffect, useState } from \"react\";\r\nimport { useNavigate } from \"react-router-dom\";\r\nimport useTable from \"../../components/common/useTable\";\r\nimport { ConfirmationDialogContext } from \"../../contexts/confirmationDialogContext\";\r\nimport { TabContext } from \"../../contexts/tabContext\";\r\nimport {\r\n deleteCategory,\r\n getCategories,\r\n} from \"../../services/categoriesService\";\r\n\r\nfunction Categories() {\r\n const [categories, setCategories] = useState([]);\r\n const { changeTab } = useContext(TabContext);\r\n const { openDialog } = useContext(ConfirmationDialogContext);\r\n const navigate = useNavigate();\r\n const categoriesColumn = [\r\n { id: \"id\", label: \"ID\" },\r\n { id: \"name\", label: \"Name\" },\r\n { id: \"actions\", label: \"Actions\", avoidSearch: true },\r\n ];\r\n\r\n useEffect(() => {\r\n const Init = async () => {\r\n changeTab(tabs.Categories);\r\n const { data } = await getCategories();\r\n setCategories(data);\r\n };\r\n Init();\r\n }, []);\r\n\r\n const handleEditClick = (stateDemo) => {\r\n navigate(`/categories/${stateDemo.id}`, {\r\n state: {\r\n ...stateDemo,\r\n },\r\n });\r\n };\r\n\r\n const handleDelete = async (id) => {\r\n let categoriesInitial = [...categories];\r\n try {\r\n if (id === null) return;\r\n let categoriesTemp = categories.filter((c) => c.id !== id);\r\n setCategories([...categoriesTemp]);\r\n await deleteCategory(id);\r\n } catch (e) {\r\n setCategories([...categoriesInitial]);\r\n }\r\n };\r\n\r\n const {\r\n TableContainer,\r\n TableHeader,\r\n TablePaginationCustom,\r\n recordsAfterPaging,\r\n } = useTable(categories, categoriesColumn, [\"id\", \"name\"]);\r\n\r\n return (\r\n \r\n \r\n
\r\n Categories \r\n navigate(\"/categories/add\")}\r\n color=\"primary\"\r\n startIcon={ }\r\n variant=\"contained\"\r\n size=\"small\"\r\n >\r\n Add Category\r\n \r\n \r\n \r\n \r\n \r\n \r\n {recordsAfterPaging()?.length === 0 ? (\r\n \r\n \r\n No Results \r\n \r\n \r\n ) : (\r\n <>\r\n {recordsAfterPaging().map((item) => (\r\n \r\n {item.id} \r\n {item.name} \r\n \r\n \r\n \r\n \r\n navigate(`/companies?category=${item.id}`)\r\n }\r\n color=\"primary\"\r\n >\r\n \r\n \r\n \r\n \r\n handleEditClick(item)}\r\n color=\"primary\"\r\n >\r\n \r\n \r\n \r\n \r\n {\r\n openDialog({\r\n title: \"Delete category?\",\r\n body: \"Are you sure you want to delete this category?\",\r\n yesButton: \"Yes\",\r\n noButton: \"No\",\r\n callback: () => handleDelete(item.id),\r\n });\r\n }}\r\n >\r\n \r\n \r\n \r\n \r\n \r\n \r\n ))}\r\n >\r\n )}\r\n \r\n \r\n \r\n \r\n \r\n );\r\n}\r\n\r\nexport default Categories;\r\n","import React, { useContext, useEffect } from \"react\";\r\nimport { FormInputHook } from \"../../utilities/formInputHook\";\r\nimport { formTypes } from \"../../config.json\";\r\nimport FormTemplate from \"../../components/common/formTemplate\";\r\nimport FormInput from \"../../components/common/formInput\";\r\nimport { addCategory, updateCategory } from \"../../services/categoriesService\";\r\nimport { UserContext } from \"../../contexts/userContext\";\r\n\r\nfunction CategoryForm({ defaultData, formType }) {\r\n const { authed } = useContext(UserContext);\r\n const {\r\n dataForm,\r\n setDataForm,\r\n disableInput,\r\n updateValue,\r\n handleDisableInput,\r\n } = FormInputHook({ defaultData, formType });\r\n\r\n useEffect(() => {\r\n setDataForm({\r\n ...dataForm,\r\n details: {\r\n ...dataForm.details,\r\n },\r\n });\r\n }, [authed]);\r\n\r\n const addCategoryValidation = () => {\r\n const errors = [];\r\n const data = { ...dataForm.details };\r\n if (data.name === null || data.name.trim() === \"\") {\r\n errors.push(\"Name is required.\");\r\n }\r\n return errors;\r\n };\r\n const updateCategoryValidation = () => {\r\n const errors = [];\r\n const data = { ...dataForm.details };\r\n if (data.name === null || data.name.trim() === \"\") {\r\n errors.push(\"Name is required.\");\r\n }\r\n return errors;\r\n };\r\n const validations = () => {\r\n if (formType === formTypes.add) {\r\n return addCategoryValidation();\r\n } else {\r\n return updateCategoryValidation();\r\n }\r\n };\r\n return (\r\n \r\n \r\n \r\n );\r\n}\r\n\r\nexport default CategoryForm;\r\n","import {\r\n BrowserRouter as Router,\r\n Routes,\r\n Route,\r\n Navigate,\r\n} from \"react-router-dom\";\r\nimport RequireAuth from \"./utilities/requireAuth\";\r\nimport Stores from \"./pages/stores/Stores\";\r\nimport Company from \"./pages/companies/Company\";\r\nimport Users from \"./pages/users/users\";\r\nimport Sales from \"./pages/sales/sales\";\r\nimport SalesForm from \"./pages/sales/salesForms\";\r\nimport { formTypes } from \"./config.json\";\r\nimport Profile from \"./pages/profile/Profile\";\r\nimport StoresForm from \"./pages/stores/storesForm\";\r\nimport AssignUserToCompany from \"./pages/companies/assignUserToCompany\";\r\nimport CompanyForm from \"./pages/companies/companyForm\";\r\nimport MyComapny from \"./pages/profile/myCompany\";\r\nimport UserForm from \"./pages/users/userForm\";\r\nimport UserPoints from \"./pages/users/userPoints\";\r\nimport PointsForm from \"./pages/users/pointsForm\";\r\nimport LoginPage from \"./pages/login/LoginPage\";\r\n\r\nimport MainPage from \"./pages/mainPage\";\r\nimport ExternalLoginPage from \"./pages/login/externalLoginPage\";\r\nimport Analytics from \"./pages/analytics/Analytics\";\r\nimport Categories from \"./pages/categories/Categories\";\r\nimport CategoryForm from \"./pages/categories/categoryForm\";\r\n\r\nexport const mainRoutes = () => (\r\n \r\n \r\n } />\r\n } />\r\n } />\r\n \r\n \r\n);\r\n\r\nexport const createRoutes = () => (\r\n \r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n \r\n \r\n \r\n }\r\n />\r\n\r\n } />\r\n } />\r\n \r\n);\r\n","import \"./App.css\";\r\nimport { UserContextProvider } from \"./contexts/userContext\";\r\nimport { mainRoutes } from \"./routes\";\r\nimport ConfirmationDialogContextProvider from \"./contexts/confirmationDialogContext\";\r\nimport { createTheme, CssBaseline, ThemeProvider } from \"@material-ui/core\";\r\n\r\nconst theme = createTheme({\r\n palette: {},\r\n});\r\n\r\nfunction App() {\r\n // const { setUserContextObject, authed } = useContext(UserContext);\r\n const routes = mainRoutes();\r\n return (\r\n <>\r\n \r\n \r\n \r\n \r\n {[routes]}\r\n \r\n \r\n \r\n >\r\n );\r\n}\r\n\r\nexport default App;\r\n","import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport App from './App';\r\nimport { UserContextProvider } from \"./contexts/userContext\";\r\nimport {ConfirmationDialogContextProvider} from \"./contexts/confirmationDialogContext\";\r\n\r\nReactDOM.render(\r\n \r\n \r\n ,\r\n document.getElementById('root')\r\n);\r\n"],"sourceRoot":""}