Skip to content

Commit

Permalink
Removed the delete functionality from my campaigns tab (#1073)
Browse files Browse the repository at this point in the history
  • Loading branch information
marinovl7 authored Oct 25, 2022
1 parent 1af551c commit a748d18
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 53 deletions.
53 changes: 4 additions & 49 deletions src/components/auth/profile/MyCampaignsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { bg, enUS } from 'date-fns/locale'
import { useTranslation } from 'next-i18next'
import { useState, useMemo } from 'react'
import { DataGrid, GridColDef, GridColumns, GridRenderCellParams } from '@mui/x-data-grid'
import { Tooltip, Button, Box, Typography, styled } from '@mui/material'
import { Tooltip, Button, Box, Typography } from '@mui/material'

import { getExactDateTime, getRelativeDate } from 'common/util/date'
import { money } from 'common/util/money'
Expand All @@ -19,7 +19,6 @@ import {
DisplayReachedAmount,
} from 'components/campaigns/grid/CampaignGrid'
import DetailsModal from '../../campaigns/grid/modals/DetailsModal'
import DeleteModal from '../../campaigns/grid/modals/DeleteModal'
import ProfileTab from './ProfileTab'
import { ProfileTabs } from './tabs'

Expand All @@ -32,46 +31,11 @@ const classes = {
boxTitle: `${PREFIX}-boxTitle`,
}

const Root = styled('div')(({ theme }) => ({
[`& .${classes.h3}`]: {
fontStyle: 'normal',
fontWeight: '500',
fontSize: '25px',
lineHeight: '116.7%',
margin: '0',
},
[`& .${classes.thinFont}`]: {
fontStyle: 'normal',
fontWeight: 400,
fontSize: '24px',
lineHeight: '123.5%',
letterSpacing: '0.25px',
color: '#000000',
margin: 0,
},
[`& .${classes.smallText}`]: {
fontFamily: 'Lato, sans-serif',
fontStyle: 'normal',
fontWeight: '500',
fontSize: '15px',
lineHeight: '160%',
letterSpacing: '0.15px',
},
[`& .${classes.boxTitle}`]: {
backgroundColor: 'white',
padding: theme.spacing(3, 7),
paddingBottom: theme.spacing(3),
marginTop: theme.spacing(3),
boxShadow: theme.shadows[3],
},
}))

export default function MyCampaingsTable() {
const { t, i18n } = useTranslation()
const locale = i18n.language == 'bg' ? bg : enUS
const [viewId, setViewId] = useState<string | undefined>()
const [deleteId, setDeleteId] = useState<string | undefined>()
const { data: campaigns = [], refetch } = useGetUserCampaigns()
const { data: campaigns = [] } = useGetUserCampaigns()
const selectedCampaign = useMemo(
() => campaigns.find((c) => c.id === viewId),
[campaigns, viewId],
Expand All @@ -92,8 +56,9 @@ export default function MyCampaingsTable() {
return (
<GridActions
id={cellValues.row.id}
allowDelete={false}
onView={() => setViewId(cellValues.row.id)}
onDelete={() => setDeleteId(cellValues.row.id)}
onDelete={() => null}
/>
)
},
Expand Down Expand Up @@ -304,16 +269,6 @@ export default function MyCampaingsTable() {
{selectedCampaign && (
<DetailsModal campaign={selectedCampaign} onClose={() => setViewId(undefined)} />
)}
{deleteId && (
<DeleteModal
id={deleteId}
onDelete={() => {
refetch()
setDeleteId(undefined)
}}
onClose={() => setDeleteId(undefined)}
/>
)}
</Box>
</>
)
Expand Down
1 change: 1 addition & 0 deletions src/components/campaigns/grid/CampaignGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default function CampaignGrid() {
return (
<GridActions
id={cellValues.row.id}
allowDelete={true}
onView={() => setViewId(cellValues.row.id)}
onDelete={() => setDeleteId(cellValues.row.id)}
/>
Expand Down
11 changes: 7 additions & 4 deletions src/components/campaigns/grid/GridActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { routes } from 'common/routes'

type Props = {
id: string
allowDelete: boolean
onView: () => void
onDelete: () => void
}

export default function GridActions({ id, onView, onDelete }: Props) {
export default function GridActions({ id, allowDelete, onView, onDelete }: Props) {
return (
<Box
style={{
Expand All @@ -31,9 +32,11 @@ export default function GridActions({ id, onView, onDelete }: Props) {
<EditOutlinedIcon />
</IconButton>
</Link>
<IconButton size="small" color="primary" onClick={onDelete}>
<DeleteOutlinedIcon />
</IconButton>
{allowDelete && (
<IconButton size="small" color="primary" onClick={onDelete}>
<DeleteOutlinedIcon />
</IconButton>
)}
</Box>
)
}

0 comments on commit a748d18

Please sign in to comment.