Skip to content

Commit

Permalink
Added refresh button to dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoni7 committed Sep 15, 2024
1 parent 27e60a6 commit 54f7965
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/routes/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { ManifestArmorStatMod, ManifestExoticArmor } from '../../types/manifest-
import { SharedLoadoutDto } from '../../features/loadouts/types';
import { updateProfileCharacters } from '../../store/ProfileReducer';
import { getProfileData } from '../../util/profile-characters';
import RefreshCharacters from '../../components/RefreshCharacters';

const PageContainer = styled(Box)(({ theme }) => ({
display: 'flex',
Expand Down Expand Up @@ -447,6 +448,7 @@ export const Dashboard: React.FC = () => {
/>
) : sharedLoadoutDto === undefined && selectedSubclass ? (
<>
<RefreshCharacters />
<HeaderWrapper>
<HeaderComponent
emblemUrl={characters[selectedCharacterIndex]?.emblem?.secondarySpecial || ''}
Expand Down
39 changes: 39 additions & 0 deletions src/components/RefreshCharacters.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Box, CircularProgress, IconButton, Tooltip } from '@mui/material';
import { Refresh } from '@mui/icons-material';
import { useDispatch } from 'react-redux';
import { refreshProfileCharacters } from '../util/profile-characters';
import { useState } from 'react';

export default function RefreshCharacters() {
const dispatch = useDispatch();
const [refreshing, setRefreshing] = useState<boolean>(false);

async function onRefreshClick() {
setRefreshing(true);
await refreshProfileCharacters(dispatch);
setRefreshing(false);
}

return (
<Box
sx={{ position: 'fixed', top: '1%', right: '1%', zIndex: 9999, mixBlendMode: 'difference' }}
>
{refreshing ? (
<CircularProgress color="inherit" />
) : (
<Tooltip title="Refresh Data">
<IconButton
onClick={onRefreshClick}
sx={{
borderRadius: 4,
mixBlendMode: 'difference',
':hover': { mixBlendMode: 'difference' },
}}
>
<Refresh color="inherit" fontSize="large" />
</IconButton>
</Tooltip>
)}
</Box>
);
}

0 comments on commit 54f7965

Please sign in to comment.