Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions src/pages/AddRecord/AddRecord.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { useEffect, useState } from 'react'
import BackButton from '@components/BackButton'
import AddRecordCategory from './AddRecordCategory'

import AddRecordTextArea from './AddRecordTextArea'
import AddRecordColor from './AddRecordColor'
import AddRecordFile from './AddRecordFile'

import AddRecordIcon from './AddRecordIcon'
import Button from '@components/Button'
import { useNavigate } from 'react-router-dom'
Expand All @@ -23,11 +21,6 @@ import AddRecordInput from './AddRecordInput'
import { useCheckMobile } from '@hooks/useCheckMobile'
import MemoizedParentCategoryTab from '@components/ParrentCategoryTab'

export type IsInputsHasValueType = {
input: boolean
textArea: boolean
}

export type FormDataType = {
selectedCategory: number
selectedColor: string
Expand Down Expand Up @@ -63,11 +56,6 @@ export default function AddRecord() {
const [parentCategoryId, setParentCategoryId] =
useState<parentCategoryID>(CELEBRATION_ID)

const [isInputsHasValue, setIsInputsHasValue] =
useState<IsInputsHasValueType>({
input: false,
textArea: false,
})
const [formData, setFormData] = useRecoilState(formDataAtom)
const { selectedCategory, selectedColor, selectedIcon }: FormDataType =
formData
Expand Down Expand Up @@ -99,7 +87,6 @@ export default function AddRecord() {
selectedCategory: parentCategoryId === CELEBRATION_ID ? 3 : 7,
selectedColor: 'icon-purple',
})
setIsInputsHasValue({ input: false, textArea: false })
}
}, [parentCategoryId])

Expand Down Expand Up @@ -131,10 +118,6 @@ export default function AddRecord() {
setParentCategoryId(2)
}
}
setIsInputsHasValue({
input: recordData.title,
textArea: recordData.content,
})
setFormData({ ...formData, selectedColor: recordData.colorName })
}
}, [recordData])
Expand Down Expand Up @@ -261,8 +244,6 @@ export default function AddRecord() {
modifyTitle={recordData?.title}
recordTitle={recordTitle}
setRecordTitle={setRecordTitle}
isInputsHasValue={isInputsHasValue}
setIsInputsHasValue={setIsInputsHasValue}
setIsInputFocus={setIsInputFocus}
parentCategoryId={parentCategoryId}
isModify={isModify}
Expand All @@ -272,8 +253,6 @@ export default function AddRecord() {
modifyTitle={recordData?.content}
recordContent={recordContent}
setRecordContent={setRecordContent}
isInputsHasValue={isInputsHasValue}
setIsInputsHasValue={setIsInputsHasValue}
currentRecordType={parentCategoryId}
setIsInputFocus={setIsInputFocus}
/>
Expand Down
22 changes: 2 additions & 20 deletions src/pages/AddRecord/AddRecordInput.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import React, { Dispatch, SetStateAction, useEffect, useState } from 'react'
import {
CELEBRATION_ID,
INPUT_DETAILS,
RECORD_TITLE_MAX_LENGTH,
} from '@assets/constant/constant'
import { IsInputsHasValueType } from './AddRecord'

import { parentCategoryID } from 'types/category'

interface Props {
setIsInputsHasValue: Dispatch<SetStateAction<IsInputsHasValueType>>
isInputsHasValue: IsInputsHasValueType
setIsInputFocus: Dispatch<SetStateAction<boolean>>
recordTitle: string
setRecordTitle: Dispatch<SetStateAction<string>>
Expand All @@ -19,8 +12,6 @@ interface Props {
}

function AddRecordInput({
setIsInputsHasValue,
isInputsHasValue,
setIsInputFocus,
recordTitle,
setRecordTitle,
Expand All @@ -39,16 +30,7 @@ function AddRecordInput({
}, [parentCategoryId])

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const inputValueLength = e.target.value.length
if (inputValueLength > INPUT_DETAILS.MAX_INPUT_TYPING) {
return
}
if (inputValueLength > INPUT_DETAILS.MIN_TYPING) {
setIsInputsHasValue({ ...isInputsHasValue, input: true })
}
if (inputValueLength === INPUT_DETAILS.MIN_TYPING) {
setIsInputsHasValue({ ...isInputsHasValue, input: false })
}

setRecordTitle(e.target.value)
}

Expand Down
11 changes: 0 additions & 11 deletions src/pages/AddRecord/AddRecordTextArea.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import React, { Dispatch, SetStateAction, useEffect } from 'react'
import { CELEBRATION_ID, INPUT_DETAILS } from '@assets/constant/constant'
import { IsInputsHasValueType } from './AddRecord'
import { parentCategoryID } from 'types/category'

type userProps = {
recordContent: string
setRecordContent: Dispatch<SetStateAction<string>>
currentRecordType: parentCategoryID
setIsInputsHasValue: Dispatch<SetStateAction<IsInputsHasValueType>>
isInputsHasValue: IsInputsHasValueType
setIsInputFocus: Dispatch<SetStateAction<boolean>>
modifyTitle: string
}

function AddRecordTextArea({
setIsInputsHasValue,
isInputsHasValue,
currentRecordType,
setIsInputFocus,
recordContent,
Expand All @@ -42,12 +37,6 @@ function AddRecordTextArea({
if (inputValueLength > INPUT_DETAILS.MAX_TEXTAREA_TYPING) {
return
}
if (inputValueLength > 0) {
setIsInputsHasValue({ ...isInputsHasValue, textArea: true })
}
if (inputValueLength === 0) {
setIsInputsHasValue({ ...isInputsHasValue, textArea: false })
}
setRecordContent(e.target.value)
}

Expand Down