From e39bab4835d531cd4f093996f80ee6142e3d3b58 Mon Sep 17 00:00:00 2001 From: Georgi Parlakov Date: Fri, 5 Jul 2024 12:09:25 +0300 Subject: [PATCH] feat: campaign application admin init (#1867) * feat: campaign application admin init - issue #1842 - add a admin space for the campaign applications - only skeleton - will be fleshed out iteratively - add admin edit campaign application - it will show all the steps of the stepper (create campaign application) with addition of the admin-only editable stuff * Update EditPage.tsx * fix: linting for campaign application admin edit --- .eslintrc.js | 11 +++--- README.md | 2 ++ src/common/routes.ts | 4 +++ .../CampaignApplications.tsx | 26 ++++++++++++++ .../admin/campaign-applications/EditPage.tsx | 36 +++++++++++++++++++ .../common/navigation/adminMenu.tsx | 10 ++++++ .../admin/campaign-applications/edit/[id].tsx | 7 ++++ .../admin/campaign-applications/index.tsx | 6 ++++ 8 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 src/components/admin/campaign-applications/CampaignApplications.tsx create mode 100644 src/components/admin/campaign-applications/EditPage.tsx create mode 100644 src/pages/admin/campaign-applications/edit/[id].tsx create mode 100644 src/pages/admin/campaign-applications/index.tsx diff --git a/.eslintrc.js b/.eslintrc.js index c82e8eaa6..446629ed2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -45,9 +45,12 @@ module.exports = { endOfLine: 'auto', }, ], - 'no-restricted-imports': ["error", { - "name": "react-i18next", - "message": "Please use next-i18next" - }] + 'no-restricted-imports': [ + 'error', + { + name: 'react-i18next', + message: 'Please use next-i18next', + }, + ], }, } diff --git a/README.md b/README.md index 75b254c40..425532187 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,9 @@ Watch releases of this repository to be notified about future updates: ## Contributors ✨ + [![All Contributors](https://img.shields.io/badge/all_contributors-82-orange.svg?style=flat-square)](#contributors-) + Please check [contributors guide](https://github.com/podkrepi-bg/frontend/blob/master/CONTRIBUTING.md) for: diff --git a/src/common/routes.ts b/src/common/routes.ts index c567b64e6..6f03310d0 100644 --- a/src/common/routes.ts +++ b/src/common/routes.ts @@ -160,6 +160,10 @@ export const routes = { viewCampaignBySlug: (slug: string) => `/admin/campaigns/${slug}`, edit: (id: string) => `/admin/campaigns/edit/${id}`, }, + campaignApplications: { + index: '/admin/campaign-applications', + edit: (id: string) => `/admin/campaign-applications/edit/${id}`, + }, news: { index: '/admin/campaign-news', create: '/admin/campaign-news/create', diff --git a/src/components/admin/campaign-applications/CampaignApplications.tsx b/src/components/admin/campaign-applications/CampaignApplications.tsx new file mode 100644 index 000000000..a3eadbc40 --- /dev/null +++ b/src/components/admin/campaign-applications/CampaignApplications.tsx @@ -0,0 +1,26 @@ +import { useTranslation } from 'next-i18next' + +import EditOutlinedIcon from '@mui/icons-material/EditOutlined' +import { IconButton } from '@mui/material' +import { routes } from 'common/routes' +import AdminContainer from 'components/common/navigation/AdminContainer' +import AdminLayout from 'components/common/navigation/AdminLayout' +import Link from 'next/link' + +export default function CampaignApplicationsPage() { + const { t } = useTranslation('campaigns') + + return ( + + +
Campaigns will appear here
+ + + + takes you to edit page + + +
+
+ ) +} diff --git a/src/components/admin/campaign-applications/EditPage.tsx b/src/components/admin/campaign-applications/EditPage.tsx new file mode 100644 index 000000000..c708dc3df --- /dev/null +++ b/src/components/admin/campaign-applications/EditPage.tsx @@ -0,0 +1,36 @@ +import { CampaignApplicationFormData } from 'components/client/campaign-application/helpers/campaignApplication.types' +import CampaignApplication from 'components/client/campaign-application/steps/CampaignApplication' +import CampaignApplicationDetails from 'components/client/campaign-application/steps/CampaignApplicationDetails' +import CampaignApplicationOrganizer from 'components/client/campaign-application/steps/CampaignApplicationOrganizer' +import GenericForm from 'components/common/form/GenericForm' +import AdminContainer from 'components/common/navigation/AdminContainer' +import AdminLayout from 'components/common/navigation/AdminLayout' + +export default function EditPage() { + const initialValues = { + organizer: { + name: '', + phone: '', + email: '', + }, + } as CampaignApplicationFormData + + return ( + + + Will layout all the steps from the stepper plus the admin step + + onSubmit={(v) => console.log(v)} + initialValues={initialValues}> + + +
.
+ +
.
+ +
.
+ Edit the status and ticket URL here +
+
+ ) +} diff --git a/src/components/common/navigation/adminMenu.tsx b/src/components/common/navigation/adminMenu.tsx index cb13f0f32..4fe80a0e4 100644 --- a/src/components/common/navigation/adminMenu.tsx +++ b/src/components/common/navigation/adminMenu.tsx @@ -38,6 +38,11 @@ export const menuPeople = [ ] export const menuCampaings = [ { label: 'Кампании', icon: AssignmentInd, href: routes.admin.campaigns.index }, + { + label: 'Кандидат Кампании', + icon: AssignmentInd, + href: routes.admin.campaignApplications.index, + }, { label: 'Новини', icon: ArticleOutlined, href: routes.admin.news.index }, { label: 'Документи', icon: FolderShared, href: routes.admin.documents.index }, { label: 'Злоупотреби', icon: ReportGmailerrorredIcon, href: routes.admin.irregularity.index }, @@ -73,6 +78,11 @@ export const items = [ export const adminCards = [ { label: 'Кампании', icon: AssignmentInd, href: routes.admin.campaigns.index }, + { + label: 'Кандидат Кампании', + icon: AssignmentInd, + href: routes.admin.campaignApplications.index, + }, { label: 'Новини', icon: ArticleOutlined, href: routes.admin.news.index }, { label: 'Плащания', icon: PaymentsIcon, href: routes.admin.payments.index }, { label: 'Дарения', icon: VolunteerActivismOutlinedIcon, href: routes.admin.donations.index }, diff --git a/src/pages/admin/campaign-applications/edit/[id].tsx b/src/pages/admin/campaign-applications/edit/[id].tsx new file mode 100644 index 000000000..7782229e5 --- /dev/null +++ b/src/pages/admin/campaign-applications/edit/[id].tsx @@ -0,0 +1,7 @@ +import EditPage from 'components/admin/campaign-applications/EditPage' + +import { securedPropsWithTranslation } from 'middleware/auth/securedProps' + +export const getServerSideProps = securedPropsWithTranslation() + +export default EditPage diff --git a/src/pages/admin/campaign-applications/index.tsx b/src/pages/admin/campaign-applications/index.tsx new file mode 100644 index 000000000..2f0335687 --- /dev/null +++ b/src/pages/admin/campaign-applications/index.tsx @@ -0,0 +1,6 @@ +import CampaignApplications from 'components/admin/campaign-applications/CampaignApplications' +import { securedPropsWithTranslation } from 'middleware/auth/securedProps' + +export const getServerSideProps = securedPropsWithTranslation() + +export default CampaignApplications