Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions backend/database/Cupon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import sqlalchemy as sql
from web import sql_database as db


class Cupon(db.Model):
id = sql.Column(sql.Integer, primary_key=True)
name = sql.Column(sql.String(100), nullable=False, unique=True)
color = sql.Column(sql.String(7), nullable=False)
18 changes: 18 additions & 0 deletions backend/database/CuponDrink.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sqlalchemy as sql
from web import sql_database as db
from sqlalchemy.orm import relationship


class CuponDrink(db.Model):
id = sql.Column(sql.Integer, primary_key=True)
cupon_id = sql.Column(sql.Integer, sql.ForeignKey(
'cupon.id'), nullable=False)
cupon = relationship(
'database.Cupon.Cupon', lazy="joined")

drink_id = sql.Column(sql.Integer, sql.ForeignKey(
'drink.id'), nullable=False)
drink = relationship(
'database.Drink.Drink', lazy="joined")

price = sql.Column(sql.Float, nullable=False)
13 changes: 13 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"date-fns": "^2.30.0",
"emoji-mart": "^5.5.2",
"js-cookie": "^3.0.5",
"mui-color-input": "^2.0.1",
"react": "^18.2.0",
"react-countup": "^6.5.0",
"react-dom": "^18.2.0",
Expand Down
20 changes: 20 additions & 0 deletions frontend/src/Components/Admin/Cupons/AddCupon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Stack, TextField, Typography } from '@mui/material'
import React, { useState } from 'react'
import style from './cupon.module.scss';
import { MuiColorInput } from 'mui-color-input';

type Props = {}

const AddCupon = (props: Props) => {
const [color, setcolor] = useState("#ffdd00")
return (
<div className={style.addCuponPage}>
<Stack flexDirection={"row"} alignItems={"center"} flexWrap={"wrap"} gap={2}>
<TextField label="Cupon Name" variant="outlined" />
<MuiColorInput value={color} onChange={(value)=>{setcolor(value)}} />
</Stack>
</div>
)
}

export default AddCupon
33 changes: 33 additions & 0 deletions frontend/src/Components/Admin/Cupons/CuponDisplay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Button, Paper, Stack, Typography } from '@mui/material'
import React from 'react'
import style from './cupon.module.scss';
import SellIcon from '@mui/icons-material/Sell';
import Spacer from '../../Common/Spacer';
import DeleteIcon from '@mui/icons-material/Delete';
import EditIcon from '@mui/icons-material/Edit';

type Props = {}

const CuponDisplay = (props: Props) => {
return (
<Paper className={style.cuponDisplayContainer}>
<Stack direction="row" alignItems="center" justifyContent="space-between" gap={1}>
<SellIcon sx={{color:"#ffdd00"}}/>
<Typography variant='h5'>
Rentner
</Typography>
</Stack>
<Spacer vertical={15} />
<Stack direction="row" alignItems="center" justifyContent="space-between" gap={1}>
<Button variant="outlined" color="primary">
<DeleteIcon />
</Button>
<Button variant="outlined" color="primary">
<EditIcon />
</Button>
</Stack>
</Paper>
)
}

export default CuponDisplay
35 changes: 35 additions & 0 deletions frontend/src/Components/Admin/Cupons/Overview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react'
import CuponDisplay from './CuponDisplay'
import { Button, Stack, Typography } from '@mui/material'
import AddIcon from '@mui/icons-material/Add';
import style from './cupon.module.scss';
import Spacer from '../../Common/Spacer';
import { useNavigate } from 'react-router-dom';

type Props = {}

const Overview = (props: Props) => {
const navigate = useNavigate();
return (
<div className={style.cuponsPage}>
<Stack direction="row" alignItems="center" justifyContent="flex-start" gap={5}>
<Typography variant='h3'>
Cupons
</Typography>
<Button variant="outlined" color="primary" onClick={()=>{navigate("add")}}>
<AddIcon />
</Button>
</Stack>
<Spacer vertical={15} />
<Stack direction="row" alignItems="center" justifyContent="flex-start" gap={1} flexWrap={"wrap"}>
<CuponDisplay />
<CuponDisplay />
<CuponDisplay />
<CuponDisplay />
<CuponDisplay />
</Stack>
</div>
)
}

export default Overview
18 changes: 18 additions & 0 deletions frontend/src/Components/Admin/Cupons/cupon.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@import "../../Common/variables.module.scss";

.cuponsPage{
padding: $padding;
}

.addCuponPage{
padding: $padding;
}

