Skip to content

Commit

Permalink
fix no-unused-vars (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhalife authored Jan 15, 2025
1 parent 4eeca1f commit 0aa164b
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 65 deletions.
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default [
{
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"react/prop-types": "off"
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/Authorization/ForgotPasswordView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ForgotPasswordView = () => {
} else {
setResetStatusOk(false)
}
} catch (error) {
} catch {
setResetStatusOk(false)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/Authorization/LoginView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const LoginView = () => {
setError('An error occurred, please try again')
}
})
.catch(err => {
.catch(() => {
setError('Unable to communicate with server, please try again')
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/Authorization/UpdatePasswordView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const UpdatePasswordView = () => {
} else {
setUpdateStatusOk(false)
}
} catch (error) {
} catch {
setUpdateStatusOk(false)
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/views/ChoreEdit/ChoreEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
CreateChore,
DeleteChore,
GetChoreByID,
GetChoreHistory,
SaveChore,
} from '../../utils/Fetcher'
import { useLabels } from '../Labels/LabelQueries'
Expand Down Expand Up @@ -60,14 +59,13 @@ export const ChoreEdit = () => {
const [isNotificable, setIsNotificable] = useState(false)
const [isActive, setIsActive] = useState(true)
const [updatedBy, setUpdatedBy] = useState(0)
const [createdBy, setCreatedBy] = useState(0)
const [errors, setErrors] = useState({})
const [attemptToSave, setAttemptToSave] = useState(false)
const [isSnackbarOpen, setIsSnackbarOpen] = useState(false)
const [snackbarMessage, setSnackbarMessage] = useState<any>(null)
const [snackbarColor, setSnackbarColor] = useState('warning')
const [addLabelModalOpen, setAddLabelModalOpen] = useState(false)
const { data: userLabelsRaw, isLoading: isUserLabelsLoading } = useLabels()
const { data: userLabelsRaw } = useLabels()

const [userLabels, setUserLabels] = useState([])

Expand Down Expand Up @@ -205,11 +203,7 @@ export const ChoreEdit = () => {
: null,
)
setUpdatedBy(data.res.updatedBy)
setCreatedBy(data.res.createdBy)
setIsNotificable(data.res.notification)
// setDueDate(data.res.dueDate)
// setCompleted(data.res.completed)
// setCompletedDate(data.res.completedDate)
})
}
// set focus on the first input field:
Expand Down Expand Up @@ -454,7 +448,7 @@ export const ChoreEdit = () => {
setLabels(userLabels.filter(l => newValue.indexOf(l.name) > -1))
}}
value={labels.map(l => l.name)}
renderValue={selected => (
renderValue={() => (
<Box sx={{ display: 'flex', gap: '0.25rem' }}>
{labels.map(selectedOption => {
return (
Expand Down
8 changes: 2 additions & 6 deletions src/views/ChoreEdit/ChoreView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
CalendarMonth,
CancelScheduleSend,
Check,
Checklist,
Edit,
Expand All @@ -18,7 +17,6 @@ import {
ListItem,
ListItemContent,
Sheet,
Snackbar,
Typography,
} from '@mui/joy'
import moment from 'moment'
Expand All @@ -42,12 +40,10 @@ export const ChoreView = () => {

const [searchParams] = useSearchParams()

const [secondsLeftToCancel, setSecondsLeftToCancel] = useState<number | null>(null)
const [completedDate, setCompletedDate] = useState(null)
const [confirmModelConfig, setConfirmModelConfig] = useState({})

const handleTaskCompletion = useCallback(() => {
MarkChoreComplete(choreId, note, completedDate)
MarkChoreComplete(choreId, note, null)
.then(resp => {
if (resp.ok) {
return resp.json().then(data => {
Expand All @@ -65,7 +61,7 @@ export const ChoreView = () => {
}
})
})
}, [MarkChoreComplete, GetChoreDetailById, setNote, setChore, choreId, note, completedDate])
}, [MarkChoreComplete, GetChoreDetailById, setNote, setChore, choreId, note])

useEffect(() => {
GetChoreDetailById(choreId).then(resp => {
Expand Down
3 changes: 1 addition & 2 deletions src/views/ChoreEdit/RepeatSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import {
Typography,
} from '@mui/joy'
import moment from 'moment'
import { useContext, useState } from 'react'
import { UserContext } from '../../contexts/UserContext'
import { useState } from 'react'
import React from 'react'

const FREQUANCY_TYPES_RADIOS = [
Expand Down
10 changes: 0 additions & 10 deletions src/views/Chores/ChoreCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const ChoreCard = ({
sx,
viewOnly,
}) => {
const [activeUserId, setActiveUserId] = React.useState(0)
const [isChangeDueDateModalOpen, setIsChangeDueDateModalOpen] =
React.useState(false)
const [isCompleteWithPastDateModalOpen, setIsCompleteWithPastDateModalOpen] =
Expand Down Expand Up @@ -85,10 +84,6 @@ export const ChoreCard = ({
}

const handleChangeDueDate = newDate => {
if (activeUserId === null) {
alert('Please select a performer')
return
}
UpdateDueDate(chore.id, newDate).then(response => {
if (response.ok) {
response.json().then(data => {
Expand All @@ -100,11 +95,6 @@ export const ChoreCard = ({
}

const handleCompleteWithPastDate = newDate => {
if (activeUserId === null) {
alert('Please select a performer')
return
}

MarkChoreComplete(
chore.id,
null,
Expand Down
5 changes: 0 additions & 5 deletions src/views/ChoresOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import {
Adjust,
CancelRounded,
CheckBox,
Edit,
HelpOutline,
History,
QueryBuilder,
SearchRounded,
Warning,
} from '@mui/icons-material'
import {
Avatar,
Button,
ButtonGroup,
Chip,
Expand Down
29 changes: 6 additions & 23 deletions src/views/History/ChoreHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,19 @@ import { HistoryCard } from './HistoryCard'

export const ChoreHistory = () => {
const [choreHistory, setChoresHistory] = useState([])
const [historyInfo, setHistoryInfo] = useState([])
let historyInfo: any[] = [];

const [isLoading, setIsLoading] = useState(true)
const { choreId } = useParams()
const [isEditModalOpen, setIsEditModalOpen] = useState(false)
const [editHistory, setEditHistory] = useState({})

useEffect(() => {
setIsLoading(true)

GetChoreHistory(choreId)
.then(res => res.json())
.then(([historyData, usersData]) => {
.then(([historyData]) => {
setChoresHistory(historyData.res)

const newUserChoreHistory = {}
historyData.res.forEach(choreHistory => {
const userId = choreHistory.completedBy
newUserChoreHistory[userId] = (newUserChoreHistory[userId] || 0) + 1
})

updateHistoryInfo(historyData.res, newUserChoreHistory, usersData.res)
updateHistoryInfo(historyData.res)
})
.catch(error => {
console.error('Error fetching data:', error)
Expand All @@ -52,7 +43,7 @@ export const ChoreHistory = () => {
})
}, [choreId])

const updateHistoryInfo = (histories, userHistories) => {
const updateHistoryInfo = (histories) => {
// average delay for task completaion from due date:
const averageDelay =
histories.reduce((acc, chore) => {
Expand All @@ -74,12 +65,7 @@ export const ChoreHistory = () => {

const maxDelayMoment = moment.duration(maximumDelay, 'hours')

// find max value in userHistories:
const userCompletedByMost = Object.keys(userHistories).reduce((a, b) =>
userHistories[a] > userHistories[b] ? a : b,
)

const historyInfo = [
historyInfo = [
{
icon: <Checklist />,
text: 'Total Completed',
Expand Down Expand Up @@ -168,10 +154,7 @@ export const ChoreHistory = () => {
<List sx={{ p: 0 }}>
{choreHistory.map((historyEntry, index) => (
<HistoryCard
onClick={() => {
setIsEditModalOpen(true)
setEditHistory(historyEntry)
}}
onClick={() => {}}
historyEntry={historyEntry}
allHistory={choreHistory}
key={index}
Expand Down
2 changes: 0 additions & 2 deletions src/views/History/HistoryCard.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { CalendarViewDay, Check, Timelapse } from '@mui/icons-material'
import {
Avatar,
Box,
Chip,
ListDivider,
ListItem,
ListItemContent,
ListItemDecorator,
Typography,
} from '@mui/joy'
import moment from 'moment'
Expand Down
3 changes: 0 additions & 3 deletions src/views/Labels/LabelView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { Add } from '@mui/icons-material'
import { useQueryClient } from 'react-query'
import { getTextColorFromBackgroundColor } from '../../utils/Colors'
import { DeleteLabel } from '../../utils/Fetcher'
import { ConfirmationModal } from '../Modals/Inputs/ConfirmationModal.tsx'
import React from 'react'

export const LabelView = () => {
Expand All @@ -28,7 +27,6 @@ export const LabelView = () => {

const [currentLabel, setCurrentLabel] = useState(null)
const queryClient = useQueryClient()
const [confirmationModel, setConfirmationModel] = useState({})

const handleAddLabel = () => {
setCurrentLabel(null)
Expand Down Expand Up @@ -169,7 +167,6 @@ export const LabelView = () => {
<Add />
</IconButton>
</Box>
<ConfirmationModal config={confirmationModel} />
</Container>
)
}
3 changes: 1 addition & 2 deletions src/views/components/Loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Logo } from '../../Logo'
import React from 'react'

export const LoadingComponent = () => {
const [message, setMessage] = useState('Loading...')
const [subMessage, setSubMessage] = useState('')
useEffect(() => {
const timeout = setTimeout(() => {
Expand Down Expand Up @@ -38,7 +37,7 @@ export const LoadingComponent = () => {
mt: 2,
}}
>
{message}
Loading...
</Box>
<Typography level='h2' fontWeight={500} textAlign={'center'}>
{subMessage}
Expand Down

0 comments on commit 0aa164b

Please sign in to comment.