diff --git a/src/App.scss b/src/App.scss index 21ef27f9..362c8c9f 100644 --- a/src/App.scss +++ b/src/App.scss @@ -17,8 +17,8 @@ $grid-active-border-color: $white; $toolbar-height: 55px; -$achievement-width: 350px; -$achievement-height: 370px; +$achievement-width: 375px; +$achievement-height: 425px; $avatar-editor-width: 620px; $avatar-editor-height: 374px; diff --git a/src/views/achievements/AchievementsView.scss b/src/components/achievements/AchievementsView.scss similarity index 52% rename from src/views/achievements/AchievementsView.scss rename to src/components/achievements/AchievementsView.scss index 025a30c8..f4d9606a 100644 --- a/src/views/achievements/AchievementsView.scss +++ b/src/components/achievements/AchievementsView.scss @@ -3,19 +3,6 @@ height: $achievement-height; } -.nitro-achievements-category-grid { - --nitro-grid-column-min-width: 80px !important; - - .grid-item { - height: 80px; - max-height: 80px; - - .achievement-score { - top: 50px; - } - } -} - .nitro-achievements-back-arrow { background: url('../../assets/images/achievements/back-arrow.png') no-repeat center; width: 33px; @@ -23,6 +10,6 @@ } .nitro-achievements-badge-image { - width: 80px; - height: 80px; + width: 80px !important; + height: 80px !important; } diff --git a/src/views/achievements/AchievementsView.tsx b/src/components/achievements/AchievementsView.tsx similarity index 73% rename from src/views/achievements/AchievementsView.tsx rename to src/components/achievements/AchievementsView.tsx index a3bfbaca..c7ae6633 100644 --- a/src/views/achievements/AchievementsView.tsx +++ b/src/components/achievements/AchievementsView.tsx @@ -1,18 +1,21 @@ import { AchievementData, AchievementEvent, AchievementsEvent, AchievementsScoreEvent, RequestAchievementsMessageComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { LocalizeText } from '../../api'; +import { GetConfiguration, LocalizeText } from '../../api'; +import { Base } from '../../common/Base'; +import { Column } from '../../common/Column'; +import { Flex } from '../../common/Flex'; +import { Text } from '../../common/Text'; import { AchievementsUIEvent, AchievementsUIUnseenCountEvent } from '../../events/achievements'; import { BatchUpdates, CreateMessageHook, dispatchUiEvent, SendMessageHook } from '../../hooks'; import { useUiEvent } from '../../hooks/events'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardSubHeaderView, NitroCardView, NitroLayoutFlexColumn, NitroLayoutGrid, NitroLayoutGridColumn } from '../../layout'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardSubHeaderView, NitroCardView } from '../../layout'; import { NitroLayoutBase } from '../../layout/base'; -import { AchievementsViewProps } from './AchievementsView.types'; import { AchievementCategory } from './common/AchievementCategory'; import { AchievementUtilities } from './common/AchievementUtilities'; import { AchievementsCategoryListView } from './views/category-list/AchievementsCategoryListView'; import { AchievementCategoryView } from './views/category/AchievementCategoryView'; -export const AchievementsView: FC = props => +export const AchievementsView: FC<{}> = props => { const [ isVisible, setIsVisible ] = useState(false); const [ isInitalized, setIsInitalized ] = useState(false); @@ -170,6 +173,15 @@ export const AchievementsView: FC = props => return achievementCategories.find(existing => (existing.code === selectedCategoryCode)); }, [ achievementCategories, selectedCategoryCode ]); + const getCategoryIcon = useMemo(() => + { + if(!getSelectedCategory) return null; + + const imageUrl = GetConfiguration('achievements.images.url'); + + return imageUrl.replace('%image%', `achicon_${ getSelectedCategory.code }`); + }, [ getSelectedCategory ]); + const setAchievementSeen = useCallback((code: string, achievementId: number) => { const newCategories = [ ...achievementCategories ]; @@ -207,38 +219,27 @@ export const AchievementsView: FC = props => setIsVisible(false) } /> { getSelectedCategory && - + setSelectedCategoryCode(null) } className="nitro-achievements-back-arrow" /> - - - { LocalizeText(`quests.${ getSelectedCategory.code }.name`) } - - - { LocalizeText('achievements.details.categoryprogress', [ 'progress', 'limit' ], [ getSelectedCategory.getProgress().toString(), getSelectedCategory.getMaxProgress().toString() ]) } - - + + { LocalizeText(`quests.${ getSelectedCategory.code }.name`) } + { LocalizeText('achievements.details.categoryprogress', [ 'progress', 'limit' ], [ getSelectedCategory.getProgress().toString(), getSelectedCategory.getMaxProgress().toString() ]) } + } - - - { !getSelectedCategory && - <> - - - - - { LocalizeText('achievements.categories.totalprogress', [ 'progress', 'limit' ], [ getProgress.toString(), getMaxProgress.toString() ]) } - - - - { LocalizeText('achievements.categories.score', [ 'score' ], [ achievementScore.toString() ]) } - - - } - { getSelectedCategory && - } - - + { !getSelectedCategory && + <> + + + + { LocalizeText('achievements.categories.totalprogress', [ 'progress', 'limit' ], [ getProgress.toString(), getMaxProgress.toString() ]) } + + + { LocalizeText('achievements.categories.score', [ 'score' ], [ achievementScore.toString() ]) } + + } + { getSelectedCategory && + } ); diff --git a/src/views/achievements/common/AchievementCategory.ts b/src/components/achievements/common/AchievementCategory.ts similarity index 100% rename from src/views/achievements/common/AchievementCategory.ts rename to src/components/achievements/common/AchievementCategory.ts diff --git a/src/views/achievements/common/AchievementUtilities.ts b/src/components/achievements/common/AchievementUtilities.ts similarity index 100% rename from src/views/achievements/common/AchievementUtilities.ts rename to src/components/achievements/common/AchievementUtilities.ts diff --git a/src/views/achievements/common/GetAchievementLevel.ts b/src/components/achievements/common/GetAchievementLevel.ts similarity index 100% rename from src/views/achievements/common/GetAchievementLevel.ts rename to src/components/achievements/common/GetAchievementLevel.ts diff --git a/src/views/achievements/common/GetScaledProgressPercent.ts b/src/components/achievements/common/GetScaledProgressPercent.ts similarity index 100% rename from src/views/achievements/common/GetScaledProgressPercent.ts rename to src/components/achievements/common/GetScaledProgressPercent.ts diff --git a/src/views/achievements/views/achievement-badge/AchievementBadgeView.tsx b/src/components/achievements/views/achievement-badge/AchievementBadgeView.tsx similarity index 58% rename from src/views/achievements/views/achievement-badge/AchievementBadgeView.tsx rename to src/components/achievements/views/achievement-badge/AchievementBadgeView.tsx index 578f86dc..26b266ee 100644 --- a/src/views/achievements/views/achievement-badge/AchievementBadgeView.tsx +++ b/src/components/achievements/views/achievement-badge/AchievementBadgeView.tsx @@ -1,7 +1,14 @@ +import { AchievementData } from '@nitrots/nitro-renderer'; import { FC } from 'react'; -import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; +import { BaseProps } from '../../../../common/Base'; +import { BadgeImageView } from '../../../../views/shared/badge-image/BadgeImageView'; import { AchievementUtilities } from '../../common/AchievementUtilities'; -import { AchievementBadgeViewProps } from './AchievementBadgeView.types'; + +export interface AchievementBadgeViewProps extends BaseProps +{ + achievement: AchievementData; + scale?: number; +} export const AchievementBadgeView: FC = props => { diff --git a/src/views/achievements/views/achievement-details/AchievementDetailsView.tsx b/src/components/achievements/views/achievement-details/AchievementDetailsView.tsx similarity index 61% rename from src/views/achievements/views/achievement-details/AchievementDetailsView.tsx rename to src/components/achievements/views/achievement-details/AchievementDetailsView.tsx index 5ab5d320..6d2de4a2 100644 --- a/src/views/achievements/views/achievement-details/AchievementDetailsView.tsx +++ b/src/components/achievements/views/achievement-details/AchievementDetailsView.tsx @@ -1,13 +1,22 @@ +import { AchievementData } from '@nitrots/nitro-renderer'; import { FC } from 'react'; import { LocalizeBadgeDescription, LocalizeBadgeName, LocalizeText } from '../../../../api'; +import { Base } from '../../../../common/Base'; +import { Column } from '../../../../common/Column'; +import { Flex } from '../../../../common/Flex'; +import { Text } from '../../../../common/Text'; import { NitroLayoutFlex, NitroLayoutFlexColumn } from '../../../../layout'; import { NitroLayoutBase } from '../../../../layout/base'; -import { CurrencyIcon } from '../../../shared/currency-icon/CurrencyIcon'; +import { CurrencyIcon } from '../../../../views/shared/currency-icon/CurrencyIcon'; import { AchievementUtilities } from '../../common/AchievementUtilities'; import { GetAchievementLevel } from '../../common/GetAchievementLevel'; import { GetScaledProgressPercent } from '../../common/GetScaledProgressPercent'; import { AchievementBadgeView } from '../achievement-badge/AchievementBadgeView'; -import { AchievementDetailsViewProps } from './AchievementDetailsView.types'; + +export interface AchievementDetailsViewProps +{ + achievement: AchievementData; +} export const AchievementDetailsView: FC = props => { @@ -19,22 +28,22 @@ export const AchievementDetailsView: FC = props => const scaledProgressPercent = GetScaledProgressPercent(achievement); return ( - - + + { LocalizeText('achievements.details.level', [ 'level', 'limit' ], [ achievementLevel.toString(), achievement.levelCount.toString() ]) } - - - - - + + + + + { LocalizeBadgeName(AchievementUtilities.getBadgeCode(achievement)) } - - + + { LocalizeBadgeDescription(AchievementUtilities.getBadgeCode(achievement)) } - - + + { ((achievement.levelRewardPoints > 0) || (achievement.scoreLimit > 0)) && { (achievement.levelRewardPoints > 0) && @@ -48,13 +57,12 @@ export const AchievementDetailsView: FC = props => } { (achievement.scoreLimit > 0) && - - - { LocalizeText('achievements.details.progress', [ 'progress', 'limit' ], [ (achievement.currentPoints + achievement.scoreAtStartOfLevel).toString(), (achievement.scoreLimit + achievement.scoreAtStartOfLevel).toString() ]) } - - } + + { LocalizeText('achievements.details.progress', [ 'progress', 'limit' ], [ (achievement.currentPoints + achievement.scoreAtStartOfLevel).toString(), (achievement.scoreLimit + achievement.scoreAtStartOfLevel).toString() ]) } + + } } - - + + ) } diff --git a/src/components/achievements/views/achievement-list/AchievementListItemView.tsx b/src/components/achievements/views/achievement-list/AchievementListItemView.tsx new file mode 100644 index 00000000..74975759 --- /dev/null +++ b/src/components/achievements/views/achievement-list/AchievementListItemView.tsx @@ -0,0 +1,23 @@ +import { AchievementData } from '@nitrots/nitro-renderer'; +import { FC } from 'react'; +import { LayoutGridItem, LayoutGridItemProps } from '../../../../common/layout/LayoutGridItem'; +import { AchievementBadgeView } from '../achievement-badge/AchievementBadgeView'; + +export interface AchievementListItemViewProps extends LayoutGridItemProps +{ + achievement: AchievementData; +} + +export const AchievementListItemView: FC = props => +{ + const { achievement = null, children = null, ...rest } = props; + + if(!achievement) return null; + + return ( + + + { children } + + ); +} diff --git a/src/components/achievements/views/achievement-list/AchievementListView.tsx b/src/components/achievements/views/achievement-list/AchievementListView.tsx new file mode 100644 index 00000000..030d79fd --- /dev/null +++ b/src/components/achievements/views/achievement-list/AchievementListView.tsx @@ -0,0 +1,26 @@ +import { AchievementData } from '@nitrots/nitro-renderer'; +import { Dispatch, FC, SetStateAction } from 'react'; +import { Grid, GridProps } from '../../../../common/Grid'; +import { AchievementListItemView } from './AchievementListItemView'; + +export interface AchievementListViewProps extends GridProps +{ + achievements: AchievementData[]; + selectedAchievementId: number; + setSelectedAchievementId: Dispatch>; +} + +export const AchievementListView: FC = props => +{ + const { achievements = null, selectedAchievementId = 0, setSelectedAchievementId = null, children = null, ...rest } = props; + + return ( + + { achievements && (achievements.length > 0) && achievements.map((achievement, index) => + { + return setSelectedAchievementId(achievement.achievementId) } />; + }) } + { children } + + ); +} diff --git a/src/components/achievements/views/category-list/AchievementsCategoryListItemView.tsx b/src/components/achievements/views/category-list/AchievementsCategoryListItemView.tsx new file mode 100644 index 00000000..f9ccfcef --- /dev/null +++ b/src/components/achievements/views/category-list/AchievementsCategoryListItemView.tsx @@ -0,0 +1,44 @@ +import { FC, useCallback, useMemo } from 'react'; +import { GetConfiguration, LocalizeText } from '../../../../api'; +import { LayoutGridItem, LayoutGridItemProps } from '../../../../common/layout/LayoutGridItem'; +import { LayoutImage } from '../../../../common/layout/LayoutImage'; +import { Text } from '../../../../common/Text'; +import { AchievementCategory } from '../../common/AchievementCategory'; + +export interface AchievementCategoryListItemViewProps extends LayoutGridItemProps +{ + category: AchievementCategory; +} + +export const AchievementsCategoryListItemView: FC = props => +{ + const { category = null, ...rest } = props; + + const progress = category.getProgress(); + const maxProgress = category.getMaxProgress(); + + const getCategoryImage = useMemo(() => + { + const imageUrl = GetConfiguration('achievements.images.url'); + + return imageUrl.replace('%image%', `achcategory_${ category.code }_${ ((progress > 0) ? 'active' : 'inactive') }`); + }, [ category, progress ]); + + const getTotalUnseen = useCallback(() => + { + let unseen = 0; + + for(const achievement of category.achievements) unseen += achievement.unseen; + + return unseen; + }, [ category ]); + + return ( + + { LocalizeText(`quests.${ category.code }.name`) } + + { progress } / { maxProgress } + + + ); +} diff --git a/src/components/achievements/views/category-list/AchievementsCategoryListView.tsx b/src/components/achievements/views/category-list/AchievementsCategoryListView.tsx new file mode 100644 index 00000000..e5d47325 --- /dev/null +++ b/src/components/achievements/views/category-list/AchievementsCategoryListView.tsx @@ -0,0 +1,23 @@ +import { Dispatch, FC, SetStateAction } from 'react'; +import { Grid, GridProps } from '../../../../common/Grid'; +import { AchievementCategory } from '../../common/AchievementCategory'; +import { AchievementsCategoryListItemView } from './AchievementsCategoryListItemView'; + +export interface AchievementsCategoryListViewProps extends GridProps +{ + categories: AchievementCategory[]; + selectedCategoryCode: string; + setSelectedCategoryCode: Dispatch>; +} + +export const AchievementsCategoryListView: FC = props => +{ + const { categories = null, selectedCategoryCode = null, setSelectedCategoryCode = null, children = null, ...rest } = props; + + return ( + + { categories && (categories.length > 0) && categories.map((category, index) => setSelectedCategoryCode(category.code) } /> ) } + { children } + + ); +}; diff --git a/src/views/achievements/views/category/AchievementCategoryView.tsx b/src/components/achievements/views/category/AchievementCategoryView.tsx similarity index 82% rename from src/views/achievements/views/category/AchievementCategoryView.tsx rename to src/components/achievements/views/category/AchievementCategoryView.tsx index 4041bf21..5f535d2c 100644 --- a/src/views/achievements/views/category/AchievementCategoryView.tsx +++ b/src/components/achievements/views/category/AchievementCategoryView.tsx @@ -1,8 +1,14 @@ import { FC, useEffect, useMemo, useState } from 'react'; -import { NitroLayoutFlexColumn } from '../../../../layout'; +import { Column } from '../../../../common/Column'; +import { AchievementCategory } from '../../common/AchievementCategory'; import { AchievementDetailsView } from '../achievement-details/AchievementDetailsView'; import { AchievementListView } from '../achievement-list/AchievementListView'; -import { AchievementCategoryViewProps } from './AchievementCategoryView.types'; + +export class AchievementCategoryViewProps +{ + category: AchievementCategory; + setAchievementSeen: (code: string, achievementId: number) => void; +} export const AchievementCategoryView: FC = props => { @@ -42,10 +48,10 @@ export const AchievementCategoryView: FC = props = if(!category) return null; return ( - + { getSelectedAchievement && } - + ); } diff --git a/src/components/avatar-editor/views/figure-set/AvatarEditorFigureSetItemView.tsx b/src/components/avatar-editor/views/figure-set/AvatarEditorFigureSetItemView.tsx index aced50e1..8a6d8432 100644 --- a/src/components/avatar-editor/views/figure-set/AvatarEditorFigureSetItemView.tsx +++ b/src/components/avatar-editor/views/figure-set/AvatarEditorFigureSetItemView.tsx @@ -1,11 +1,10 @@ import { FC, useCallback, useEffect, useState } from 'react'; -import { LayoutGridItem } from '../../../../common/layout/LayoutGridItem'; -import { NitroCardGridItemViewProps } from '../../../../layout'; +import { LayoutGridItem, LayoutGridItemProps } from '../../../../common/layout/LayoutGridItem'; import { CurrencyIcon } from '../../../../views/shared/currency-icon/CurrencyIcon'; import { AvatarEditorGridPartItem } from '../../common/AvatarEditorGridPartItem'; import { AvatarEditorIcon } from '../AvatarEditorIcon'; -export interface AvatarEditorFigureSetItemViewProps extends NitroCardGridItemViewProps +export interface AvatarEditorFigureSetItemViewProps extends LayoutGridItemProps { partItem: AvatarEditorGridPartItem; } diff --git a/src/components/index.scss b/src/components/index.scss index 81e4c379..1ae5c142 100644 --- a/src/components/index.scss +++ b/src/components/index.scss @@ -1,2 +1,3 @@ +@import './achievements/AchievementsView'; @import './avatar-editor/AvatarEditorView'; @import './inventory/InventoryView'; diff --git a/src/components/inventory/views/pet/InventoryPetItemView.tsx b/src/components/inventory/views/pet/InventoryPetItemView.tsx index 5bcd7b06..446a4ac7 100644 --- a/src/components/inventory/views/pet/InventoryPetItemView.tsx +++ b/src/components/inventory/views/pet/InventoryPetItemView.tsx @@ -51,7 +51,7 @@ export const InventoryPetItemView: FC = props => return ( - + ); } diff --git a/src/views/Styles.scss b/src/views/Styles.scss index 6f9feb96..708fceb6 100644 --- a/src/views/Styles.scss +++ b/src/views/Styles.scss @@ -15,7 +15,6 @@ @import "./toolbar/ToolbarView"; @import "./wired/WiredView"; @import "./mod-tools/ModToolsView"; -@import "./achievements/AchievementsView"; @import "./user-settings/UserSettingsView"; @import "./user-profile/UserProfileVew"; @import "./chat-history/ChatHistoryView"; diff --git a/src/views/achievements/AchievementsView.types.ts b/src/views/achievements/AchievementsView.types.ts deleted file mode 100644 index 821d5c20..00000000 --- a/src/views/achievements/AchievementsView.types.ts +++ /dev/null @@ -1,2 +0,0 @@ -export class AchievementsViewProps -{} diff --git a/src/views/achievements/views/achievement-badge/AchievementBadgeView.types.ts b/src/views/achievements/views/achievement-badge/AchievementBadgeView.types.ts deleted file mode 100644 index c89706ac..00000000 --- a/src/views/achievements/views/achievement-badge/AchievementBadgeView.types.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { AchievementData } from '@nitrots/nitro-renderer'; -import { NitroLayoutBaseProps } from '../../../../layout/base'; - -export interface AchievementBadgeViewProps extends NitroLayoutBaseProps -{ - achievement: AchievementData; - scale?: number; -} diff --git a/src/views/achievements/views/achievement-details/AchievementDetailsView.types.ts b/src/views/achievements/views/achievement-details/AchievementDetailsView.types.ts deleted file mode 100644 index 098f0867..00000000 --- a/src/views/achievements/views/achievement-details/AchievementDetailsView.types.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { AchievementData } from '@nitrots/nitro-renderer'; - -export interface AchievementDetailsViewProps -{ - achievement: AchievementData; -} diff --git a/src/views/achievements/views/achievement-list-item/AchievementListItemView.tsx b/src/views/achievements/views/achievement-list-item/AchievementListItemView.tsx deleted file mode 100644 index 806c1ed5..00000000 --- a/src/views/achievements/views/achievement-list-item/AchievementListItemView.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { FC } from 'react'; -import { NitroCardGridItemView } from '../../../../layout'; -import { AchievementBadgeView } from '../achievement-badge/AchievementBadgeView'; -import { AchievementListItemViewProps } from './AchievementListItemView.types'; - -export const AchievementListItemView: FC = props => -{ - const { achievement = null, children = null, ...rest } = props; - - if(!achievement) return null; - - return ( - - - - ); -} diff --git a/src/views/achievements/views/achievement-list-item/AchievementListItemView.types.ts b/src/views/achievements/views/achievement-list-item/AchievementListItemView.types.ts deleted file mode 100644 index 78072e6d..00000000 --- a/src/views/achievements/views/achievement-list-item/AchievementListItemView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { AchievementData } from '@nitrots/nitro-renderer'; -import { NitroCardGridItemViewProps } from '../../../../layout'; - -export interface AchievementListItemViewProps extends NitroCardGridItemViewProps -{ - achievement: AchievementData; -} diff --git a/src/views/achievements/views/achievement-list/AchievementListView.tsx b/src/views/achievements/views/achievement-list/AchievementListView.tsx deleted file mode 100644 index 4475e263..00000000 --- a/src/views/achievements/views/achievement-list/AchievementListView.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { FC } from 'react'; -import { NitroCardGridView } from '../../../../layout'; -import { AchievementListItemView } from '../achievement-list-item/AchievementListItemView'; -import { AchievementListViewProps } from './AchievementListView.types'; - -export const AchievementListView: FC = props => -{ - const { achievements = null, selectedAchievementId = 0, setSelectedAchievementId = null, ...rest } = props; - - return ( - - { achievements && (achievements.length > 0) && achievements.map((achievement, index) => - { - return setSelectedAchievementId(achievement.achievementId) } />; - }) } - - ); -} diff --git a/src/views/achievements/views/achievement-list/AchievementListView.types.ts b/src/views/achievements/views/achievement-list/AchievementListView.types.ts deleted file mode 100644 index 9a6013f9..00000000 --- a/src/views/achievements/views/achievement-list/AchievementListView.types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { AchievementData } from '@nitrots/nitro-renderer'; -import { Dispatch, SetStateAction } from 'react'; -import { NitroCardGridViewProps } from '../../../../layout'; - -export interface AchievementListViewProps extends NitroCardGridViewProps -{ - achievements: AchievementData[]; - selectedAchievementId: number; - setSelectedAchievementId: Dispatch>; -} diff --git a/src/views/achievements/views/category-list-item/AchievementCategoryListItemView.types.ts b/src/views/achievements/views/category-list-item/AchievementCategoryListItemView.types.ts deleted file mode 100644 index 3f493995..00000000 --- a/src/views/achievements/views/category-list-item/AchievementCategoryListItemView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { NitroCardGridItemViewProps } from '../../../../layout'; -import { AchievementCategory } from '../../common/AchievementCategory'; - -export interface AchievementCategoryListItemViewProps extends NitroCardGridItemViewProps -{ - category: AchievementCategory; -} diff --git a/src/views/achievements/views/category-list-item/AchievementsCategoryListItemView.tsx b/src/views/achievements/views/category-list-item/AchievementsCategoryListItemView.tsx deleted file mode 100644 index 30a82dc9..00000000 --- a/src/views/achievements/views/category-list-item/AchievementsCategoryListItemView.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { FC, useCallback, useMemo } from 'react'; -import { GetConfiguration } from '../../../../api'; -import { NitroCardGridItemView } from '../../../../layout'; -import { NitroLayoutBase } from '../../../../layout/base'; -import { AchievementCategoryListItemViewProps } from './AchievementCategoryListItemView.types'; - -export const AchievementsCategoryListItemView: FC = props => -{ - const { category = null, ...rest } = props; - - const progress = category.getProgress(); - const maxProgress = category.getMaxProgress(); - - const getCategoryImage = useMemo(() => - { - const imageUrl = GetConfiguration('achievements.images.url'); - - return imageUrl.replace('%image%', `achcategory_${ category.code }_${ ((progress > 0) ? 'active' : 'inactive') }`); - }, [ category, progress ]); - - const getTotalUnseen = useCallback(() => - { - let unseen = 0; - - for(const achievement of category.achievements) unseen += achievement.unseen; - - return unseen; - }, [ category ]); - - return ( - - { category.code } - - { progress } / { maxProgress } - - - ); -} diff --git a/src/views/achievements/views/category-list/AchievementsCategoryListView.tsx b/src/views/achievements/views/category-list/AchievementsCategoryListView.tsx deleted file mode 100644 index 70cbc44d..00000000 --- a/src/views/achievements/views/category-list/AchievementsCategoryListView.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { FC } from 'react'; -import { NitroCardGridView } from '../../../../layout'; -import { AchievementsCategoryListItemView } from '../category-list-item/AchievementsCategoryListItemView'; -import { AchievementsCategoryListViewProps } from './AchievementsCategoryListView.types'; - -export const AchievementsCategoryListView: FC = props => -{ - const { categories = null, selectedCategoryCode = null, setSelectedCategoryCode = null, ...rest } = props; - - return ( - - { categories && (categories.length > 0) && categories.map((category, index) => - { - return setSelectedCategoryCode(category.code) } />; - }) } - - ); -}; diff --git a/src/views/achievements/views/category-list/AchievementsCategoryListView.types.ts b/src/views/achievements/views/category-list/AchievementsCategoryListView.types.ts deleted file mode 100644 index ef15c583..00000000 --- a/src/views/achievements/views/category-list/AchievementsCategoryListView.types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Dispatch, SetStateAction } from 'react'; -import { NitroCardGridViewProps } from '../../../../layout'; -import { AchievementCategory } from '../../common/AchievementCategory'; - -export interface AchievementsCategoryListViewProps extends NitroCardGridViewProps -{ - categories: AchievementCategory[]; - selectedCategoryCode: string; - setSelectedCategoryCode: Dispatch>; -} diff --git a/src/views/achievements/views/category/AchievementCategoryView.types.ts b/src/views/achievements/views/category/AchievementCategoryView.types.ts deleted file mode 100644 index 0e819a34..00000000 --- a/src/views/achievements/views/category/AchievementCategoryView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { AchievementCategory } from '../../common/AchievementCategory'; - -export class AchievementCategoryViewProps -{ - category: AchievementCategory; - setAchievementSeen: (code: string, achievementId: number) => void; -} diff --git a/src/views/main/MainView.tsx b/src/views/main/MainView.tsx index 2ecaab7e..5256aa51 100644 --- a/src/views/main/MainView.tsx +++ b/src/views/main/MainView.tsx @@ -1,11 +1,11 @@ import { HabboWebTools, RoomSessionEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import { AddEventLinkTracker, GetCommunication, RemoveLinkEventTracker } from '../../api'; +import { AchievementsView } from '../../components/achievements/AchievementsView'; import { AvatarEditorView } from '../../components/avatar-editor/AvatarEditorView'; import { InventoryView } from '../../components/inventory/InventoryView'; import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; import { TransitionAnimation, TransitionAnimationTypes } from '../../layout'; -import { AchievementsView } from '../achievements/AchievementsView'; import { CameraWidgetView } from '../camera/CameraWidgetView'; import { CampaignView } from '../campaign/CampaignView'; import { CatalogView } from '../catalog/CatalogView';