|
1 | | -import React, { useState, useEffect } from 'react' |
| 1 | +import { AchievementItem, ItemWithCounter } from '@components/common'; |
2 | 2 | import type { cropsShippedType } from 'types/displayDataTypes'; |
3 | 3 |
|
4 | | -interface CropsShippedWrapperType { |
5 | | - cropsShipped: cropsShippedType; |
6 | | -} |
7 | 4 |
|
8 | | -const Crops= (cropsShipped : CropsShippedWrapperType) => { |
9 | | - let _monocultureText = cropsShipped.cropsShipped.hasMonoculture ? "You already have the 'Monoculture' Achievement" : `You've shipped ${ cropsShipped.cropsShipped.maxMono?.name } the most and you require ${300 - cropsShipped.cropsShipped.maxMono?.shipped} more of it to get the 'Monoculture' Achievement`; |
10 | | - let _polycultureText = cropsShipped.cropsShipped.hasPolyculture ? "You already have the 'Polyculture' Achievement" : `You need to ship 15 crops for each polyculture crop to get the 'Polyculture' achievement`; |
11 | | - |
| 5 | +const Crops= ({poly_crops, mono_extras, achievements} : cropsShippedType) => { |
12 | 6 | return ( |
13 | 7 | <div className="progress-container"> |
14 | | - {/* <span className="a-title"><h1>{_monocultureAchieved ? `You've shipped ${ maxShipped.name } the most and you require ${300 - maxShipped.times} more of it to get the 'Monoculture' Achievement` : <span className="completed">`You already have the 'Monoculture' Achievement`</span> }</h1></span> */} |
15 | 8 | <br /> |
16 | | - <h2>Farming Achievements</h2> |
17 | | - <ul className="a-List"> |
18 | | - <li>Monoculture: <span className={cropsShipped.cropsShipped.hasMonoculture ? "completed" : "pending"}>{_monocultureText}</span> </li> |
19 | | - <li>Polyculture: <span className={cropsShipped.cropsShipped.hasPolyculture ? "completed" : "pending"}>{_polycultureText}</span></li> |
20 | | - </ul> |
| 9 | + <h2>Farming Achievements</h2> |
| 10 | + <div className="section-achievements"> |
| 11 | + {achievements && achievements.map((ach, i) => ( |
| 12 | + <AchievementItem |
| 13 | + key={i} |
| 14 | + done={ach.done} |
| 15 | + image={ach.image} |
| 16 | + achievementName={ach.name} |
| 17 | + achievementDesc={ach.description} |
| 18 | + achievementHoverDesc={ach.hoverDesc} |
| 19 | + />))} |
| 20 | + </div> |
21 | 21 | <span className="a-title"><p>Ship 15 of the following crops to get the 'Polyculture' achievement</p></span> |
22 | | - {cropsShipped.cropsShipped.poly_crops.map((crop, i) =><a href={`https://stardewvalleywiki.com/${crop.image}`} target="_blank" rel="noreferrer" key={i}> <img key={i} src={`https://stardew-tracker.s3.amazonaws.com/Crops/${crop.image}.png`} alt={crop.name} className={ (crop.shipped !== undefined) ? ((crop.shipped >= 15) ? "done" : "known" ): "" } title={(crop.shipped !== undefined) ? (crop.shipped >= 15) ? `You have shipped ${crop.name} ${crop.shipped} times` : `You have to ship ${ 15 - crop.shipped} more ${crop.name} ` : `You haven't shipped ${crop.name}`} ></img></a>)} |
| 22 | + <div className="item-grid"> |
| 23 | + { poly_crops ? |
| 24 | + poly_crops.map((d, i) => |
| 25 | + <ItemWithCounter |
| 26 | + key={i} |
| 27 | + link={`https://stardewvalleywiki.com/${d.link}`} |
| 28 | + src={`https://stardew-tracker.s3.amazonaws.com/Crops/${d.image}.png`} |
| 29 | + name={d.name} |
| 30 | + state={ (d.shipped) ? "done" : "known" } |
| 31 | + hoverDesc={(d.shipped) ? |
| 32 | + (d.shipped && d.shipped > 0) ? `Cooked ${d.name} ${d.shipped} times` |
| 33 | + : `You haven't cooked ${d.name}` |
| 34 | + : `You don't know how to cook ${d.name}`} |
| 35 | + times={d.shipped ? d.shipped : 0} |
| 36 | + />) |
| 37 | + : <div>No cooking data available.</div> |
| 38 | + } |
| 39 | + </div> |
23 | 40 |
|
24 | 41 | <span className="a-title"><p>These crops are not counted for the 'Polyculture' achievement</p></span> |
25 | | - {cropsShipped.cropsShipped.mono_extras.map((crop, i) =><a href={`https://stardewvalleywiki.com/${crop.image}`} target="_blank" rel="noreferrer" key={i}> <img key={i} src={`https://stardew-tracker.s3.amazonaws.com/Crops/${crop.image}.png`} alt={crop.name} className={ (crop.shipped !== undefined) ? ((crop.shipped > 0) ? "done" : "known" ): "" } title={(crop.shipped !== undefined) ? `You have shipped ${crop.name} ${crop.shipped} times` : `You haven't shipped ${crop.name}`} ></img></a>)} |
| 42 | + <div className="item-grid"> |
| 43 | + { mono_extras ? |
| 44 | + mono_extras.map((d, i) => |
| 45 | + <ItemWithCounter |
| 46 | + key={i} |
| 47 | + link={`https://stardewvalleywiki.com/${d.link}`} |
| 48 | + src={`https://stardew-tracker.s3.amazonaws.com/Crops/${d.image}.png`} |
| 49 | + name={d.name} |
| 50 | + state={ (d.shipped) ? "done" : "known" } |
| 51 | + hoverDesc={(d.shipped) ? |
| 52 | + (d.shipped && d.shipped > 0) ? `Cooked ${d.name} ${d.shipped} times` |
| 53 | + : `You haven't cooked ${d.name}` |
| 54 | + : `You don't know how to cook ${d.name}`} |
| 55 | + times={d.shipped ? d.shipped : 0} |
| 56 | + />) |
| 57 | + : <div>No cooking data available.</div> |
| 58 | + } |
| 59 | + </div> |
| 60 | + {/* {cropsShipped.cropsShipped.mono_extras.map((crop, i) => |
| 61 | + <a href={`https://stardewvalleywiki.com/${crop.image}`} target="_blank" rel="noreferrer" key={i}> |
| 62 | + <img key={i} src={`https://stardew-tracker.s3.amazonaws.com/Crops/${crop.image}.png`} |
| 63 | + alt={crop.name} className={ (crop.shipped !== undefined) ? ((crop.shipped > 0) ? "done" : "known" ): "" } title={(crop.shipped !== undefined) ? `You have shipped ${crop.name} ${crop.shipped} times` : `You haven't shipped ${crop.name}`} ></img></a>)} */} |
26 | 64 | </div> |
27 | 65 | ); |
28 | 66 | }; |
|
0 commit comments