From a71fb529d07df7ec33c044f88e27af859b51fb2a Mon Sep 17 00:00:00 2001 From: Jonatan Norbye Date: Sun, 10 Sep 2023 07:58:36 +0200 Subject: [PATCH] Connect admin-pages under the same view --- .../InputValidationFeedback/index.tsx | 2 +- frontend/src/components/NavBar/UserInfo.tsx | 4 +- frontend/src/components/NavBar/index.tsx | 34 ++-- .../containers/AdmissionsContainer/index.tsx | 4 +- frontend/src/global.d.ts | 7 +- frontend/src/index.tsx | 4 +- .../AdminPageAbakusLeaderView/CSVExport.tsx | 14 -- .../AdminPageAbakusLeaderView/LinkLink.tsx | 10 -- .../AdminPageAbakusLeaderView/Statistics.tsx | 11 -- .../StatisticsGroupLogo.tsx | 9 -- .../StatisticsName.tsx | 13 -- .../StatisticsWrapper.tsx | 17 -- .../AdminPageAbakusLeaderView/Wrapper.tsx | 22 --- .../EditGroup.tsx} | 68 +------- .../ViewApplications.tsx} | 148 +++++++++--------- .../components/EditGroupForm.tsx} | 0 .../components}/GroupStatistics.tsx | 8 +- .../AdmissionAdmin/components/NavBar.tsx | 68 ++++++++ .../components/StyledElements.tsx | 63 ++++++++ .../components}/csrftoken.tsx | 0 .../components}/styles.tsx | 1 + frontend/src/routes/AdmissionAdmin/index.tsx | 54 +++++++ frontend/src/routes/ApplicationPortal.tsx | 11 +- .../src/routes/ManageAdmissions/index.tsx | 5 +- frontend/src/types.ts | 2 +- frontend/src/utils/config.ts | 8 +- frontend/src/utils/djangoData.ts | 14 +- 27 files changed, 326 insertions(+), 275 deletions(-) delete mode 100644 frontend/src/routes/AdminPageAbakusLeaderView/CSVExport.tsx delete mode 100644 frontend/src/routes/AdminPageAbakusLeaderView/LinkLink.tsx delete mode 100644 frontend/src/routes/AdminPageAbakusLeaderView/Statistics.tsx delete mode 100644 frontend/src/routes/AdminPageAbakusLeaderView/StatisticsGroupLogo.tsx delete mode 100644 frontend/src/routes/AdminPageAbakusLeaderView/StatisticsName.tsx delete mode 100644 frontend/src/routes/AdminPageAbakusLeaderView/StatisticsWrapper.tsx delete mode 100644 frontend/src/routes/AdminPageAbakusLeaderView/Wrapper.tsx rename frontend/src/routes/{AdminPage/index.tsx => AdmissionAdmin/EditGroup.tsx} (69%) rename frontend/src/routes/{AdminPageAbakusLeaderView/index.tsx => AdmissionAdmin/ViewApplications.tsx} (59%) rename frontend/src/routes/{AdminPage/form.tsx => AdmissionAdmin/components/EditGroupForm.tsx} (100%) rename frontend/src/routes/{AdminPageAbakusLeaderView => AdmissionAdmin/components}/GroupStatistics.tsx (92%) create mode 100644 frontend/src/routes/AdmissionAdmin/components/NavBar.tsx create mode 100644 frontend/src/routes/AdmissionAdmin/components/StyledElements.tsx rename frontend/src/routes/{AdminPage => AdmissionAdmin/components}/csrftoken.tsx (100%) rename frontend/src/routes/{AdminPage => AdmissionAdmin/components}/styles.tsx (98%) create mode 100644 frontend/src/routes/AdmissionAdmin/index.tsx diff --git a/frontend/src/components/InputValidationFeedback/index.tsx b/frontend/src/components/InputValidationFeedback/index.tsx index fc144b2e..db3e0c13 100644 --- a/frontend/src/components/InputValidationFeedback/index.tsx +++ b/frontend/src/components/InputValidationFeedback/index.tsx @@ -7,6 +7,6 @@ interface InputValidationFeedbackProps { const InputValidationFeedback: React.FC = ({ error, -}) => (error ?
{error}
: null); +}) => (error ?

{error}

: null); export default InputValidationFeedback; diff --git a/frontend/src/components/NavBar/UserInfo.tsx b/frontend/src/components/NavBar/UserInfo.tsx index e5378bf3..d09cb836 100644 --- a/frontend/src/components/NavBar/UserInfo.tsx +++ b/frontend/src/components/NavBar/UserInfo.tsx @@ -2,10 +2,10 @@ import React from "react"; import styled from "styled-components"; import { media } from "src/styles/mediaQueries"; import avatar from "assets/avatar.png"; -import { User } from "src/types"; +import { DjangoUserData } from "src/utils/djangoData"; interface UserInfoProps { - user: User; + user: DjangoUserData; } const UserInfo: React.FC = ({ user }) => { diff --git a/frontend/src/components/NavBar/index.tsx b/frontend/src/components/NavBar/index.tsx index 1b6c6d2c..b435cbff 100644 --- a/frontend/src/components/NavBar/index.tsx +++ b/frontend/src/components/NavBar/index.tsx @@ -4,17 +4,17 @@ import UserInfo from "./UserInfo"; import AbakusLogo from "src/components/AbakusLogo"; import NavItem from "./NavItem"; import { media } from "src/styles/mediaQueries"; -import { User } from "src/types"; import { useParams } from "react-router-dom"; import { useAdmission } from "src/query/hooks"; +import { DjangoUserData } from "src/utils/djangoData"; interface NavBarProps { - user: User; + user: DjangoUserData; isEditing: boolean; } const NavBar: React.FC = ({ user, isEditing }) => { - const { admissionSlug } = useParams(); + const { admissionSlug, ...params } = useParams(); const { data: admission } = useAdmission(admissionSlug ?? ""); const isRevy = admissionSlug === "revy"; @@ -23,20 +23,20 @@ const NavBar: React.FC = ({ user, isEditing }) => { - {!admission?.userdata.has_application || isEditing ? ( - - - - - ) : ( - - - - )} - + + {params["*"]?.substring(0, 5) !== "admin" && ( + <> + {!admission?.userdata.has_application || + (isEditing && ( + + ))} + + + )} + ); diff --git a/frontend/src/containers/AdmissionsContainer/index.tsx b/frontend/src/containers/AdmissionsContainer/index.tsx index b81758c0..aa287a70 100644 --- a/frontend/src/containers/AdmissionsContainer/index.tsx +++ b/frontend/src/containers/AdmissionsContainer/index.tsx @@ -15,9 +15,9 @@ import SubComponentWrapper from "./SubComponentWrapper"; import SubComponentHeader from "./SubComponentHeader"; import { Application } from "src/types"; import { useState } from "react"; -import { TableWrapper } from "src/routes/AdminPageAbakusLeaderView/Wrapper"; import styled from "styled-components"; import Icon from "src/components/Icon"; +import { TableWrapper } from "src/routes/AdmissionAdmin/components/StyledElements"; interface AdmissionsContainerProps { applications: Application[]; @@ -32,7 +32,7 @@ export interface AdmissionsTableValues { numApplications: number; createdAt: string; updatedAt: string; - text: string; + text?: string; groupApplications: InnerTableValues[]; } diff --git a/frontend/src/global.d.ts b/frontend/src/global.d.ts index 1048e426..d3dfc646 100644 --- a/frontend/src/global.d.ts +++ b/frontend/src/global.d.ts @@ -1,3 +1,6 @@ +import { DjangoConfig } from "./utils/config"; +import { DjangoData } from "./utils/djangoData"; + declare global { namespace NodeJS { interface ProcessEnv { @@ -5,8 +8,8 @@ declare global { } } interface Window { - __CONFIG__: any; - __DJANGO__: any; + __CONFIG__: DjangoConfig; + __DJANGO__: DjangoData; } } diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index 366c870f..6892f4be 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -60,7 +60,9 @@ const AppRoutes = () => path: "/admin/*", element: ( diff --git a/frontend/src/routes/AdminPageAbakusLeaderView/CSVExport.tsx b/frontend/src/routes/AdminPageAbakusLeaderView/CSVExport.tsx deleted file mode 100644 index 4f88184b..00000000 --- a/frontend/src/routes/AdminPageAbakusLeaderView/CSVExport.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import styled from "styled-components"; -import { CSVLink } from "react-csv"; - -const CSVExport = styled(CSVLink)` - padding: 1em 0; - display: block; - text-align: center; - border-top: 5px solid #c0392b; - border-bottom: 1px solid #c0392b; - width: 100%; - font-weight: bold; -`; - -export default CSVExport; diff --git a/frontend/src/routes/AdminPageAbakusLeaderView/LinkLink.tsx b/frontend/src/routes/AdminPageAbakusLeaderView/LinkLink.tsx deleted file mode 100644 index f6246291..00000000 --- a/frontend/src/routes/AdminPageAbakusLeaderView/LinkLink.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import styled from "styled-components"; -import { Link } from "react-router-dom"; - -const LinkLink = styled(Link)` - padding: 1em 0; - display: block; - font-weight: bold; -`; - -export default LinkLink; diff --git a/frontend/src/routes/AdminPageAbakusLeaderView/Statistics.tsx b/frontend/src/routes/AdminPageAbakusLeaderView/Statistics.tsx deleted file mode 100644 index 39673e89..00000000 --- a/frontend/src/routes/AdminPageAbakusLeaderView/Statistics.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import styled from "styled-components"; - -const Statistics = styled.div` - padding: 0.5em; - display: flex; - justify-content: center; - width: 100%; - flex-wrap: wrap; -`; - -export default Statistics; diff --git a/frontend/src/routes/AdminPageAbakusLeaderView/StatisticsGroupLogo.tsx b/frontend/src/routes/AdminPageAbakusLeaderView/StatisticsGroupLogo.tsx deleted file mode 100644 index c3ebde19..00000000 --- a/frontend/src/routes/AdminPageAbakusLeaderView/StatisticsGroupLogo.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import styled from "styled-components"; - -const StatisticsGroupLogo = styled.img` - object-fit: scale-down; - max-height: 2em; - margin: 0.3em 0; -`; - -export default StatisticsGroupLogo; diff --git a/frontend/src/routes/AdminPageAbakusLeaderView/StatisticsName.tsx b/frontend/src/routes/AdminPageAbakusLeaderView/StatisticsName.tsx deleted file mode 100644 index 2cb66bf6..00000000 --- a/frontend/src/routes/AdminPageAbakusLeaderView/StatisticsName.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import styled from "styled-components"; - -interface SmallDescriptionProps { - capitalize?: boolean; -} - -const SmallDescription = styled.span` - font-size: 0.8em; - font-weight: bold; - text-transform: ${(props) => (props.capitalize ? "capitalize" : "normal")}; -`; - -export default SmallDescription; diff --git a/frontend/src/routes/AdminPageAbakusLeaderView/StatisticsWrapper.tsx b/frontend/src/routes/AdminPageAbakusLeaderView/StatisticsWrapper.tsx deleted file mode 100644 index 7f608353..00000000 --- a/frontend/src/routes/AdminPageAbakusLeaderView/StatisticsWrapper.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import styled from "styled-components"; - -interface SmallDescriptionWrapperProps { - smallerMargin?: boolean; -} - -const SmallDescriptionWrapper = styled.div` - display: inline-flex; - flex-direction: column; - margin: ${(props) => (props.smallerMargin ? "0 0.5em 1em 1em" : "1em")}; - - justify-content: flex-start; - line-height: 1; - align-items: center; -`; - -export default SmallDescriptionWrapper; diff --git a/frontend/src/routes/AdminPageAbakusLeaderView/Wrapper.tsx b/frontend/src/routes/AdminPageAbakusLeaderView/Wrapper.tsx deleted file mode 100644 index 8e393a3a..00000000 --- a/frontend/src/routes/AdminPageAbakusLeaderView/Wrapper.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import styled from "styled-components"; -import { Card } from "src/components/Card"; -import { media } from "src/styles/mediaQueries"; - -const Wrapper = styled(Card)` - width: 80%; - max-width: 100%; - min-height: 30em; - padding: 0; - - ${media.handheld` - width: auto; - padding: 0 10px; - `}; -`; - -export default Wrapper; - -export const TableWrapper = styled.div` - max-width: 100%; - overflow-x: auto; -`; diff --git a/frontend/src/routes/AdminPage/index.tsx b/frontend/src/routes/AdmissionAdmin/EditGroup.tsx similarity index 69% rename from frontend/src/routes/AdminPage/index.tsx rename to frontend/src/routes/AdmissionAdmin/EditGroup.tsx index f137151e..ed8b4c5d 100644 --- a/frontend/src/routes/AdminPage/index.tsx +++ b/frontend/src/routes/AdmissionAdmin/EditGroup.tsx @@ -3,21 +3,10 @@ import styled from "styled-components"; import { useParams } from "react-router-dom"; import { useAdmission, useApplications } from "src/query/hooks"; import djangoData from "src/utils/djangoData"; -import { media } from "src/styles/mediaQueries"; -import UserApplication from "src/containers/UserApplication"; import LoadingBall from "src/components/LoadingBall"; -import EditGroupForm from "./form"; +import EditGroupForm from "./components/EditGroupForm"; import { replaceQuotationMarks } from "src/utils/methods"; -import { - Wrapper, - LinkLink, - CSVExport, - Statistics, - StatisticsName, - StatisticsWrapper, - GroupLogo, - GroupLogoWrapper, -} from "./styles"; +import { Wrapper, GroupLogo, GroupLogoWrapper } from "./components/styles"; import { Application } from "src/types"; import { AlphabeticalComparatorAsc, @@ -40,7 +29,7 @@ export interface CsvData { phoneNumber: string; } -const AdminPage = () => { +const EditGroup = () => { const { admissionSlug } = useParams(); const [sortedApplications, setSortedApplications] = useState( [] @@ -122,20 +111,16 @@ const AdminPage = () => { return
Feil: klarte ikke laste inn grupper.
; } else { const group = (groups ?? []).find( - (group) => - group.name.toLowerCase() === - djangoData.user.representative_of_group.toLowerCase() + (group) => group.name === djangoData.user.representative_of_group ); if (!group) return
Feil: Ugyldig gruppe
; return ( - Admin Panel

{djangoData.user.representative_of_group}

- Gå til forside { group={group} /> - - - - Antall søkere - {numApplicants} {numApplicants == 1 ? "søker" : "søkere"} - - - - Sorter etter - - {" "} - - - - Eksporter som csv - - {sortedApplications.map((userApplication) => ( - - ))} -
); } }; -export default AdminPage; - -/** Styles **/ +export default EditGroup; export const PageWrapper = styled.div` display: flex; @@ -193,10 +142,3 @@ export const PageWrapper = styled.div` align-items: center; min-height: 100vh; `; - -const PageTitle = styled.h1` - ${media.handheld` - margin: 0 1em 0 1em; - font-size: 2.5rem; - `}; -`; diff --git a/frontend/src/routes/AdminPageAbakusLeaderView/index.tsx b/frontend/src/routes/AdmissionAdmin/ViewApplications.tsx similarity index 59% rename from frontend/src/routes/AdminPageAbakusLeaderView/index.tsx rename to frontend/src/routes/AdmissionAdmin/ViewApplications.tsx index f43b79b2..15a9fd6f 100644 --- a/frontend/src/routes/AdminPageAbakusLeaderView/index.tsx +++ b/frontend/src/routes/AdmissionAdmin/ViewApplications.tsx @@ -2,23 +2,22 @@ import React, { useEffect, useState } from "react"; import styled from "styled-components"; import FormatTime from "src/components/Time/FormatTime"; -import { media } from "src/styles/mediaQueries"; - import LoadingBall from "src/components/LoadingBall"; -import Wrapper from "./Wrapper"; -import LinkLink from "./LinkLink"; -import CSVExport from "./CSVExport"; -import Statistics from "./Statistics"; -import GroupStatistics from "./GroupStatistics"; -import StatisticsName from "./StatisticsName"; -import StatisticsWrapper from "./StatisticsWrapper"; +import GroupStatistics from "./components/GroupStatistics"; import { replaceQuotationMarks } from "src/utils/methods"; import { useAdmission, useApplications } from "src/query/hooks"; import { useParams } from "react-router-dom"; import AdmissionsContainer from "src/containers/AdmissionsContainer"; -import { CsvData } from "src/routes/AdminPage"; +import { CsvData } from "./EditGroup"; import { Application } from "src/types"; +import { + CSVExport, + Statistics, + StatisticsName, + StatisticsWrapper, +} from "./components/StyledElements"; +import djangoData from "src/utils/djangoData"; type CompleteCsvData = { priorityText: string; @@ -26,7 +25,7 @@ type CompleteCsvData = { groupApplicationText: string; } & Omit; -const AdminPageAbakusLeaderView = () => { +const ViewApplications = () => { const { admissionSlug } = useParams(); const [sortedApplications, setSortedApplications] = useState( [] @@ -97,7 +96,7 @@ const AdminPageAbakusLeaderView = () => { appliedWithinDeadline: application.applied_within_deadline, priorityText: application.text != "" - ? replaceQuotationMarks(application.text) + ? replaceQuotationMarks(application.text ?? "") : "Ingen prioriteringer", group: groupApplication.group.name, groupApplicationText: replaceQuotationMarks(groupApplication.text), @@ -129,70 +128,71 @@ const AdminPageAbakusLeaderView = () => { } else { return ( - Admin Panel - Gå til forside - - - - Søknader åpner - - {admission.open_from} - - - - Søknadsfrist - - {admission.public_deadline} - - - - Redigeringsfrist - - {admission.closed_from} - - - + + + Søknader åpner + + {admission.open_from} + + + + Søknadsfrist + + {admission.public_deadline} + + + + Redigeringsfrist + + {admission.closed_from} + + + + + + Antall søkere + {numApplicants} {numApplicants == 1 ? "søker" : "søkere"} + + + Totalt antall søknader + {numApplications} {numApplications == 1 ? "søknad" : "søknader"} + + - - Antall søkere - {numApplicants} {numApplicants == 1 ? "søker" : "søkere"} - - - Totalt antall søknader - {numApplications} {numApplications == 1 ? "søknad" : "søknader"} - - - - {(groups !== undefined ? [...groups] : []) - .sort((a, b) => a.name.localeCompare(b.name)) - .map((group) => ( - - ))} - + {(groups !== undefined ? [...groups] : []) + .filter( + (group) => + admission.userdata.is_admin || + group.name === djangoData.user.representative_of_group + ) + .sort((a, b) => a.name.localeCompare(b.name)) + .map((group) => ( + + ))} - - Eksporter som csv - - - + + + Eksporter som csv + + ); } }; -export default AdminPageAbakusLeaderView; +export default ViewApplications; /** Styles **/ @@ -201,11 +201,7 @@ export const PageWrapper = styled.div` flex-direction: column; align-items: center; min-height: 100vh; -`; - -const PageTitle = styled.h1` - ${media.handheld` - margin: 0 1em 0 1em; - font-size: 2.5rem; - `}; + margin: 1em; + border: 1px solid rgba(0, 0, 0, 0.09); + box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04); `; diff --git a/frontend/src/routes/AdminPage/form.tsx b/frontend/src/routes/AdmissionAdmin/components/EditGroupForm.tsx similarity index 100% rename from frontend/src/routes/AdminPage/form.tsx rename to frontend/src/routes/AdmissionAdmin/components/EditGroupForm.tsx diff --git a/frontend/src/routes/AdminPageAbakusLeaderView/GroupStatistics.tsx b/frontend/src/routes/AdmissionAdmin/components/GroupStatistics.tsx similarity index 92% rename from frontend/src/routes/AdminPageAbakusLeaderView/GroupStatistics.tsx rename to frontend/src/routes/AdmissionAdmin/components/GroupStatistics.tsx index f0412b9c..2da630da 100644 --- a/frontend/src/routes/AdminPageAbakusLeaderView/GroupStatistics.tsx +++ b/frontend/src/routes/AdmissionAdmin/components/GroupStatistics.tsx @@ -1,10 +1,12 @@ import React from "react"; -import StatisticsName from "./StatisticsName"; -import StatisticsWrapper from "./StatisticsWrapper"; -import StatisticsGroupLogo from "./StatisticsGroupLogo"; import { Application } from "src/types"; import styled from "styled-components"; +import { + StatisticsGroupLogo, + StatisticsName, + StatisticsWrapper, +} from "./StyledElements"; interface GroupStatisticsProps { applications: Application[]; diff --git a/frontend/src/routes/AdmissionAdmin/components/NavBar.tsx b/frontend/src/routes/AdmissionAdmin/components/NavBar.tsx new file mode 100644 index 00000000..2c0cf7c8 --- /dev/null +++ b/frontend/src/routes/AdmissionAdmin/components/NavBar.tsx @@ -0,0 +1,68 @@ +import React, { useMemo } from "react"; +import { Link } from "react-router-dom"; +import Icon from "src/components/Icon"; +import { Admission } from "src/types"; +import djangoData from "src/utils/djangoData"; +import styled from "styled-components"; + +interface Props { + admission?: Admission; +} + +const NavBar: React.FC = ({ admission }) => { + const representingGroup = useMemo( + () => + admission?.groups.find( + (group) => group.name === djangoData.user.representative_of_group + ), + [admission] + ); + + return ( + + + Gå tilbake til forsiden + + + Administrer opptak + Se søknader + Administrer grupper + {representingGroup ? ( + + {representingGroup.name} + + ) : ( +

+ Du har ikke tilgang til å redigere noen av gruppene i dette opptaket. +

+ )} +
+ ); +}; + +export default NavBar; + +const Wrapper = styled.div` + padding: 1rem; + + h2, + h3 { + margin-bottom: 0; + margin-top: 0.5em; + } + + p { + margin: 0; + } +`; + +const NavHeader = styled.h3` + margin: 0; +`; + +const NavLink = styled(Link)` + display: block; + line-height: 1.4; + padding: 0.3rem 0; + font-weight: 500; +`; diff --git a/frontend/src/routes/AdmissionAdmin/components/StyledElements.tsx b/frontend/src/routes/AdmissionAdmin/components/StyledElements.tsx new file mode 100644 index 00000000..d685758a --- /dev/null +++ b/frontend/src/routes/AdmissionAdmin/components/StyledElements.tsx @@ -0,0 +1,63 @@ +import { CSVLink } from "react-csv"; +import { Link } from "react-router-dom"; +import styled from "styled-components"; + +interface SmallDescriptionWrapperProps { + smallerMargin?: boolean; +} + +export const StatisticsWrapper = styled.div` + display: inline-flex; + flex-direction: column; + margin: ${(props) => (props.smallerMargin ? "0 0.5em 1em 1em" : "1em")}; + + justify-content: flex-start; + line-height: 1; + align-items: center; +`; + +interface SmallDescriptionProps { + capitalize?: boolean; +} + +export const StatisticsName = styled.span` + font-size: 0.8em; + font-weight: bold; + text-transform: ${(props) => (props.capitalize ? "capitalize" : "normal")}; +`; + +export const StatisticsGroupLogo = styled.img` + object-fit: scale-down; + max-height: 2em; + margin: 0.3em 0; +`; + +export const Statistics = styled.div` + padding: 0.5em; + display: flex; + justify-content: center; + width: 100%; + flex-wrap: wrap; +`; + +export const TableWrapper = styled.div` + max-width: 100%; + width: 100%; + overflow-x: auto; +`; + +export const LinkLink = styled(Link)` + padding: 1em 0; + display: block; + font-weight: bold; +`; + +export const CSVExport = styled(CSVLink)` + padding: 1em 0; + display: block; + text-align: center; + border-top: 5px solid #c0392b; + border-bottom: 1px solid #c0392b; + width: 100%; + font-weight: bold; +`; diff --git a/frontend/src/routes/AdminPage/csrftoken.tsx b/frontend/src/routes/AdmissionAdmin/components/csrftoken.tsx similarity index 100% rename from frontend/src/routes/AdminPage/csrftoken.tsx rename to frontend/src/routes/AdmissionAdmin/components/csrftoken.tsx diff --git a/frontend/src/routes/AdminPage/styles.tsx b/frontend/src/routes/AdmissionAdmin/components/styles.tsx similarity index 98% rename from frontend/src/routes/AdminPage/styles.tsx rename to frontend/src/routes/AdmissionAdmin/components/styles.tsx index 3ff8e7a7..8a1f2e01 100644 --- a/frontend/src/routes/AdminPage/styles.tsx +++ b/frontend/src/routes/AdmissionAdmin/components/styles.tsx @@ -55,6 +55,7 @@ export const GroupLogoWrapper = styled.div` export const EditGroupFormWrapper = styled.div` display: flex; width: 100%; + margin-bottom: 0.5em; div { flex: 1 1 100%; diff --git a/frontend/src/routes/AdmissionAdmin/index.tsx b/frontend/src/routes/AdmissionAdmin/index.tsx new file mode 100644 index 00000000..de3087ee --- /dev/null +++ b/frontend/src/routes/AdmissionAdmin/index.tsx @@ -0,0 +1,54 @@ +import React from "react"; +import { Route, Routes, useParams } from "react-router-dom"; +import styled from "styled-components"; +import ViewApplications from "./ViewApplications"; +import NavBar from "./components/NavBar"; +import { useAdmission } from "src/query/hooks"; +import EditGroup from "./EditGroup"; + +const AdminPage: React.FC = () => { + const { admissionSlug } = useParams(); + const { data: admission } = useAdmission(admissionSlug ?? ""); + + return ( + + + + + + + + } /> + } /> + + + + + ); +}; + +export default AdminPage; + +const PageWrapper = styled.div` + background-color: #ffffff; + display: flex; + flex-direction: column; + align-items: center; + min-height: 100vh; + padding-bottom: 2em; +`; + +const Wrapper = styled.div` + width: 100%; + display: flex; + flex-direction: row; +`; + +const LeftSide = styled.div` + flex-basis: 300px; + flex-shrink: 0; +`; + +const RightSide = styled.div` + flex-grow: 1; +`; diff --git a/frontend/src/routes/ApplicationPortal.tsx b/frontend/src/routes/ApplicationPortal.tsx index 80498ef5..1427106a 100644 --- a/frontend/src/routes/ApplicationPortal.tsx +++ b/frontend/src/routes/ApplicationPortal.tsx @@ -15,8 +15,7 @@ import { useAdmission, useMyApplication } from "src/query/hooks"; import ApplicationForm from "src/routes/ApplicationForm"; import ReceiptForm from "src/routes/ReceiptForm"; import GroupsPage from "src/routes/GroupsPage"; -import AdminPage from "src/routes/AdminPage"; -import AdminPageAbakusLeaderView from "src/routes/AdminPageAbakusLeaderView"; +import AdmissionAdmin from "src/routes/AdmissionAdmin"; import LoadingBall from "src/components/LoadingBall"; import NavBar from "src/components/NavBar"; @@ -142,14 +141,10 @@ const ApplicationPortal = () => { } /> - {admission?.userdata.is_admin ? ( - - ) : ( - - )} + } /> diff --git a/frontend/src/routes/ManageAdmissions/index.tsx b/frontend/src/routes/ManageAdmissions/index.tsx index b067ca19..a4cbd223 100644 --- a/frontend/src/routes/ManageAdmissions/index.tsx +++ b/frontend/src/routes/ManageAdmissions/index.tsx @@ -6,6 +6,7 @@ import { media } from "src/styles/mediaQueries"; import LoadingBall from "src/components/LoadingBall"; import NavBar from "./components/NavBar"; import CreateAdmission from "./CreateAdmission"; +import Icon from "src/components/Icon"; const ManageAdmissions: React.FC = () => { const { data, isFetching, error } = useAdminAdmissions(); @@ -19,7 +20,9 @@ const ManageAdmissions: React.FC = () => {

Administrer opptak

- Gå tilbake til forsiden + + Gå tilbake til forsiden +
diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 123b1299..2b6f48b3 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -26,7 +26,7 @@ export interface Application { applied_within_deadline: boolean; created_at: string; updated_at: string; - text: string; + text?: string; phone_number: string; group_applications: GroupApplication[]; } diff --git a/frontend/src/utils/config.ts b/frontend/src/utils/config.ts index 7c331d41..48590b19 100644 --- a/frontend/src/utils/config.ts +++ b/frontend/src/utils/config.ts @@ -1,4 +1,10 @@ -const defaultConfig = { +export type DjangoConfig = { + SENTRY_DSN?: string; + RELEASE?: string; + ENVIRONMENT?: string; + API_URL: string; +}; +const defaultConfig: DjangoConfig = { API_URL: "http://127.0.0.1:5000/api", }; const config = window.__CONFIG__ diff --git a/frontend/src/utils/djangoData.ts b/frontend/src/utils/djangoData.ts index 8fbcc3f7..4abd7fba 100644 --- a/frontend/src/utils/djangoData.ts +++ b/frontend/src/utils/djangoData.ts @@ -1,4 +1,16 @@ -const defaultConfig = {}; +export type DjangoUserData = { + profile_picture?: string; + full_name?: string; + representative_of_group?: string; + is_staff?: boolean; + is_member_of_webkom?: boolean; +}; + +export type DjangoData = { + user: DjangoUserData; +}; + +const defaultConfig: DjangoData = { user: {} }; const config = window.__DJANGO__ ? { ...defaultConfig, ...window.__DJANGO__ } : defaultConfig;