Skip to content

Commit

Permalink
Merge pull request #49 from dragoni7/equip-shared-loadout
Browse files Browse the repository at this point in the history
Equip shared loadout
  • Loading branch information
Rorschach7552 authored Sep 4, 2024
2 parents 3097fbe + 297d0bb commit 07aa11f
Show file tree
Hide file tree
Showing 9 changed files with 534 additions and 169 deletions.
15 changes: 7 additions & 8 deletions src/app/routes/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ import NumberBoxes from '../../features/armor-optimization/NumberBoxes';
import { getDestinyMembershipId } from '../../features/membership/bungie-account';
import { updateMembership } from '../../store/MembershipReducer';
import { getProfileData } from '../../features/profile/destiny-profile';
import { updateProfileData } from '../../store/ProfileReducer';
import { Character, SubclassConfig } from '../../types/d2l-types';
import { updateProfileData, updateSelectedCharacter } from '../../store/ProfileReducer';
import { Character, FilteredPermutation, SubclassConfig } from '../../types/d2l-types';
import StatsTable from '../../features/armor-optimization/StatsTable';
import HeaderComponent from '../../components/HeaderComponent';
import ExoticSelector from '../../features/armor-optimization/ExoticSelector';
import greyBackground from '../../assets/grey.png';
import { db } from '../../store/db';
import { resetLoadout, updateLoadoutCharacter, updateSubclass } from '../../store/LoadoutReducer';
import SubclassCustomizationWrapper from '../../features/subclass/SubclassCustomizationWrapper';
import { updateManifest } from '../../lib/bungie_api/manifest';
import LoadoutCustomization from '../../components/LoadoutCustomization';
import greyBackground from '../../assets/grey.png';
import ExoticSelector from '../../features/armor-optimization/ExoticSelector';
import { DAMAGE_TYPE } from '../../lib/bungie_api/constants';

const PageContainer = styled('div')({
Expand Down Expand Up @@ -132,7 +133,7 @@ export const Dashboard: React.FC = () => {
dispatch(updateProfileData(profileData));

if (profileData.characters.length > 0) {
setSelectedCharacter(profileData.characters[0]);
dispatch(updateSelectedCharacter(profileData.characters[0]));
}
};

Expand Down Expand Up @@ -193,9 +194,7 @@ export const Dashboard: React.FC = () => {
}, [permutations, selectedValues]);

const handleCharacterClick = (character: Character) => {
if (selectedCharacter && selectedCharacter?.id !== character.id) {
setSelectedCharacter(character);
}
dispatch(updateSelectedCharacter(character));
};

const handleSubclassSelect = (subclass: SubclassConfig) => {
Expand Down
45 changes: 28 additions & 17 deletions src/components/HeaderComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { styled } from '@mui/system';
import { Character } from '../types/d2l-types';
import { useDispatch } from 'react-redux';
import { updateSelectedCharacter } from '../store/ProfileReducer';

interface HeaderComponentProps {
emblemUrl: string;
Expand Down Expand Up @@ -74,22 +76,31 @@ const HeaderComponent: React.FC<HeaderComponentProps> = ({
characters,
selectedCharacter,
onCharacterClick,
}) => (
<Header emblemUrl={emblemUrl}>
<OverlayImage src={overlayUrl} alt="Overlay Image" />
<DisplayName>{displayName}</DisplayName>
<ButtonContainer>
{characters.map((character) => (
<CharacterText
key={character.id}
isSelected={selectedCharacter?.id === character.id}
onClick={() => onCharacterClick(character)}
>
{character.class}
</CharacterText>
))}
</ButtonContainer>
</Header>
);
}) => {
const dispatch = useDispatch();

const handleCharacterClick = (character: Character) => {
onCharacterClick(character);
dispatch(updateSelectedCharacter(character));
};

return (
<Header emblemUrl={emblemUrl}>
<OverlayImage src={overlayUrl} alt="Overlay" />
<DisplayName>{displayName}</DisplayName>
<ButtonContainer>
{characters.map((character) => (
<CharacterText
key={character.id}
isSelected={selectedCharacter?.id === character.id}
onClick={() => handleCharacterClick(character)}
>
{character.class}
</CharacterText>
))}
</ButtonContainer>
</Header>
);
};

export default HeaderComponent;
Loading

0 comments on commit 07aa11f

Please sign in to comment.