Skip to content

Commit 7b65045

Browse files
committed
Refactor Achievements to use typed props
Updated the Achievements component to use destructured, typed props based on fullPlayerDataType instead of accessing properties via the generic props object. This improves type safety and code clarity.
1 parent 34020c8 commit 7b65045

1 file changed

Lines changed: 32 additions & 12 deletions

File tree

src/Components/Achievements/Achievements.tsx

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,28 @@ import Shipping from '../AchieveTabs/Shipping'
1212
import Earnings from '../AchieveTabs/moneyEarned'
1313
import Collection from '../AchieveTabs/Collection'
1414
import Quests from '../AchieveTabs/quests'
15+
import type { fullPlayerDataType } from 'types/displayDataTypes.js';
1516

16-
const Achievements = (props) => {
17+
const Achievements = ({
18+
playerName,
19+
farmName,
20+
experience,
21+
moneyEarned,
22+
professions,
23+
shippedItems,
24+
cropsShipped,
25+
mineralsFound,
26+
cookedItems,
27+
museumCollection,
28+
availableSpecialRequests,
29+
fishCaught,
30+
friendship,
31+
itemsCrafted,
32+
monstersKilled,
33+
questsDone,
34+
specialRequests,
35+
tailoredItems,
36+
}: fullPlayerDataType ) => {
1737
const TabImg = [
1838
{img: TabCook, alt: "Cooking"},
1939
{img: TabCraft, alt: "Crafting"},
@@ -37,57 +57,57 @@ const Achievements = (props) => {
3757
</TabList>
3858
<TabPanel>
3959
<section className="achievement-container">
40-
<Food recipesCooked={props.recipesCooked}></Food>
60+
<Food recipesCooked={cookedItems}></Food>
4161
</section>
4262
</TabPanel>
4363
<TabPanel>
4464
<section className="achievement-container">
45-
<Crafting itemsCrafted={props.itemsCrafted}></Crafting>
65+
<Crafting itemsCrafted={itemsCrafted}></Crafting>
4666
</section>
4767
</TabPanel>
4868
<TabPanel>
4969
<section className="achievement-container">
50-
<Crops cropsShipped={props.cropsShipped} />
70+
<Crops cropsShipped={cropsShipped} />
5171
</section>
5272
</TabPanel>
5373
<TabPanel>
5474
<section className="achievement-container">
55-
<Fish fishCaught={props.fishCaught} />
75+
<Fish fishCaught={fishCaught} />
5676
</section>
5777
</TabPanel>
5878
<TabPanel>
5979
<section className="achievement-container">
60-
<Friendship friendship={props.friendship}/>
80+
<Friendship friendship={friendship}/>
6181
</section>
6282
</TabPanel>
6383
<TabPanel>
6484
<section className="achievement-container">
65-
<Monsters monstersKilled={props.monstersKilled}/>
85+
<Monsters monstersKilled={monstersKilled}/>
6686
</section>
6787
</TabPanel>
6888
<TabPanel>
6989
<section className="achievement-container">
70-
<Shipping shippedItems={props.shippedItems}/>
90+
<Shipping shippedItems={shippedItems}/>
7191
</section>
7292
</TabPanel>
7393
<TabPanel>
7494
<section className="achievement-container">
75-
<Earnings moneyEarned={props.moneyEarned}/>
95+
<Earnings moneyEarned={moneyEarned}/>
7696
</section>
7797
</TabPanel>
7898
<TabPanel>
7999
<section className="achievement-container">
80-
<Collection museumCollection={props.museumCollection} />
100+
<Collection museumCollection={museumCollection} />
81101
</section>
82102
</TabPanel>
83103
<TabPanel>
84104
<section className="achievement-container">
85-
<Quests questsDone={props.questsDone} specialReq={props.specialReq} pendingSpecialReq={props.pendingSpecialReq} />
105+
<Quests questsDone={questsDone} specialReq={specialRequests} pendingSpecialReq={pendingSpecialReq} />
86106
</section>
87107
</TabPanel>
88108
<TabPanel>
89109
<section className="achievement-container">
90-
<Quests questsDone={props.questsDone} specialReq={props.specialReq} pendingSpecialReq={props.pendingSpecialReq} />
110+
<Quests questsDone={questsDone} specialReq={specialRequests} pendingSpecialReq={pendingSpecialReq} />
91111
</section>
92112
</TabPanel>
93113
</Tabs>

0 commit comments

Comments
 (0)