Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1606 archivable teams adjust frontend #2672

Merged
merged 18 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 20 additions & 0 deletions src/frontend/src/pages/TeamsPage/TeamPill.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Chip } from '@mui/material';
import { red } from '@mui/material/colors';

export const TeamPill: React.FC<{
superhvarn marked this conversation as resolved.
Show resolved Hide resolved
displayText: string;
}> = ({ displayText }) => {
return (
<Chip
size="small"
label={displayText}
variant="filled"
sx={{
fontSize: 12,
color: 'white',
backgroundColor: red[600],
width: 100
}}
/>
);
};
75 changes: 64 additions & 11 deletions src/frontend/src/pages/TeamsPage/TeamSpecificPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Grid } from '@mui/material';
import { Box, Grid, Menu, MenuItem, Stack } from '@mui/material';
import { useSingleTeam } from '../../hooks/teams.hooks';
import { useParams } from 'react-router-dom';
import TeamMembersPageBlock from './TeamMembersPageBlock';
Expand All @@ -13,9 +13,11 @@ import { Delete } from '@mui/icons-material';
import { NERButton } from '../../components/NERButton';
import { useCurrentUser } from '../../hooks/users.hooks';
import { isAdmin } from 'shared';
import { useState } from 'react';
import React, { useState } from 'react';
import DeleteTeamModal from './DeleteTeamModal';
import SetTeamTypeModal from './SetTeamTypeModal';
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
import { TeamPill } from './TeamPill';

interface ParamTypes {
teamId: string;
Expand All @@ -27,39 +29,90 @@ const TeamSpecificPage: React.FC = () => {
const user = useCurrentUser();
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [showTeamTypeModal, setShowTeamTypeModal] = useState(false);
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const dropdownOpen = Boolean(anchorEl);

const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};

const handleDropdownClose = () => {
setAnchorEl(null);
};

if (isError) return <ErrorPage message={error?.message} />;
if (isLoading || !data) return <LoadingIndicator />;

const DeleteButton = () => (
<NERButton
variant="contained"
disabled={!isAdmin(user.role)}
startIcon={<Delete />}
onClick={() => setShowDeleteModal(true)}
sx={{ marginRight: '10px' }}
disabled={!isAdmin(user.role)}
>
Delete
</NERButton>
);

const SetTeamTypeButton = () => (
<NERButton variant="contained" disabled={!isAdmin(user.role)} onClick={() => setShowTeamTypeModal(true)}>
<NERButton variant="contained" onClick={() => setShowTeamTypeModal(true)} disabled={!isAdmin(user.role)}>
Set Team Type
</NERButton>
);

const ArchiveTeamButton = () => (
<NERButton variant="contained" disabled={!isAdmin(user.role)}>
Archive Team
</NERButton>
);

const UnarchiveTeamButton = () => (
<NERButton variant="contained" disabled={!isAdmin(user.role)}>
Unarchive
</NERButton>
);

superhvarn marked this conversation as resolved.
Show resolved Hide resolved
const TeamActionsDropdown = () => (
<div>
superhvarn marked this conversation as resolved.
Show resolved Hide resolved
<NERButton
superhvarn marked this conversation as resolved.
Show resolved Hide resolved
endIcon={<ArrowDropDownIcon style={{ fontSize: 28 }} />}
variant="contained"
id="team-actions-dropdown"
onClick={handleClick}
>
Actions
</NERButton>
<Menu
open={dropdownOpen}
anchorEl={anchorEl}
onClose={handleDropdownClose}
anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
transformOrigin={{ vertical: 'top', horizontal: 'left' }}
>
<MenuItem onClick={handleDropdownClose}>
{data.dateArchived ? <UnarchiveTeamButton /> : <ArchiveTeamButton />}
</MenuItem>
<MenuItem onClick={handleDropdownClose}>
<DeleteButton />
</MenuItem>
</Menu>
</div>
);

return (
<PageLayout
headerRight={
isAdmin(user.role) && (
<>
<DeleteButton />
<SetTeamTypeButton />
</>
)
<Stack direction="row" spacing={2} justifyContent="flex-end">
<SetTeamTypeButton />
{TeamActionsDropdown()}
</Stack>
}
title={`Team ${data.teamName}`}
chips={
<Box display="flex" gap="20px">
<TeamPill displayText={data.dateArchived ? 'Archived' : 'Unarchived'} />
</Box>
superhvarn marked this conversation as resolved.
Show resolved Hide resolved
}
previousPages={[{ name: 'Teams', route: routes.TEAMS }]}
>
<Grid container spacing={2}>
Expand Down
Loading