-
Notifications
You must be signed in to change notification settings - Fork 0
Code review hyungjun #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hyungchunKim
wants to merge
5
commits into
main
Choose a base branch
from
code_review_hyungjun
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bfc174d
Date 관련 오류에 대한 아이디어 떠올라서 시도했으나 실패. 다시 뜯어고쳐야 함
Jsoo-Kim 8fc9257
리스트 부분 수정: 입력 받는 value 값 올바르게 지정 + 새로운 리스트 화면에 표현되는 부분 추가
Jsoo-Kim 01070c0
테스트용
Jsoo-Kim 999a850
입력 시 diaryDate가 화면에 안 나타나는 문제 발생
Jsoo-Kim cba6c07
이슈 해결 완료. css만 하면 됨
Jsoo-Kim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule Jisoo-Repo
added at
7c2625
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,114 +1,25 @@ | ||
| import React, { useState } from "react"; | ||
|
|
||
| const List = ({ | ||
| id, | ||
| diaryValue, | ||
| dateValue, | ||
| diaryData, | ||
| setDiaryData, | ||
| dateData, | ||
| setDateData, | ||
| }) => { | ||
| const [isEditing, setIsEditing] = useState(false); | ||
| const [editedDateText, setEditedDateText] = useState(dateValue); | ||
| const [editedDiaryText, setEditedDiaryText] = useState(diaryValue); | ||
|
|
||
| // 업데이트 할 때 입력 받는 부분? | ||
| const handleDateEditChange = (e) => { | ||
| setEditedDateText(e.target.dateText); | ||
| }; | ||
|
|
||
| const handleDiaryEditChange = (e) => { | ||
| setEditedDiaryText(e.target.diaryText); | ||
| }; | ||
|
|
||
| // * Update 기능 | ||
| const handleSubmit = (e) => { | ||
| e.preventDefault(); | ||
|
|
||
| let newDiaryData = diaryData.map((data) => { | ||
| if (data.id === id) { | ||
| data.title = editedDiaryText; | ||
| } | ||
| return data; | ||
| }); | ||
| setDiaryData(newDiaryData); | ||
| localStorage.setItem("diaryData", JSON.stringify(newDiaryData)); | ||
|
|
||
| let newDateData = dateData.map((data) => { | ||
| if (data.id === id) { | ||
| data.title = editedDateText; | ||
| } | ||
| return data; | ||
| }); | ||
| setDateData(newDateData); | ||
| localStorage.setItem("dateData", JSON.stringify(newDateData)); | ||
|
|
||
| setIsEditing(false); | ||
| }; | ||
|
|
||
| // * Delete 기능 | ||
| const handleRemove = (id) => { | ||
| let newDiaryData = diaryData.filter((data) => data.id !== id); | ||
| setDiaryData(newDiaryData); | ||
| localStorage.setItem("diaryData", JSON.stringify(newDiaryData)); | ||
|
|
||
| let newDateData = dateData.filter((data) => data.id !== id); | ||
| setDateData(newDateData); | ||
| localStorage.setItem("dateData", JSON.stringify(newDateData)); | ||
| }; | ||
|
|
||
| // * html 부분 | ||
| if (isEditing) { | ||
| /* isEditing이 true 즉, 수정 중인 데이터 */ | ||
| return ( | ||
| <div> | ||
| <form onSubmit={handleSubmit}> | ||
| <input | ||
| className="editDateText" | ||
| value={editedDateText} | ||
| onChange={handleDateEditChange} | ||
| /> | ||
| <input | ||
| className="editDiaryText" | ||
| value={editedDiaryText} | ||
| onChange={handleDiaryEditChange} | ||
| autoFocus /* 웹 페이지를 열었을 때 해당 요소에 자동으로 커서가 위치하여 사용자가 바로 입력을 시작할 수 있게 함 */ | ||
| /> | ||
| </form> | ||
|
|
||
| <div className="isEditingButtons"> | ||
| <button onClick={() => setIsEditing(false)} type="button"> | ||
| X | ||
| </button> | ||
| <button onClick={handleSubmit} type="submit"> | ||
| Save | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } else { | ||
| /* isEditing이 false 즉, 작성이 완료된 데이터 */ | ||
| return ( | ||
| <div> | ||
| <span className="editedDate"> | ||
| {dateValue} | ||
| </span> | ||
| <span className="editedDiary"> | ||
| {diaryValue} | ||
| </span> | ||
|
|
||
| <div className="isEditedButtons"> | ||
| <button onClick={() => handleRemove(id)} className="removeButton"> | ||
| X | ||
| </button> | ||
| <button onClick={() => setIsEditing(true)} className="editButton"> | ||
| Edit | ||
| </button> | ||
| import React from "react"; | ||
| import ListItem from "./ListItem"; | ||
|
|
||
| const List = ({ diaryData, setDiaryData }) => { | ||
| return ( | ||
| <div className="listItems"> | ||
| <div style={{ display: "flex" }}> | ||
| <div> | ||
| {diaryData.map((data) => ( | ||
| <ListItem | ||
| key={data.key} | ||
| id={data.id} | ||
| diaryValue={data.diaryValue} | ||
| diaryDate={data.diaryDate} | ||
| diaryData={diaryData} | ||
| setDiaryData={setDiaryData} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default List; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import React, { useState } from "react"; | ||
|
|
||
| const ListItem = ({ id, diaryValue, diaryDate, diaryData, setDiaryData }) => { | ||
| const [isEditing, setIsEditing] = useState(false); | ||
| const [editedDiaryValue, setEditedDiaryValue] = useState(diaryValue); // Edit 할 때 입력되어 있는 부분 | ||
| const [editedDiaryDate, setEditedDiaryDate] = useState(diaryDate); | ||
|
|
||
|
|
||
| // 업데이트 할 때 입력 받는 부분? | ||
| const handleDiaryEditChange = (e) => { | ||
| const { name, value } = e.target; | ||
| if (name === "diaryValue") { | ||
| setEditedDiaryValue(e.target.value); | ||
| } else if (name === "diaryDate") { | ||
| setEditedDiaryDate(e.target.value); | ||
| } | ||
| }; | ||
|
|
||
| // * Update 기능 (save 클릭했을 때 호출) | ||
| const handleSubmit = (e) => { | ||
| e.preventDefault(); | ||
|
|
||
| let newDiaryData = diaryData.map((data) => { | ||
| if (data.id === id) { | ||
| data.diaryValue = editedDiaryValue; | ||
| data.diaryDate = editedDiaryDate; | ||
| } | ||
| return data; | ||
| }); | ||
| setDiaryData(newDiaryData); | ||
| localStorage.setItem("diaryData", JSON.stringify(newDiaryData)); | ||
|
|
||
| setIsEditing(false); | ||
| }; | ||
|
|
||
| // * Delete 기능 | ||
| const handleRemove = (id) => { | ||
| let newDiaryData = diaryData.filter((data) => data.id !== id); | ||
| setDiaryData(newDiaryData); | ||
| localStorage.setItem("diaryData", JSON.stringify(newDiaryData)); | ||
| }; | ||
|
|
||
| // * html 부분 | ||
| if (isEditing) { | ||
| /* isEditing이 true 즉, 수정 중인 데이터 */ | ||
| return ( | ||
| <div className="stateOfEditing"> | ||
| <form onSubmit={handleSubmit}> | ||
| <input | ||
| className="editDiaryDate" | ||
| name="diaryDate" | ||
| value={editedDiaryDate} | ||
| onChange={handleDiaryEditChange} | ||
| /> | ||
| <input | ||
| className="editDiaryValue" | ||
| name="diaryValue" | ||
| value={editedDiaryValue} /* 저장된 텍스트 값 부분 */ | ||
| onChange={handleDiaryEditChange} | ||
| autoFocus /* 웹 페이지를 열었을 때 해당 요소에 자동으로 커서가 위치하여 사용자가 바로 입력을 시작할 수 있게 함 */ | ||
| /> | ||
| </form> | ||
|
|
||
| <div className="isEditingButtons"> | ||
| <button onClick={() => setIsEditing(false)} type="button"> | ||
| X | ||
| </button> | ||
| <button onClick={handleSubmit} type="submit"> | ||
| Save | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } else { | ||
| /* isEditing이 false 즉, 작성이 완료된 데이터 */ | ||
| return ( | ||
| <div style={{ display: "flex" }} key={id}> | ||
| {" "} | ||
| {/* 각 리스트들의 고유 key 가 필요함 */} | ||
| <span className="editDate"> | ||
| {diaryDate} | ||
| </span> | ||
| <span className="editDiary"> | ||
| {diaryValue} | ||
| </span> | ||
| <div className="isEditedButtons"> | ||
| <button onClick={() => handleRemove(id)} className="removeButton"> | ||
| X | ||
| </button> | ||
| <button onClick={() => setIsEditing(true)} className="editButton"> | ||
| Edit | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| }; | ||
|
|
||
| export default ListItem; | ||
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 이런 속성을 줄수가 있군요!! 좋은정보 감사합니다!!