diff --git a/mailadmin/static/mailadmin/src/_sidebar.scss b/mailadmin/static/mailadmin/src/_sidebar.scss new file mode 100644 index 0000000..86051ff --- /dev/null +++ b/mailadmin/static/mailadmin/src/_sidebar.scss @@ -0,0 +1,44 @@ +/* Hide for mobile, show later */ +.sidebar { + .orgunit-list { + display: none; + @media (min-width: 768px) { + display: block; + } + } +} +.search-field { + margin-bottom: 20px; +} +.orgunit-list { + margin-bottom: 40px; + + li { + &.active { + a, + a:hover, + a:focus { + color: #fff; + background-color: $primary; + } + } + a { + padding: 0.5rem 0.8rem; + display: block; + + + &:hover { + text-decoration: none; + background-color: #eee; + } + } + } +} +.orgunit-select-container { + display: block; + margin-bottom: 20px; + + @media (min-width: map-get($grid-breakpoints, "md")) { + display: none; + } +} diff --git a/mailadmin/static/mailadmin/src/components/MainArea.js b/mailadmin/static/mailadmin/src/components/MainArea.js index bfa08e9..fc5fe8b 100644 --- a/mailadmin/static/mailadmin/src/components/MainArea.js +++ b/mailadmin/static/mailadmin/src/components/MainArea.js @@ -1,22 +1,238 @@ -import React from 'react'; -// import { parseEmails } from '../utils'; +import React, { useState } from 'react'; +import { groupBy, sortBy } from 'lodash'; +import { useQuery } from '@apollo/react-hooks'; +import ctx from 'classnames'; + +import { parseEmails } from '../utils'; +import { GET_ALIASES, GET_DOMAINS, GET_ORG_UNITS } from '../queries'; const ListCreate = () => { + const { data, loading, error } = useQuery(GET_ORG_UNITS); + const { data: emailData, loading: emailLoading, error: emailError } = useQuery(GET_DOMAINS); + const [textareaVisible, setTextareaVisible] = useState(false); + const [listName, setListName] = useState(''); + const [selectedPrefix, setSelectedPrefix] = useState(null); + + if (loading || emailLoading || error || emailError) { + return null; + } + + const { orgUnits } = data; + const { domains } = emailData; + const emailDomain = domains[0]; + return (
- -
-
+
+
+
+
+
+
+ +
+ {orgUnits.map((ou) => + ou.prefixes.map((prefix) => ( + { + e.preventDefault(); + setSelectedPrefix(prefix); + }} + > + {prefix}- + + )) + )} +
+
+ setListName(e.target.value)} + /> +
+ {`@${emailDomain.name}`} +
+
+ +
+
+ {/*
*/}
); }; -const Forwards = () => { +const AliasRow = ({ id, destination, updateDeletionList }) => { + const [checked, setChecked] = useState(false); + return ( + + {destination} + +
+ { + setChecked(e.target.checked); + updateDeletionList(id, e.target.checked); + }} + /> +
+ + + ); +}; + +const ActionRow = ({ onAddEmailClick, deleteVisible, onDelete }) => { + return ( + + + + + + + + + + + ); +}; + +const EmailsTextarea = ({ list, selectedPrefix, newList = false }) => { + const [rawAliases, setRawAliases] = useState(''); + const [aliases, setAliases] = useState([]); + + const createAliases = () => { + console.log(list, aliases, selectedPrefix, newList); + // TODO: POST /aliases + }; + return ( + <> +
+ Eposter{' '} + {aliases.length === 0 ? '' : aliases.length} +
+