Skip to content
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

feat: 트랙 추가하기 기능 구현 #419

Merged
merged 2 commits into from
Mar 25, 2024
Merged

feat: 트랙 추가하기 기능 구현 #419

merged 2 commits into from
Mar 25, 2024

Conversation

gxxrxn
Copy link
Member

@gxxrxn gxxrxn commented Mar 20, 2024

구현 기능

  • 트랙 추가하기 기능을 구현했어요.

관련 이슈

@gxxrxn gxxrxn added ✨ feature New feature or request 📚 프론트엔드 Frontend labels Mar 20, 2024
@gxxrxn gxxrxn requested a review from SingTheCode March 20, 2024 14:26
@gxxrxn gxxrxn self-assigned this Mar 20, 2024
Copy link

vercel bot commented Mar 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
collusic-new ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 20, 2024 2:28pm

@gxxrxn gxxrxn changed the base branch from main to dev-fe March 20, 2024 14:26
Copy link
Collaborator

@SingTheCode SingTheCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다ㅎㅎ 제안드린것일 뿐이고 빨리 마무리하는게 우선이니깐 대략적으로만 봐주시고 머지하셔도 될 것 같아요ㅎㅎ

import { API } from "./axios";

// 트랙 생성
export const addTrack = async (projectId: string, params: {}) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params에 빈 객체로 타입을 설정하면 addTrack 호출부에서 params에 key 넣을 때 타입에러가 뜨진 않나요??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FormData 타입이 빈 객체로 정의되어 있어서 에러가 발생하지는 않는 것으로 보여요. 이전 프로젝트 생성할 때 작성했던 코드를 재사용하다가 parameter 타입을 놓쳤네요.. 여기선 FormData 타입을 사용하는게 더 정확할 것 같아요!

} = useTrackSetting();
function TrackSetting({ projectTitle, bpmState, trackTags, tracks, onTrackCreate }: ProjectInfoType) {
const { title, inputDeviceId, inputTextDevice, trackTag, handleTitleInput, handleTrackTagSelect, handleDeviceClick } =
useTrackSetting();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettier가 이렇게 포맷팅 시켜주나요??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네! printWidth를 120으로 설정해둬서 그런가봐요..😂

Comment on lines +50 to +52
if (!title || !trackTag || !recordedAudio) {
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제목, 태그, 녹음에 대한 사용자 액션을 유도하는 얼럿을 추가해주는 것은 어떨까요??

Suggested change
if (!title || !trackTag || !recordedAudio) {
return;
}
const requiredProperties = [title, trackTag, recordedAudio];
const errorPropertyIdx = requiredProperties.fineIndex((item) => !item);
if (errorPropertyIdx > -1) {
alert(`${requiredProperties[errorPropertyIdx]}을 채워주세요.`);
return;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오.. 이렇게 required 요소를 체크하는 방법 좋은 것 같아요! 👍🏻

Comment on lines +28 to +33
const recordedBlob = await getAudioBlob(audio);

const formData = new FormData();
formData.append("trackName", title);
formData.append("trackTag", trackTag);
formData.append("audioFile", recordedBlob);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

인스턴스 생성 구끼리 인접하게 두는게 더 깔끔해보일 것 같아요ㅎㅎ

Suggested change
const recordedBlob = await getAudioBlob(audio);
const formData = new FormData();
formData.append("trackName", title);
formData.append("trackTag", trackTag);
formData.append("audioFile", recordedBlob);
const recordedBlob = await getAudioBlob(audio);
const formData = new FormData();
formData.append("trackName", title);
formData.append("trackTag", trackTag);
formData.append("audioFile", recordedBlob);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 코드를 읽을 때 formData를 생성하는 부분이 한 블록으로 읽히면 좋을 것 같아서 묶어뒀어요. 저도 변수 선언부가 인접해있으면 깔끔하다는 의견에 동의해요! 👍🏻

@gxxrxn gxxrxn merged commit d837e0e into dev-fe Mar 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature New feature or request 📚 프론트엔드 Frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FE] [트랙 추가] 트랙 생성 api 연결
2 participants