Skip to content

Commit

Permalink
[refactor] #7 상태 변경 api 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
harin0707 committed May 31, 2024
1 parent 8bf070f commit 8241329
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/components/issue/InfoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ const InfoBox: React.FC<InputProps> = ({infoType, data, patchData}) => {

const handleStatusUpdate = async () =>{
try{
const updatedIssue = await usePatch('status', Number(issueId), updatedIssueData);
const updatedIssue = await usePatch('issues/status', Number(issueId), updatedIssueData);
console.log('Updated Issue:', updatedIssue);

} catch(error){
console.error('Error updating issue status', error);
}
Expand Down
6 changes: 4 additions & 2 deletions src/hooks/usePatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import { UpdateIssueInfo } from "@/types/type";


const usePatch = async(endpoint:string, issueId:number, issueData:UpdateIssueInfo) =>{
const url = `${process.env.NEXT_PUBLIC_API_BASE_URL}/status?issueId=${issueId}`;
const url = `${process.env.NEXT_PUBLIC_API_BASE_URL}/${endpoint}?issueId=${issueId}`;
const requestBody = JSON.stringify(issueData);
const requestOption = {
method: 'PATCH',
headers: {
'Content-Type' : 'application/json'
},
body:JSON.stringify(issueData)
body:requestBody
}
console.log(url);
console.log(requestBody);

try{
const response = await fetch(url, requestOption);
Expand Down

0 comments on commit 8241329

Please sign in to comment.