feat: Refactor user profile management and improve token validation

- Introduced `useUserProfile` hook to centralize user profile fetching and management.
- Updated various components to utilize the new `useUserProfile` hook instead of context.
- Enhanced token validation logic in `Fetch` function to prevent unnecessary redirects.
- Added `parseDueDate` function to handle due date parsing with improved logic.
- Cleaned up user profile state management across multiple views and settings.
- Improved loading states and error handling in user-related components.
- remove usercontext and just use react query for userProfile
This commit is contained in:
Mo Tarbin
2025-06-08 02:09:23 -04:00
parent 10f646f125
commit e21e71b442
20 changed files with 353 additions and 239 deletions

View File

@@ -23,9 +23,9 @@ import {
Typography,
} from '@mui/joy'
import React, { useEffect, useState } from 'react'
import { UserContext } from '../../contexts/UserContext'
import { useChores, useChoresHistory } from '../../queries/ChoreQueries'
import { useCircleMembers } from '../../queries/UserQueries.jsx'
import { useCircleMembers, useUserProfile } from '../../queries/UserQueries.jsx'
import { ChoresGrouper } from '../../utils/Chores'
import { TASK_COLOR } from '../../utils/Colors.jsx'
import { resolvePhotoURL } from '../../utils/Helpers.jsx'
@@ -167,7 +167,8 @@ const USER_FILTER = (history, userId) => {
}
const UserActivites = () => {
const { userProfile } = React.useContext(UserContext)
const { data: userProfile } = useUserProfile()
const [tabValue, setTabValue] = React.useState(30)
const [selectedHistory, setSelectedHistory] = React.useState([])
const [enrichedHistory, setEnrichedHistory] = React.useState([])