From 736fe30117a164379e2b90867d6308d7a856bb50 Mon Sep 17 00:00:00 2001 From: ethanJcoding Date: Thu, 11 Jul 2024 19:22:14 +0900 Subject: [PATCH 01/21] =?UTF-8?q?=F0=9F=90=9B=20=EC=8B=9C=EC=A6=8C3=20?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=96=B4=EB=B9=8C?= =?UTF-8?q?=EB=A6=AC=ED=8B=B0=20=EC=8A=A4=ED=86=A4=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=9D=B4=EC=8A=88=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CharacterDetail/Equipment.tsx | 53 ++++++++++++------- src/types/Equipments/equipments.ts | 45 ++++++++++++++++ 2 files changed, 79 insertions(+), 19 deletions(-) diff --git a/src/components/scheduleDetail/CharacterDetail/Equipment.tsx b/src/components/scheduleDetail/CharacterDetail/Equipment.tsx index d7b634a..e141194 100644 --- a/src/components/scheduleDetail/CharacterDetail/Equipment.tsx +++ b/src/components/scheduleDetail/CharacterDetail/Equipment.tsx @@ -1,4 +1,4 @@ -import { EquipmentInterface } from '@/types/Equipments/equipments' +import { EquipmentInterface, ToolTipIndentStringGroup, ToolTipObject } from '@/types/Equipments/equipments' import { StoneObjectInterface } from '@/types/Equipments/equipments' import { getBraceletAbility } from '@/utils/getBraceletAbility' import { getElixir } from '@/utils/getElixir' @@ -200,25 +200,38 @@ const AccessoryDetails = ({ equipment }: { equipment: EquipmentInterface }) => { } const BraceletAndStoneDetails = ({ equipment }: { equipment: EquipmentInterface }) => { - const parsedObject = JSON.parse(equipment.Tooltip) - const abilityStone = parsedObject.Element_006.value.Element_000?.contentStr + const parsedObject: ToolTipObject = JSON.parse(equipment.Tooltip) - if (equipment.Type === '팔찌') { - const bracelet = getBraceletAbility(equipment) + function isIndentStringGroup(value: any): value is ToolTipIndentStringGroup { + return value && typeof value === 'object' && 'Element_000' in value + } + const getAbilityStone = (parsedObject: ToolTipObject) => { + for (const item of Object.values(parsedObject)) { + if (item.type === 'IndentStringGroup' && isIndentStringGroup(item.value)) { + if (item.value.Element_000.topStr.includes('무작위 각인 효과')) { + return item.value.Element_000.contentStr as StoneObjectInterface + } + } + } + return null + } + + const renderAbilityStone = () => { + const abilityStone = getAbilityStone(parsedObject) as StoneObjectInterface + + return + } + + const renderBracelet = () => { + const bracelet = getBraceletAbility(equipment) return ( -
- -
-
{equipment.Name}
-
- {bracelet?.map((el, idx) => ( -
- {el} -
- ))} +
+ {bracelet?.map((el, idx) => ( +
+ {el}
-
+ ))}
) } @@ -226,9 +239,11 @@ const BraceletAndStoneDetails = ({ equipment }: { equipment: EquipmentInterface return (
-
-
{equipment.Type}
- +
+
+ {equipment.Type === '팔찌' ? equipment.Name : equipment.Type} +
+ {equipment.Type === '팔찌' ? renderBracelet() : renderAbilityStone()}
) diff --git a/src/types/Equipments/equipments.ts b/src/types/Equipments/equipments.ts index d4ae90a..6b0db45 100644 --- a/src/types/Equipments/equipments.ts +++ b/src/types/Equipments/equipments.ts @@ -17,3 +17,48 @@ export interface StoneObjectInterface { Element_001: Element Element_002: Element } + +interface ToolTipElement { + type: string + value: string | ToolTipItemTitle | ToolTipItemPartBox | ToolTipIndentStringGroup | null +} + +export interface ToolTipIndentStringGroup { + Element_000: { + topStr: string + contentStr: StoneObjectInterface + } +} + +interface ToolTipItemTitle { + bEquip: number + leftStr0: string + leftStr2: string + qualityValue: number + rightStr0: string + slotData: { + advBookIcon: number + battleItemTypeIcon: number + cardIcon: boolean + friendship: number + iconGrade: number + iconPath: string + imagePath: string + islandIcon: number + petBorder: number + rtString: string + seal: boolean + temporary: number + town: number + trash: number + } +} + +interface ToolTipItemPartBox { + Element_000: string + Element_001: string +} + +export interface ToolTipObject { + [key: string]: ToolTipElement +} From 3512b2dbd0728c45b2f777a88d5ea022f95d0bea Mon Sep 17 00:00:00 2001 From: ethanJcoding Date: Fri, 12 Jul 2024 17:10:30 +0900 Subject: [PATCH 02/21] =?UTF-8?q?=F0=9F=8E=A8=20=EB=8C=80=EC=89=AC?= =?UTF-8?q?=EB=B3=B4=EB=93=9C=20=EB=A7=81=ED=81=AC=20=EC=A0=88=EB=8C=80=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/landing/header/Gnb.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/landing/header/Gnb.tsx b/src/components/landing/header/Gnb.tsx index 80323b7..2952f29 100644 --- a/src/components/landing/header/Gnb.tsx +++ b/src/components/landing/header/Gnb.tsx @@ -10,7 +10,7 @@ export default async function Gnb() { if (session) { const { channels } = (await getUserData(session.user.id)) as User - dashboardUrl = `${channels[0]}/dashboard` + dashboardUrl = `/${channels[0]}/dashboard` } return ( From d5ad9bda9160aff2591728f2321a54ebaa5ec53c Mon Sep 17 00:00:00 2001 From: ethanJcoding Date: Sat, 13 Jul 2024 20:12:21 +0900 Subject: [PATCH 03/21] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Armory=20=EC=9D=B8?= =?UTF-8?q?=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EB=A6=AC=ED=8E=99?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types/Equipments/armory.ts | 85 ++++++++++++++++++++++++++++++ src/types/Equipments/cards.ts | 25 --------- src/types/Equipments/engravings.ts | 17 ------ src/types/Equipments/equipments.ts | 8 --- src/types/Equipments/gems.ts | 71 ------------------------- src/types/characterList.ts | 13 ----- src/types/gameProfile.ts | 32 ----------- 7 files changed, 85 insertions(+), 166 deletions(-) create mode 100644 src/types/Equipments/armory.ts delete mode 100644 src/types/Equipments/cards.ts delete mode 100644 src/types/Equipments/engravings.ts delete mode 100644 src/types/Equipments/gems.ts delete mode 100644 src/types/characterList.ts delete mode 100644 src/types/gameProfile.ts diff --git a/src/types/Equipments/armory.ts b/src/types/Equipments/armory.ts new file mode 100644 index 0000000..c4d6700 --- /dev/null +++ b/src/types/Equipments/armory.ts @@ -0,0 +1,85 @@ +export interface ArmoryAvatarsInterface { + Grade: string + Icon: string + isInner: boolean + isSet: boolean + Name: string + Tooltip: string + Type: string +} + +export interface ArmoryCardsInterface { + Cards: { + AwakeCount: number + AwakeTotal: number + Grade: string + Icon: string + Name: string + Slot: number + Tooltip: string + }[] + Effects: { CardSlots: number[]; Items: { Name: string; Description: string }[] }[] +} + +export interface ArmoryEngravingInterface { + ArkPassiveEffects: null + Effects: { Desciption: string; Icon: string; Name: string }[] + Engravings: { Icon: string; name: string; Slot: number; Tooltip: string }[] +} + +export interface ArmoryEquipmentInterface { + Type: string + Name: string + Icon: string + Tooltip: string + Grade: string +} + +export interface ArmoryGemInterface { + Effects: { + Description: string + Skills: { Description: string[]; GemSlot: number; Icon: string; Name: string; Option: string; Tooltip: string }[] + } + Gems: { Grade: string; Icon: string; Level: number; Name: string; Slot: number; Tooltip: string }[] +} + +export interface ArmoryProfileInterface { + ArkPassive: { iseArkPassive: false; Points: { Name: string; Tooltip: string; value: number }[] } + CharacterClassName: string + CharacterImage: string + CharacterLevel: number + CharacterName: string + ExpeditionLevel: number + GuildMemberGrade: string + GuildName: string + ItemAvgLevel: string + ItemMaxLevel: string + PvpGradeName: string + ServerName: string + Stats: { Tooltip: string[]; Type: string; Value: string }[] + Tendencies: { Type: string; Points: number; MaxPoint: number }[] + Title: string + TotalSkillPoint: number + TownLevel: number + TownName: string + UsingSkillPoint: number +} + +export interface ArmorySkillsInterface { + Icon: string + IsAwakening: boolean + Level: number + Name: string + Rune: { Grade: string; Icon: string; Name: string; Tooltip: string } | null + Tooltip: string + Tripods: { + Icon: string + IsSelected: boolean + Level: number + Name: string + Slot: number + Tier: number + Tooltip: string + }[] + Type: string +} diff --git a/src/types/Equipments/cards.ts b/src/types/Equipments/cards.ts deleted file mode 100644 index 64f2d85..0000000 --- a/src/types/Equipments/cards.ts +++ /dev/null @@ -1,25 +0,0 @@ -interface Card { - Slot: number - Name: string - Icon: string - AwakeCount: number - AwakeTotal: number - Grade: string - Tooltip: string -} - -interface EffectItem { - Name: string - Description: string -} - -interface Effect { - Index: number - CardSlots: number[] - Items: EffectItem[] -} - -export interface CardsInterface { - Cards: Card[] - Effects: Effect[] -} diff --git a/src/types/Equipments/engravings.ts b/src/types/Equipments/engravings.ts deleted file mode 100644 index 6741ddb..0000000 --- a/src/types/Equipments/engravings.ts +++ /dev/null @@ -1,17 +0,0 @@ -interface Engraving { - Slot: number - Name: string - Icon: string - Tooltip: string -} - -export interface EngravingEffect { - Icon: string - Name: string - Description: string -} - -export interface EngravingInterface { - Engravings: Engraving[] - Effects: EngravingEffect[] -} diff --git a/src/types/Equipments/equipments.ts b/src/types/Equipments/equipments.ts index 6b0db45..f17b578 100644 --- a/src/types/Equipments/equipments.ts +++ b/src/types/Equipments/equipments.ts @@ -1,11 +1,3 @@ -export interface EquipmentInterface { - Type: string - Name: string - Icon: string - Tooltip: string - Grade: string -} - interface Element { bPoint: number contentStr: string diff --git a/src/types/Equipments/gems.ts b/src/types/Equipments/gems.ts deleted file mode 100644 index 1ab98d1..0000000 --- a/src/types/Equipments/gems.ts +++ /dev/null @@ -1,71 +0,0 @@ -interface Gem { - Slot: number - Name: string - Icon: string - Level: number - Grade: string - Tooltip: string - // Tooltip: { - // Element_000: { - // type: string - // value: string - // } - // Element_001: { - // type: string - // value: { - // bEquip: number - // leftStr0: string - // leftStr2: string - // qualityValue: number - // rightStr0: string - // slotData: { - // advBookIcon: number - // battleItemTypeIcon: number - // cardIcon: boolean - // friendship: number - // iconGrade: number - // iconPath: string - // imagePath: string - // islandIcon: number - // petBorder: number - // rtString: string - // seal: boolean - // temporary: number - // town: number - // trash: number - // } - // } - // } - // Element_002: { - // type: string - // value: string - // } - // Element_003: { - // type: string - // value: string - // } - // Element_004: { - // type: string - // value: string - // } - // Element_005: { - // type: string - // value: { - // Element_000: string - // Element_001: string - // } - // } - // Element_006: { - // type: string - // value: string - // } - // Element_007: { - // type: string - // value: string - // } - // } -} - -export interface GemsInterface { - Gems: Gem[] -} diff --git a/src/types/characterList.ts b/src/types/characterList.ts deleted file mode 100644 index 2a87b9b..0000000 --- a/src/types/characterList.ts +++ /dev/null @@ -1,13 +0,0 @@ -export interface ChaListInterface { - CharacterClassName: string - CharacterLevel: number - CharacterName: string - ItemAvgLevel: string - ItemMaxLevel: string - ServerName: string - CharacterImage: string - ExpeditionLevel: number - TownName: string - GuildName: string - Title: string -} diff --git a/src/types/gameProfile.ts b/src/types/gameProfile.ts deleted file mode 100644 index 26cfabc..0000000 --- a/src/types/gameProfile.ts +++ /dev/null @@ -1,32 +0,0 @@ -interface Stat { - Type: string - Value: string - Tooltip: string[] -} - -interface Tendency { - Type: string - Point: number - MaxPoint: number -} - -export interface ProfileInterface { - CharacterImage: string - ExpeditionLevel: number - PvpGradeName: string - TownLevel: number - TownName: string - Title: string - GuildMemberGrade: string - GuildName: string - UsingSkillPoint: number - TotalSkillPoint: number - Stats: Stat[] - Tendencies: Tendency[] - ServerName: string - CharacterName: string - CharacterLevel: number - CharacterClassName: string - ItemAvgLevel: string - ItemMaxLevel: string -} From a4b107dd7c5ef2d5b7818a64396a8132acfa0047 Mon Sep 17 00:00:00 2001 From: ethanJcoding Date: Sat, 13 Jul 2024 20:19:47 +0900 Subject: [PATCH 04/21] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=EC=9D=B8=ED=84=B0?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EB=A6=AC=ED=8E=99=ED=86=A0?= =?UTF-8?q?=EB=A7=81=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CharacterDetail/ArmoryTab.tsx | 17 ++++++++------ .../scheduleDetail/CharacterDetail/Card.tsx | 4 ++-- .../CharacterDetail/CardGemEngSummary.tsx | 17 ++++++-------- .../CharacterDetail/CharacterSummary.tsx | 22 ++++++++++--------- .../CharacterDetail/Engraving.tsx | 4 ++-- .../CharacterDetail/Equipment.tsx | 11 +++++----- .../CharacterDetail/EquipmentSummary.tsx | 4 ++-- .../scheduleDetail/CharacterDetail/Gem.tsx | 4 ++-- .../CharacterDetail/ProfileSummary.tsx | 4 ++-- .../scheduleDetail/TeamAllocator/Popover.tsx | 6 ++--- src/hooks/useCharacterList.ts | 4 ++-- 11 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/components/scheduleDetail/CharacterDetail/ArmoryTab.tsx b/src/components/scheduleDetail/CharacterDetail/ArmoryTab.tsx index 297443a..995da5e 100644 --- a/src/components/scheduleDetail/CharacterDetail/ArmoryTab.tsx +++ b/src/components/scheduleDetail/CharacterDetail/ArmoryTab.tsx @@ -1,17 +1,20 @@ import { useState } from 'react' -import { CardsInterface } from '@/types/Equipments/cards' -import { EquipmentInterface } from '@/types/Equipments/equipments' -import { GemsInterface } from '@/types/Equipments/gems' import Card from './Card' import Gem from './Gem' import Equipment from './Equipment' import Engraving from './Engraving' +import { + ArmoryEquipmentInterface, + ArmoryCardsInterface, + ArmoryGemInterface, + ArmoryEngravingInterface +} from '@/types/Equipments/armory' interface Ownprops { - ArmoryEquipment: EquipmentInterface[] - ArmoryCard: CardsInterface - ArmoryGem: GemsInterface - ArmoryEngraving: any + ArmoryEquipment: ArmoryEquipmentInterface[] + ArmoryCard: ArmoryCardsInterface + ArmoryGem: ArmoryGemInterface + ArmoryEngraving: ArmoryEngravingInterface } export default function ArmoryTab({ ArmoryEquipment, ArmoryCard, ArmoryGem, ArmoryEngraving }: Ownprops) { diff --git a/src/components/scheduleDetail/CharacterDetail/Card.tsx b/src/components/scheduleDetail/CharacterDetail/Card.tsx index fd8c0fe..3534d00 100644 --- a/src/components/scheduleDetail/CharacterDetail/Card.tsx +++ b/src/components/scheduleDetail/CharacterDetail/Card.tsx @@ -1,8 +1,8 @@ +import { ArmoryCardsInterface } from '@/types/Equipments/armory' import Image from 'next/image' -import { CardsInterface } from '@/types/Equipments/cards' interface Ownprops { - ArmoryCard: CardsInterface + ArmoryCard: ArmoryCardsInterface } export default function Card({ ArmoryCard }: Ownprops) { diff --git a/src/components/scheduleDetail/CharacterDetail/CardGemEngSummary.tsx b/src/components/scheduleDetail/CharacterDetail/CardGemEngSummary.tsx index cdd2346..5f60d37 100644 --- a/src/components/scheduleDetail/CharacterDetail/CardGemEngSummary.tsx +++ b/src/components/scheduleDetail/CharacterDetail/CardGemEngSummary.tsx @@ -1,14 +1,12 @@ -import { CardsInterface } from '@/types/Equipments/cards' -import { EngravingEffect, EngravingInterface } from '@/types/Equipments/engravings' -import { GemsInterface } from '@/types/Equipments/gems' +import { ArmoryCardsInterface, ArmoryEngravingInterface, ArmoryGemInterface } from '@/types/Equipments/armory' interface Ownprops { - ArmoryCard: CardsInterface - ArmoryEngraving: EngravingInterface - ArmoryGem: GemsInterface + ArmoryCard: ArmoryCardsInterface + ArmoryEngraving: ArmoryEngravingInterface + ArmoryGem: ArmoryGemInterface } -const getGemAvgLevel = (ArmoryGem: GemsInterface) => { +const getGemAvgLevel = (ArmoryGem: ArmoryGemInterface) => { let sum = 0 if (ArmoryGem) { @@ -20,7 +18,7 @@ const getGemAvgLevel = (ArmoryGem: GemsInterface) => { } else return '보석이 없어요' } -const getEngraving = (Effects: EngravingEffect[]) => { +const getEngraving = (Effects: ArmoryEngravingInterface['Effects']) => { const formattedEffects: { name: string; level: string; icon: string }[] = [] // 주어진 배열을 순회하며 각 객체의 이름과 레벨을 추출하여 객체화 @@ -37,7 +35,6 @@ const getEngraving = (Effects: EngravingEffect[]) => { export default function CardGemEngSummary({ ArmoryCard, ArmoryGem, ArmoryEngraving }: Ownprops) { let cardEffect = ArmoryCard.Effects[0].Items[ArmoryCard.Effects[0].Items.length - 1].Name - const { Effects } = ArmoryEngraving switch (cardEffect) { case '세상을 구하는 빛 6세트 (18각성합계)': @@ -78,7 +75,7 @@ export default function CardGemEngSummary({ ArmoryCard, ArmoryGem, ArmoryEngravi
각인
- {getEngraving(Effects).map((engrave, idx) => ( + {getEngraving(ArmoryEngraving.Effects).map((engrave, idx) => (
{engrave.level}
))}
diff --git a/src/components/scheduleDetail/CharacterDetail/CharacterSummary.tsx b/src/components/scheduleDetail/CharacterDetail/CharacterSummary.tsx index 167891f..1b68359 100644 --- a/src/components/scheduleDetail/CharacterDetail/CharacterSummary.tsx +++ b/src/components/scheduleDetail/CharacterDetail/CharacterSummary.tsx @@ -1,19 +1,21 @@ -import { EquipmentInterface } from '@/types/Equipments/equipments' -import { ProfileInterface } from '@/types/gameProfile' import Image from 'next/image' import EquipmentSummary from './EquipmentSummary' -import { CardsInterface } from '@/types/Equipments/cards' import CardGemEngSummary from './CardGemEngSummary' -import { GemsInterface } from '@/types/Equipments/gems' -import { EngravingInterface } from '@/types/Equipments/engravings' import ProfileSummary from './ProfileSummary' +import { + ArmoryCardsInterface, + ArmoryEngravingInterface, + ArmoryEquipmentInterface, + ArmoryGemInterface, + ArmoryProfileInterface +} from '@/types/Equipments/armory' interface Ownprops { - ArmoryProfile: ProfileInterface - ArmoryEquipment: EquipmentInterface[] - ArmoryCard: CardsInterface - ArmoryGem: GemsInterface - ArmoryEngraving: EngravingInterface + ArmoryProfile: ArmoryProfileInterface + ArmoryEquipment: ArmoryEquipmentInterface[] + ArmoryCard: ArmoryCardsInterface + ArmoryGem: ArmoryGemInterface + ArmoryEngraving: ArmoryEngravingInterface } export default function CharacterSummary({ diff --git a/src/components/scheduleDetail/CharacterDetail/Engraving.tsx b/src/components/scheduleDetail/CharacterDetail/Engraving.tsx index 121fe4f..6bd8d95 100644 --- a/src/components/scheduleDetail/CharacterDetail/Engraving.tsx +++ b/src/components/scheduleDetail/CharacterDetail/Engraving.tsx @@ -1,8 +1,8 @@ -import { EngravingInterface } from '@/types/Equipments/engravings' +import { ArmoryEngravingInterface } from '@/types/Equipments/armory' import Image from 'next/image' interface Ownprops { - ArmoryEngraving: EngravingInterface + ArmoryEngraving: ArmoryEngravingInterface } export default function Engraving({ ArmoryEngraving }: Ownprops) { diff --git a/src/components/scheduleDetail/CharacterDetail/Equipment.tsx b/src/components/scheduleDetail/CharacterDetail/Equipment.tsx index e141194..8c25a0e 100644 --- a/src/components/scheduleDetail/CharacterDetail/Equipment.tsx +++ b/src/components/scheduleDetail/CharacterDetail/Equipment.tsx @@ -1,12 +1,13 @@ -import { EquipmentInterface, ToolTipIndentStringGroup, ToolTipObject } from '@/types/Equipments/equipments' +import { ToolTipIndentStringGroup, ToolTipObject } from '@/types/Equipments/equipments' import { StoneObjectInterface } from '@/types/Equipments/equipments' import { getBraceletAbility } from '@/utils/getBraceletAbility' import { getElixir } from '@/utils/getElixir' import Image from 'next/image' import { getEquipmentAndAccessories } from '@/utils/getEquipmentAndAccessories' +import { ArmoryEquipmentInterface } from '@/types/Equipments/armory' interface Ownprops { - ArmoryEquipment: EquipmentInterface[] + ArmoryEquipment: ArmoryEquipmentInterface[] } interface UpgradeContent { type: string @@ -84,7 +85,7 @@ const extractEnhanceValue = (str: string) => { return match ? match[0] : null } -const EquipmentDetails = ({ equipment }: { equipment: EquipmentInterface }) => { +const EquipmentDetails = ({ equipment }: { equipment: ArmoryEquipmentInterface }) => { const parsedObject = JSON.parse(equipment.Tooltip) const quality = parsedObject.Element_001.value.qualityValue const upgradeContent: UpgradeContent = { @@ -166,7 +167,7 @@ const EquipmentDetails = ({ equipment }: { equipment: EquipmentInterface }) => { ) } -const AccessoryDetails = ({ equipment }: { equipment: EquipmentInterface }) => { +const AccessoryDetails = ({ equipment }: { equipment: ArmoryEquipmentInterface }) => { const parsedObject = JSON.parse(equipment.Tooltip) const quality = parsedObject.Element_001.value.qualityValue let accessoryStat = [parsedObject.Element_005.value.Element_001] @@ -199,7 +200,7 @@ const AccessoryDetails = ({ equipment }: { equipment: EquipmentInterface }) => { ) } -const BraceletAndStoneDetails = ({ equipment }: { equipment: EquipmentInterface }) => { +const BraceletAndStoneDetails = ({ equipment }: { equipment: ArmoryEquipmentInterface }) => { const parsedObject: ToolTipObject = JSON.parse(equipment.Tooltip) function isIndentStringGroup(value: any): value is ToolTipIndentStringGroup { diff --git a/src/components/scheduleDetail/CharacterDetail/EquipmentSummary.tsx b/src/components/scheduleDetail/CharacterDetail/EquipmentSummary.tsx index 04be3d3..3f6ac2c 100644 --- a/src/components/scheduleDetail/CharacterDetail/EquipmentSummary.tsx +++ b/src/components/scheduleDetail/CharacterDetail/EquipmentSummary.tsx @@ -1,11 +1,11 @@ -import { EquipmentInterface } from '@/types/Equipments/equipments' +import { ArmoryEquipmentInterface } from '@/types/Equipments/armory' import { getAccQualityAvg } from '@/utils/getAccQualityAvg' import { getAccStatSum } from '@/utils/getAccStatSum' import { getEquipmentAndAccessories } from '@/utils/getEquipmentAndAccessories' import { getSetOption } from '@/utils/getSetOption' interface Ownprops { - ArmoryEquipment: EquipmentInterface[] + ArmoryEquipment: ArmoryEquipmentInterface[] } export default function EquipmentSummary({ ArmoryEquipment }: Ownprops) { diff --git a/src/components/scheduleDetail/CharacterDetail/Gem.tsx b/src/components/scheduleDetail/CharacterDetail/Gem.tsx index 77ffa3d..02c4bbe 100644 --- a/src/components/scheduleDetail/CharacterDetail/Gem.tsx +++ b/src/components/scheduleDetail/CharacterDetail/Gem.tsx @@ -1,8 +1,8 @@ +import { ArmoryGemInterface } from '@/types/Equipments/armory' import Image from 'next/image' -import { GemsInterface } from '@/types/Equipments/gems' interface Ownprops { - ArmoryGem: GemsInterface + ArmoryGem: ArmoryGemInterface } export default function Gem({ ArmoryGem }: Ownprops) { diff --git a/src/components/scheduleDetail/CharacterDetail/ProfileSummary.tsx b/src/components/scheduleDetail/CharacterDetail/ProfileSummary.tsx index fe96534..ef1f083 100644 --- a/src/components/scheduleDetail/CharacterDetail/ProfileSummary.tsx +++ b/src/components/scheduleDetail/CharacterDetail/ProfileSummary.tsx @@ -1,7 +1,7 @@ -import { ProfileInterface } from '@/types/gameProfile' +import { ArmoryProfileInterface } from '@/types/Equipments/armory' interface Ownprops { - ArmoryProfile: ProfileInterface + ArmoryProfile: ArmoryProfileInterface } export default function ProfileSummary({ ArmoryProfile }: Ownprops) { diff --git a/src/components/scheduleDetail/TeamAllocator/Popover.tsx b/src/components/scheduleDetail/TeamAllocator/Popover.tsx index 2bae886..0dfab3b 100644 --- a/src/components/scheduleDetail/TeamAllocator/Popover.tsx +++ b/src/components/scheduleDetail/TeamAllocator/Popover.tsx @@ -1,4 +1,3 @@ -import { ChaListInterface } from '@/types/characterList' import { FaSort, FaCheck } from 'react-icons/fa' import { addUserToRaid, deleteUserFromRaid, editPartyCharacter } from '@/api/firebase' import { useState } from 'react' @@ -10,6 +9,7 @@ import useDropdonwStore from '@/stores/dropdownStore' import { useScheduleStore } from '@/stores/scheduleStore' import useCharacterStore from '@/stores/characterStore' import { useCharacterList } from '@/hooks/useCharacterList' +import { ArmoryProfileInterface } from '@/types/Equipments/armory' interface OwnProps { isPopoverOpen: boolean @@ -20,7 +20,7 @@ interface OwnProps { userData: Session | null } -function checkCharacterRaidEligibility(characterList: ChaListInterface[], raidName: string | undefined) { +function checkCharacterRaidEligibility(characterList: ArmoryProfileInterface[], raidName: string | undefined) { switch (raidName) { case '발탄 [노말]': return characterList.filter(char => parseFloat(char.ItemAvgLevel.replace(/,/g, '')) > 1415) @@ -154,7 +154,7 @@ export default function Popover({ {isDropdownOpen && (
{checkCharacterRaidEligibility(characterList, schedule?.raidName).map( - (character: ChaListInterface, idx: number) => ( + (character: ArmoryProfileInterface, idx: number) => ( +
+
    + {searches.map(search => ( +
  • + + +
  • + ))} +
+
+ ) +} + +export default RecentSearches diff --git a/src/components/search/Search.tsx b/src/components/search/Search.tsx new file mode 100644 index 0000000..fa6aa01 --- /dev/null +++ b/src/components/search/Search.tsx @@ -0,0 +1,19 @@ +'use client' + +import SearchInput from './SearchInput' +import SearchResult from './SearchResult' +import SearchSiblings from './SearchSiblings' + +export default function Search() { + return ( +
+
+ + +
+
+ +
+
+ ) +} diff --git a/src/components/search/SearchInput.tsx b/src/components/search/SearchInput.tsx new file mode 100644 index 0000000..b10d66b --- /dev/null +++ b/src/components/search/SearchInput.tsx @@ -0,0 +1,91 @@ +'use client' + +import { useRouter, useSearchParams } from 'next/navigation' +import { useState, useEffect } from 'react' +import { FaSearch } from 'react-icons/fa' +import RecentSearches from './RecentSearches' + +export default function SearchInput() { + const [input, setInput] = useState('') + const [recentSearches, setRecentSearches] = useState([]) + const router = useRouter() + const searchParams = useSearchParams() + + useEffect(() => { + // 컴포넌트 마운트 시 로컬 스토리지에서 최근 검색어 불러오기 + const storedSearches = localStorage.getItem('recentSearches') + if (storedSearches) { + setRecentSearches(JSON.parse(storedSearches)) + } + }, []) + + const saveRecentSearches = (searches: string[]) => { + localStorage.setItem('recentSearches', JSON.stringify(searches)) + setRecentSearches(searches) + } + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault() + + if (input.trim()) { + // 최근 검색어 업데이트 + let updatedSearches = [input.trim(), ...recentSearches.filter(s => s !== input.trim())] + + // 최근 검색어를 5개로 제한 + if (updatedSearches.length > 5) { + updatedSearches = updatedSearches.slice(0, 5) + } + + const newSearchParams = new URLSearchParams(searchParams.toString()) + newSearchParams.set('query', input.trim()) + router.push(`?${newSearchParams.toString()}`, { scroll: false }) + + saveRecentSearches(updatedSearches) + } + } + + const handleClearAll = () => { + localStorage.removeItem('recentSearches') + setRecentSearches([]) + } + + const handleRemoveSearch = (searchToRemove: string) => { + const updatedSearches = recentSearches.filter(search => search !== searchToRemove) + saveRecentSearches(updatedSearches) + } + + const handleSearchClick = (search: string) => { + setInput(search) + const newSearchParams = new URLSearchParams(searchParams.toString()) + newSearchParams.set('query', search) + router.push(`?${newSearchParams.toString()}`, { scroll: false }) + } + + return ( +
+
+ setInput(e.target.value)} + value={input} + type='text' + maxLength={12} + /> + +
+ + +
+ ) +} diff --git a/src/components/search/SearchResult.tsx b/src/components/search/SearchResult.tsx new file mode 100644 index 0000000..1d73ebc --- /dev/null +++ b/src/components/search/SearchResult.tsx @@ -0,0 +1,54 @@ +'use client' + +import { useSearchStore } from '@/stores/searchStore' +import CharacterSummary from '../scheduleDetail/CharacterDetail/CharacterSummary' +import ArmoryTab from '../scheduleDetail/CharacterDetail/ArmoryTab' +import { useSearchParams } from 'next/navigation' +import { useEffect } from 'react' +import { FaSpinner } from 'react-icons/fa' + +export default function SearchResult() { + const { character, error, isLoading, searchCharacter } = useSearchStore() + const searchParams = useSearchParams() + const characterName = searchParams.get('query') + + useEffect(() => { + if (characterName) { + searchCharacter(characterName.trim().replace(/\s+/g, '')) + } + }, [characterName]) + + if (isLoading) { + return ( +
+ +
+ ) + } + + if (error) { + return
오류가 발생했습니다: {error instanceof Error ? error.message : '알 수 없는 오류'}
+ } + + if (!character) { + return
검색 결과가 없습니다.
+ } + + return ( + <> + + + + ) +} diff --git a/src/components/search/SearchSiblings.tsx b/src/components/search/SearchSiblings.tsx new file mode 100644 index 0000000..35b5539 --- /dev/null +++ b/src/components/search/SearchSiblings.tsx @@ -0,0 +1,67 @@ +'use client' + +import { useSiblingsStore } from '@/stores/siblingsStore' +import { useSearchParams, useRouter } from 'next/navigation' +import { useEffect } from 'react' +import { FaSpinner } from 'react-icons/fa' + +export default function SearchSiblings() { + const searchParams = useSearchParams() + const router = useRouter() + const { siblings, isLoading, error, searchSiblings } = useSiblingsStore() + const characterName = searchParams.get('query') + + useEffect(() => { + if (characterName) { + searchSiblings(characterName.trim().replace(/\s+/g, '')) + } + }, [characterName]) + + if (isLoading) { + return ( +
+ +
+ ) + } + + if (error) { + return
오류가 발생했습니다: {error instanceof Error ? error.message : '알 수 없는 오류'}
+ } + + if (!siblings) { + return
검색 결과가 없습니다.
+ } + + const handleClick = (characterName: string) => { + const newSearchParams = new URLSearchParams(searchParams.toString()) + newSearchParams.set('query', characterName) + router.push(`?${newSearchParams.toString()}`, { scroll: false }) + } + + return ( +
+
+

+ {characterName}님의 원정대원 리스트 +

+
+
    + {siblings.map(character => ( +
  • + +
  • + ))} +
+
+ ) +} diff --git a/src/stores/searchStore.ts b/src/stores/searchStore.ts new file mode 100644 index 0000000..0e157b9 --- /dev/null +++ b/src/stores/searchStore.ts @@ -0,0 +1,49 @@ +import { create } from 'zustand' +import { searchCharacter } from '@/api/firebase/searchCharacter/searchCharacter' +import { + ArmoryAvatarsInterface, + ArmoryCardsInterface, + ArmoryEngravingInterface, + ArmoryEquipmentInterface, + ArmoryGemInterface, + ArmoryProfileInterface, + ArmorySkillsInterface +} from '@/types/Equipments/armory' + +interface CharacterData { + ArmoryAvatars: ArmoryAvatarsInterface[] + ArmoryCard: ArmoryCardsInterface + ArmoryEngraving: ArmoryEngravingInterface + ArmoryEquipment: ArmoryEquipmentInterface[] + ArmoryGem: ArmoryGemInterface + ArmoryProfile: ArmoryProfileInterface + ArmorySkills: ArmorySkillsInterface[] +} + +interface CharacterState { + character: CharacterData | null + isLoading: boolean + error: Error | null + searchCharacter: (character: string) => Promise +} + +export const useSearchStore = create(set => ({ + character: null, + isLoading: false, + error: null, + searchCharacter: async (character: string) => { + set({ isLoading: true, error: null }) + try { + const data = await searchCharacter(character) + + if (data) { + set({ character: data as CharacterData, isLoading: false }) + } else { + throw new Error('Character data not found') + } + } catch (error) { + console.error('Error in searchCharacter:', error) + set({ error: error instanceof Error ? error : new Error('An unknown error occurred'), isLoading: false }) + } + } +})) diff --git a/src/stores/siblingsStore.ts b/src/stores/siblingsStore.ts new file mode 100644 index 0000000..3a71fec --- /dev/null +++ b/src/stores/siblingsStore.ts @@ -0,0 +1,49 @@ +import { create } from 'zustand' +import { getCharacterList } from '@/api/lostark/getCharacterList' + +interface Siblings { + CharacterClassName: string + CharacterLevel: number + CharacterName: string + ItemAvgLevel: string + ItemMaxLevel: string + ServerName: string +} + +interface CharacterState { + siblings: Siblings[] | null + isLoading: boolean + error: Error | null + searchSiblings: (character: string) => Promise +} + +function sortByItemAvgLevel(characters: Siblings[]) { + return characters.sort((a, b) => { + const levelA = parseFloat(a.ItemAvgLevel.replace(/,/g, '')) + const levelB = parseFloat(b.ItemAvgLevel.replace(/,/g, '')) + + // 내림차순 정렬 (높은 순) + return levelB - levelA + }) +} + +export const useSiblingsStore = create(set => ({ + siblings: null, + isLoading: false, + error: null, + searchSiblings: async (character: string) => { + set({ isLoading: true, error: null }) + try { + const data = (await getCharacterList(character)) as Siblings[] + + if (data) { + set({ siblings: sortByItemAvgLevel(data), isLoading: false }) + } else { + throw new Error('Character data not found') + } + } catch (error) { + console.error('Error in searchCharacter:', error) + set({ error: error instanceof Error ? error : new Error('An unknown error occurred'), isLoading: false }) + } + } +})) From d13e870b202499605fd5c76982b751582ae667c3 Mon Sep 17 00:00:00 2001 From: ethanJcoding Date: Sun, 14 Jul 2024 23:53:29 +0900 Subject: [PATCH 06/21] =?UTF-8?q?=F0=9F=93=B1=20=ED=97=A4=EB=8D=94?= =?UTF-8?q?=EB=A7=81=ED=81=AC=20=EB=B0=98=EC=9D=91=ED=98=95=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/landing/header/Gnb.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/landing/header/Gnb.tsx b/src/components/landing/header/Gnb.tsx index 2952f29..2612c09 100644 --- a/src/components/landing/header/Gnb.tsx +++ b/src/components/landing/header/Gnb.tsx @@ -14,17 +14,20 @@ export default async function Gnb() { } return ( -
    -
  • +
      +
    • 사용법
    • -
    • +
    • 봇 추가하기
    • +
    • + 유저 검색 +
    • {session && ( -
    • +
    • 대시보드
    • )} From 17d68ca57c1d886857cb0b8d92f313039b6eb4f6 Mon Sep 17 00:00:00 2001 From: ethanJcoding Date: Sun, 14 Jul 2024 23:53:45 +0900 Subject: [PATCH 07/21] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20=EC=9D=B8?= =?UTF-8?q?=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduleDetail/CharacterDetail/CardGemEngSummary.tsx | 6 +++--- src/components/scheduleDetail/CharacterDetail/Gem.tsx | 2 +- src/hooks/useCharacterList.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/scheduleDetail/CharacterDetail/CardGemEngSummary.tsx b/src/components/scheduleDetail/CharacterDetail/CardGemEngSummary.tsx index 5f60d37..e009a70 100644 --- a/src/components/scheduleDetail/CharacterDetail/CardGemEngSummary.tsx +++ b/src/components/scheduleDetail/CharacterDetail/CardGemEngSummary.tsx @@ -9,7 +9,7 @@ interface Ownprops { const getGemAvgLevel = (ArmoryGem: ArmoryGemInterface) => { let sum = 0 - if (ArmoryGem) { + if (ArmoryGem.Gems) { ArmoryGem.Gems.map(g => (sum += g.Level)) const gemAvg = Math.round((sum / ArmoryGem.Gems.length) * 10) / 10 @@ -75,9 +75,9 @@ export default function CardGemEngSummary({ ArmoryCard, ArmoryGem, ArmoryEngravi
      각인
      - {getEngraving(ArmoryEngraving.Effects).map((engrave, idx) => ( + {/* {getEngraving(ArmoryEngraving?.Effects).map((engrave, idx) => (
      {engrave.level}
      - ))} + ))} */}
diff --git a/src/components/scheduleDetail/CharacterDetail/Gem.tsx b/src/components/scheduleDetail/CharacterDetail/Gem.tsx index 02c4bbe..d350390 100644 --- a/src/components/scheduleDetail/CharacterDetail/Gem.tsx +++ b/src/components/scheduleDetail/CharacterDetail/Gem.tsx @@ -6,7 +6,7 @@ interface Ownprops { } export default function Gem({ ArmoryGem }: Ownprops) { - if (ArmoryGem === null) { + if (ArmoryGem.Gems === null) { return
보석이 없어요!
} diff --git a/src/hooks/useCharacterList.ts b/src/hooks/useCharacterList.ts index 3c2a90f..6181634 100644 --- a/src/hooks/useCharacterList.ts +++ b/src/hooks/useCharacterList.ts @@ -1,6 +1,6 @@ import { getUserData } from '@/api/firebase' import { getCharacterList } from '@/api/lostark/getCharacterList' -import { ArmoryProfileInterface } from '@/types/armory' +import { ArmoryProfileInterface } from '@/types/Equipments/armory' import { User } from '@/types/users' import { useQuery } from '@tanstack/react-query' From 44cb507ce579f143aa3f03444a2a434ea7f60a9c Mon Sep 17 00:00:00 2001 From: ethanJcoding Date: Sun, 14 Jul 2024 23:54:16 +0900 Subject: [PATCH 08/21] =?UTF-8?q?=F0=9F=8E=A8=20=EC=8B=9C=EA=B0=84=20?= =?UTF-8?q?=EC=9C=A0=ED=8B=B8=20=ED=95=A8=EC=88=98=20=EB=82=A0=EC=A7=9C=20?= =?UTF-8?q?=EA=B3=84=EC=82=B0=20=EA=B8=B0=EB=8A=A5=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/customDateString.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/customDateString.ts b/src/utils/customDateString.ts index bbde36a..0fd081b 100644 --- a/src/utils/customDateString.ts +++ b/src/utils/customDateString.ts @@ -1,5 +1,7 @@ -function customDateString() { +function customDateString(daysToSubtract: number = 0) { const currentDate = new Date() + currentDate.setDate(currentDate.getDate() - daysToSubtract) + const year = currentDate.getFullYear() const month = String(currentDate.getMonth() + 1).padStart(2, '0') const day = String(currentDate.getDate()).padStart(2, '0') From deb88667f19572a294ec59c7dad90dd6ffcd8b1a Mon Sep 17 00:00:00 2001 From: ethanJcoding Date: Mon, 15 Jul 2024 00:04:49 +0900 Subject: [PATCH 09/21] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20=EC=9D=B8?= =?UTF-8?q?=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/members/MemberCard.tsx | 6 +++--- src/components/members/SettingModal.tsx | 8 ++++---- src/utils/getAccQualityAvg.ts | 4 ++-- src/utils/getAccStatSum.ts | 4 ++-- src/utils/getBraceletAbility.ts | 4 ++-- src/utils/getEquipmentAndAccessories.ts | 4 ++-- src/utils/getSetOption.ts | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/components/members/MemberCard.tsx b/src/components/members/MemberCard.tsx index d98ee20..dfb276e 100644 --- a/src/components/members/MemberCard.tsx +++ b/src/components/members/MemberCard.tsx @@ -1,10 +1,10 @@ import { getCharacterProfile } from '@/api/lostark/getCharacterProfile' -import { ChaListInterface } from '@/types/characterList' import { User } from '@/types/users' import { Session } from 'next-auth' import Image from 'next/image' import Setting from './Setting' import { FaExclamationCircle } from 'react-icons/fa' +import { ArmoryProfileInterface } from '@/types/Equipments/armory' interface OwnProps { members: User[] @@ -27,7 +27,7 @@ const CharacterInfo = ({ label, value }: { label: string; value: string | number
) -const MemberCardContent = ({ data, m, session }: { data: ChaListInterface; m: User; session: Session }) => ( +const MemberCardContent = ({ data, m, session }: { data: ArmoryProfileInterface; m: User; session: Session }) => ( <>
@@ -87,7 +87,7 @@ const MemberCard = async ({ members, session }: OwnProps) => {