.cuponDisplayContainer{
width: fit-content;
padding: $padding;
}

.cuponDisplayHeadline{
display: flex;
}
14 changes: 12 additions & 2 deletions frontend/src/Components/Admin/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import Infobox from '../../Common/InfoBox/Infobox';
import { Area, AreaChart, Bar, BarChart, CartesianGrid, Legend, Tooltip, XAxis, YAxis } from 'recharts';
import TopDepter from '../Common/TopDepter/TopDepter';
import { RootState } from '../../../Reducer/reducerCombiner';
import { BENUTZER_ZAHL, BUDGET, EINSTELLUNGEN, GELD_VERTEILUNG, GETRAENKE, LETZE_100_KAEUFE, MITGLIEDER, TRANSAKTIONEN, VERSTECKTE_NUTZER } from '../../Common/Internationalization/i18n';
import { BENUTZER_ZAHL, BUDGET, CUPONS, EINSTELLUNGEN, GELD_VERTEILUNG, GETRAENKE, LETZE_100_KAEUFE, MITGLIEDER, TRANSAKTIONEN, VERSTECKTE_NUTZER } from '../../Common/Internationalization/i18n';
import { Transaction } from '../../../types/ResponseTypes';

import SellIcon from '@mui/icons-material/Sell';

type Props = {}

Expand Down Expand Up @@ -179,6 +179,16 @@ const Overview = (props: Props) => {
<Spacer horizontal={10} />
<Typography variant={headingType}>{TRANSAKTIONEN}</Typography>
</Button>
<Button
size="large"
className={style.button}
variant='contained'
onClick={() => navigate("cupons")}
>
<SellIcon sx={buttonSize} />
<Spacer horizontal={10} />
<Typography variant={headingType}>{CUPONS}</Typography>
</Button>
<Button
size="large"
className={style.button}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const BETRAG_NICHT_NEGATIV = "Betrag darf nicht negativ sein";
export const BITTE_EMPFAENGER = "Bitte einen Empfänger eintragen";
export const BUDGET = "Budget";
export const BUILD_NUMBER = "Build: {0}";
export const CUPONS = "Cupons";
export const DATENSCHUTZ = "Datenschutz";
export const DATUM = "Datum";
export const DIFFERENZ = "Differenz";
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/Components/Common/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import AccountBalanceIcon from '@mui/icons-material/AccountBalance';
import { RootState } from '../../../Reducer/reducerCombiner';
import InfoIcon from '@mui/icons-material/Info';
import About from './About';
import { ABRECHNUNGEN, EINSTELLUNGEN, GETRAENKE, MITGLIEDER, NUTZER_DASHBOARD, TRANSAKTIONEN } from '../Internationalization/i18n';
import { ABRECHNUNGEN, CUPONS, EINSTELLUNGEN, GETRAENKE, MITGLIEDER, NUTZER_DASHBOARD, TRANSAKTIONEN } from '../Internationalization/i18n';
import SellIcon from '@mui/icons-material/Sell';
import Cookies from 'js-cookie';

type Props = {}
Expand Down Expand Up @@ -195,6 +196,14 @@ const TopBar = (props: Props) => {
<ListItemText primary={ABRECHNUNGEN} />
</ListItemButton>
</ListItem>
<ListItem disablePadding>
<ListItemButton onClick={() => navigate("/admin/cupons")}>
<ListItemIcon>
<SellIcon />
</ListItemIcon>
<ListItemText primary={CUPONS} />
</ListItemButton>
</ListItem>
<ListItem disablePadding>
<ListItemButton onClick={() => navigate("/admin/settings")}>
<ListItemIcon>
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/Components/Routing/Routing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Transactions from '../Admin/Transactions/Transactions';
import Login from '../Common/Login/Login';
import Details from '../User/Details/Details';
import UserOverview from '../User/Overview/Overview';
import CuponOverview from '../Admin/Cupons/Overview';
import AddCupon from '../Admin/Cupons/AddCupon';

type Props = {}

Expand All @@ -24,6 +26,8 @@ const Routing = (props: Props) => {
<Route path="/admin/transactions" element={<Transactions />} />
<Route path="/admin/drinks" element={<Drinks />} />
<Route path="/admin/checkout" element={<Checkout />} />
<Route path="/admin/cupons" element={<CuponOverview />} />
<Route path="/admin/cupons/add" element={<AddCupon />} />
<Route path="/admin/settings" element={<Settings />} />
</Routes>
</>
Expand Down