From ad07e9b72777f06ae830198adcb887185991ff8d Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 6 Jan 2023 03:02:14 -0800 Subject: [PATCH] Receive and send ring values (WIP) --- components/RingSelect/index.tsx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/components/RingSelect/index.tsx b/components/RingSelect/index.tsx index 69bbd6a9..552744ed 100644 --- a/components/RingSelect/index.tsx +++ b/components/RingSelect/index.tsx @@ -1,8 +1,5 @@ // Core dependencies import React, { useEffect, useState } from 'react' -import { useRouter } from 'next/router' -import { useTranslation } from 'next-i18next' -import classNames from 'classnames' // UI dependencies import SelectWithSelect from '~components/SelectWithSelect' @@ -14,7 +11,7 @@ import { overMastery } from '~data/overMastery' import './index.scss' // Types -import { CharacterOverMastery } from '~types' +import { CharacterOverMastery, ExtendedMastery } from '~types' const emptyRing: ExtendedMastery = { modifier: 0, @@ -35,6 +32,9 @@ const RingSelect = (props: Props) => { 4: emptyRing, }) + useEffect(() => { + props.sendValues(rings) + }, [rings]) function dataSet(index: number) { const noValue = { @@ -65,25 +65,32 @@ const RingSelect = (props: Props) => { } } + function receiveRingValues(index: number, left: number, right: number) { + setRings({ + ...rings, + [index]: { + modifier: left, + strength: right, + }, + }) } return (
- {[...Array(4)].map((element, i) => { + {[...Array(4)].map((e, i) => { const ringIndex = i + 1 return ( {}} - sendValues={(value: number) => { - console.log(`VALUE ${value} RECEIVED`) + sendValues={(left: number, right: number) => { + receiveRingValues(ringIndex, left, right) }} /> )