Skip to content

Commit

Permalink
Merge pull request #29 from primus-teoSprint/feat/#24
Browse files Browse the repository at this point in the history
[#24] 투자 μ§€ν‘œ νŽ˜μ΄μ§€ 및 계산 둜직
  • Loading branch information
hanseulhee authored Apr 7, 2024
2 parents 98314a0 + 6ba8c84 commit 0763ced
Show file tree
Hide file tree
Showing 21 changed files with 320 additions and 148 deletions.
26 changes: 24 additions & 2 deletions app/(route)/indicators/_components/result/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
import Nav from '@/app/_common/nav'
import Title from '@/app/_common/text/title'
import { investmentItemAtom, totalinputValueAtom } from '@/app/_store/atom'
import { useRecoilValue } from 'recoil'
import S from './result.module.css'

//* κ²°κ³ΌνŽ˜μ΄μ§€ μž…λ‹ˆλ‹€.
//TODO: μ‚¬μš©μžκ°€ ν΄λ¦­ν•œ 아이디어 이름과 ν•΄λ‹Ή νˆ΄μ„ μ‚¬μš©ν•œ μ‚¬μš©μž μˆ˜κ°€ λ³΄μ—¬μ§‘λ‹ˆλ‹€.
function Result() {
const selectedItem = useRecoilValue(investmentItemAtom)
const totalinputValue = parseInt(useRecoilValue(totalinputValueAtom))

return (
<div className={S.wrapper}>
<Nav />
<div>
<Title title="검증 κ²°κ³Ό" />

<div>
<Title title="아이디어 이름" />
<span>전체 μ‚¬μš©μž 162λͺ…</span>
<span className={S.title}>아이디어 이름</span>
<p className={S.subTitle}>전체 μ‚¬μš©μž 162λͺ…</p>
</div>

<div>
<span className={S.title}>검증 μ§€ν‘œ</span>
<p className={S.subTitle}>계산 κ²°κ³Όμ§€μž…λ‹ˆλ‹€.</p>

<p>전체 이용자 수 : {totalinputValue}</p>

{selectedItem.map((item) => (
<span key={item.id}>
<p>μ„ νƒν•œ μ•„μ΄ν…œ 이름: {item.name}</p>
<p>μ„ νƒν•œ μ•„μ΄ν…œ 점수: {item.score}</p>
<p>μ΅œμ’… 점수: {item.score && item.score * totalinputValue}</p>
</span>
))}
</div>
</div>
</div>
Expand Down
10 changes: 10 additions & 0 deletions app/(route)/indicators/_components/result/result.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@
padding-bottom: 50px;
padding: 0 18px;
}

.title {
font-size: 1.2rem;
font-weight: 700;
}

.subTitle {
font-size: 0.9rem;
font-weight: 400;
}
6 changes: 5 additions & 1 deletion app/(route)/indicators/indicators.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
overflow: auto;
height: 690px;
width: 100%;
gap: 14px;
gap: 6px;
}

.marginWrapper {
margin-bottom: 50px;
}

.bottomWrapper {
Expand Down
74 changes: 50 additions & 24 deletions app/(route)/indicators/page.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
'use client'

import Title from '@/app/_common/text/title'
import { totalinputValueAtom } from '@/app/_store/atom'
import { useRouter } from 'next/navigation'
import { useState } from 'react'
import { useRecoilState } from 'recoil'
import Nav from '../list/_components/nav'
import ActiveInvestmentList from '../verification/ibulsin/_components/ActiveInvestmentList'
import FormTitle from './_components/form/FormTitle'
import FormS from './_components/form/form.module.css'
import S from './indicators.module.css'

//* 투자 μ§€ν‘œ μž…λ ₯ νŽ˜μ΄μ§€μž…λ‹ˆλ‹€.
//TODO: title에 μ‚¬μš©μžκ°€ μž…λ ₯ν–ˆλ˜ μš”μ†Œλ“€μ΄ λ³΄μ—¬μ§€κ²Œ λ©λ‹ˆλ‹€.
//TODO: recoil μ‚¬μš©
//? ν”ΌκΈ°λ‹˜μ΄ ν•˜μ‹  νˆ¬μžμ§€ν‘œ 툴둜 λ³€κ²½ μ˜ˆμ •
function Indicators() {
const router = useRouter()
const [inputValue, setInputValue] = useState('')
const [inputValue, setInputValue] = useRecoilState(totalinputValueAtom)
const [error, setError] = useState('')
const [checkError, setCheckError] = useState('')
const [selectedIndex, setSelectedIndex] = useState<number | null>(null)

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setInputValue(e.target.value)
setError('')
}

const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
if (!/^\d+$/.test(inputValue)) {
const handleSubmit = () => {
if (!/^\d+$/.test(inputValue) && selectedIndex === null) {
setError('숫자만 μž…λ ₯ κ°€λŠ₯ν•©λ‹ˆλ‹€.')
setCheckError('μ§€ν‘œ ν•­λͺ©μ„ ν•œκ°€μ§€ 선택해야 ν•©λ‹ˆλ‹€.')
} else if (!/^\d+$/.test(inputValue)) {
setError('숫자만 μž…λ ₯ κ°€λŠ₯ν•©λ‹ˆλ‹€.')
} else if (selectedIndex === null) {
setCheckError('μ§€ν‘œ ν•­λͺ©μ„ ν•œκ°€μ§€ 선택해야 ν•©λ‹ˆλ‹€.')
} else {
setError('')
setCheckError('')
router.push('/result')
}
}
Expand All @@ -38,33 +47,50 @@ function Indicators() {
<div className={S.paddingWrapper}>
<Title title="아이디어 제λͺ©" />
</div>
<form className={S.formWrapper} onSubmit={handleSubmit}>

<div className={S.formWrapper}>
<div className={S.overflowWrapper}>
<FormTitle
title="전체 이용자 수"
subTitle="전체 이용자 수λ₯Ό 가지고 총 κ²°κ³Ό μ§€ν‘œκ°€ κ³„μ‚°λ©λ‹ˆλ‹€."
/>
<div className={S.marginWrapper}>
<FormTitle
title="전체 이용자 수"
subTitle="전체 이용자 수λ₯Ό 가지고 총 κ²°κ³Ό μ§€ν‘œκ°€ κ³„μ‚°λ©λ‹ˆλ‹€."
/>

<div className={FormS.inputWrapper}>
<input
className={FormS.input}
placeholder="수치λ₯Ό μž…λ ₯ν•΄ μ£Όμ„Έμš”."
value={inputValue}
onChange={handleChange}
<div className={FormS.inputWrapper}>
<input
className={FormS.input}
placeholder="수치λ₯Ό μž…λ ₯ν•΄ μ£Όμ„Έμš”."
value={inputValue}
onChange={handleChange}
/>
</div>
{error && <span className={FormS.error}>{error}</span>}
</div>
<div className={S.marginWrapper}>
<FormTitle
title="μ§€ν‘œ ν•­λͺ©"
subTitle="점수 ν™˜μ‚°μ˜ 기쀀이 λ˜λŠ” ν•œκ°€μ§€μ˜ ν•­λͺ©μ„ κ³¨λΌμ£Όμ„Έμš”."
/>
<ActiveInvestmentList
selectedIndex={selectedIndex}
onSelect={(index: number) => {
setSelectedIndex(index)
setCheckError('')
}}
/>
{checkError && <span className={FormS.error}>{checkError}</span>}
</div>

{error && (
<span className={FormS.error}>숫자만 μž…λ ₯ κ°€λŠ₯ν•©λ‹ˆλ‹€.</span>
)}
</div>

<div className={S.bottomWrapper}>
<button type="submit" className={S.submitBtnWrapper}>
<button
type="submit"
className={S.submitBtnWrapper}
onClick={handleSubmit}
>
μ œμΆœν•˜κΈ°
</button>
</div>
</form>
</div>
</div>
</>
)
Expand Down
9 changes: 5 additions & 4 deletions app/(route)/toolDetail/[toolId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import Nav from '@/app/_common/nav'
import Title from '@/app/_common/text/title'
import { useState } from 'react'
import S from './toolDetail.module.css'
import Link from 'next/link'

//
//TODO: κ²€μ¦ν•˜κΈ° λˆ„λ₯Ό μ‹œ ν•΄λ‹Ή 아이디어 툴의 id둜 μ΄λ™ν•˜κΈ°
//TODO: 주석 처리 μ‹€μ œ λ°μ΄ν„°λ‘œ λ³€κ²½ν•˜κΈ°
function ToolDetail() {
const [clickBtn, setClickBtn] = useState(false)
Expand Down Expand Up @@ -77,9 +78,9 @@ function ToolDetail() {
)}
</div>

{/* <Link href={`/verification/${toolId}`}>
<div>κ²€μ¦ν•˜κΈ°</div>
</Link> */}
<Link href={`/verification/ibulsin?step=1`}>
<div>κ²€μ¦ν•˜κΈ°</div>
</Link>
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
.item_container {
display: flex;
/* justify-content: space-between; */
justify-content: center;
margin-bottom: 8px;
justify-content: space-between;
margin-bottom: 3px;
height: 50px;
}
.item_input_wrapper {
display: flex;
}
.input {
all: unset;
font-size: 12px;
font-size: 0.83rem;
padding: 8px;
border: 1px solid #CDCDCD;
border-radius: 4px;
padding: 14px 20px;
border: 1px solid #efefef;
border-radius: 15px;
width: 100%;
height: auto;
}

.item_name_input {
width: 100px;
width: 200px;
margin-right: 16px;
}
.score_container {
Expand All @@ -33,12 +37,28 @@
padding: 4px 8px;
background-color: rgb(248, 64, 64);
color: #ffffff;
font-size: 12px;
font-size: 0.7rem;
font-weight: 600;
border-radius: 8px;
width: 30px;
height: 20px;
text-align: center;
}

.columnWrapper {
display: flex;
flex-direction: column;

gap: 3px;
}

.input::-webkit-outer-spin-button,
.input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
}

.checkbox {
accent-color: var(--purple-700);
margin-bottom: 20px;
}
Loading

0 comments on commit 0763ced

Please sign in to comment.