Skip to content

Commit

Permalink
Add more styling to table
Browse files Browse the repository at this point in the history
  • Loading branch information
erikaas24 committed Nov 7, 2024
1 parent 503ba00 commit d8b1d58
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
30 changes: 18 additions & 12 deletions frontend/src/components/pages/organization/OrgShop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import { useQuery } from "@apollo/client";
import { Box, Grid, Stack, Typography } from "@mui/material";
import { useTheme } from "@mui/material/styles";
import { useState } from "react";

import { AdminOrganizationFragment, PaginatedShopOrdersDocument } from "@/generated/graphql";

import { ShopSale } from "../orgs/ShopSale";
import { TableStepper } from "../orgs/TableStepper";
import { HEADER_DESKTOP_HEIGHT} from "@/lib/mui/theme/constants";

type Props = {
organization: AdminOrganizationFragment;
};
export const OrgProducts: React.FC<Props> = ({ organization }) => {
const theme = useTheme();
const limit = 5;
const limit = 100;
const [page, setPage] = useState(0);

const handlePageChange = (newValue: number) => {
Expand Down Expand Up @@ -50,25 +49,26 @@ export const OrgProducts: React.FC<Props> = ({ organization }) => {
spacing={0}
padding={1}
borderBottom={1}
sx={{ bgcolor: theme.palette.background.elevated, color: theme.palette.text.primary }}
position={"sticky"}
sx={{ bgcolor: theme.palette.background.elevated, color: theme.palette.text.primary, top: HEADER_DESKTOP_HEIGHT - 20, zIndex:1}}
>
<Box display="flex" alignItems="left" justifyContent="left" width={"25%"} padding={1}>
<Typography variant="body1">Navn på kunde</Typography>
<Typography variant="body1" fontWeight={"bold"}>Navn på kunde</Typography>
</Box>
<Box display="flex" alignItems="left" justifyContent="left" width={"15%"} padding={1}>
<Typography variant="body1">Kjøpt produkt</Typography>
<Typography variant="body1" fontWeight={"bold"}>Kjøpt produkt</Typography>
</Box>
<Box display="flex" alignItems="left" justifyContent="left" width={"15%"} padding={1}>
<Typography variant="body1">Antall bestilt</Typography>
<Typography variant="body1" fontWeight={"bold"}>Antall bestilt</Typography>
</Box>
<Box display="flex" alignItems="left" justifyContent="left" width={"15%"} padding={1}>
<Typography variant="body1">Betalt status</Typography>
<Typography variant="body1" fontWeight={"bold"}>Betalt status</Typography>
</Box>
<Box display="flex" alignItems="left" justifyContent="left" width={"15%"} padding={1}>
Mulige handlinger
<Typography fontWeight={"bold"}>Mulige handlinger</Typography>
</Box>
<Box display="flex" alignItems="left" justifyContent="left" width={"15%"} padding={1}>
<Typography variant="body1">Har vi levert varen</Typography>
<Typography variant="body1" fontWeight={"bold"}>Har vi levert varen</Typography>
</Box>
</Stack>

Expand All @@ -78,10 +78,16 @@ export const OrgProducts: React.FC<Props> = ({ organization }) => {
data && (
<>
<Grid container spacing={0}>
{data?.paginatedShopOrders?.slice(0, limit).map((order) => {
{data?.paginatedShopOrders?.slice(0, limit).map((order, index) => {
return (
<Grid key={order.id} item xs={12} sm={12} md={12}>
<Stack borderBottom={1} borderColor={"gray"}>
<Stack
borderBottom={1}
borderColor={"gray"}
sx={{
bgcolor: index % 2 === 0 ? theme.palette.background.paper : theme.palette.background.elevated,
}}
>
<ShopSale
name={order.user.firstName + " " + order.user.lastName}
product_name={order.product.name}
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/pages/orgs/ShopSale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMutation } from "@apollo/client";
import { Check, Clear } from "@mui/icons-material";
import { Box, IconButton, Stack, Tooltip, Typography } from "@mui/material";
import { useState } from "react";

import { useTheme } from "@mui/material/styles";
import { DeliveredProductDocument } from "@/generated/graphql";

type Props = {
Expand All @@ -15,15 +15,17 @@ type Props = {
};

export const ShopSale: React.FC<Props> = ({ name, product_name, quantity, has_paid, is_delivered, order_id }) => {
const theme = useTheme();
const [delivered, setdelivered] = useState(is_delivered);
const [deliverProduct] = useMutation(DeliveredProductDocument);


function handle_click(bool: boolean) {
setdelivered(bool);
deliverProduct({ variables: { orderId: order_id } });
}
return (
<Stack direction={"row"} padding={1} spacing={0}>
<Stack direction={"row"} padding={1} spacing={0} sx={{color: theme.palette.text.primary}}>
<Box display="flex" alignItems="left" justifyContent="left" width={"25%"} padding={1}>
<Typography variant="body1">{name}</Typography>
</Box>
Expand Down

0 comments on commit d8b1d58

Please sign in to comment.