Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
crewup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-system-design-24-3
crewup
Commits
13425ab5
Commit
13425ab5
authored
5 months ago
by
김 도형
Browse files
Options
Downloads
Plain Diff
Merge branch 'front-issue5' into 'main'
edit signup-image upload See merge request
!41
parents
65b03b40
3f3dad2a
Branches
Branches containing commit
No related tags found
1 merge request
!41
edit signup-image upload
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
webapp/frontend/src/components/SignUp.js
+32
-23
32 additions, 23 deletions
webapp/frontend/src/components/SignUp.js
with
32 additions
and
23 deletions
webapp/frontend/src/components/SignUp.js
+
32
−
23
View file @
13425ab5
...
...
@@ -51,21 +51,20 @@ function SignUp(){
const
handleImageChange
=
(
e
)
=>
{
const
file
=
e
.
target
.
files
[
0
];
setImageFile
(
file
);
// 실제 파일
console
.
log
(
imageFile
);
if
(
file
)
{
const
reader
=
new
FileReader
();
reader
.
onloadend
=
()
=>
{
setImagePreview
(
reader
.
result
);
// 미리보기용 이미지
setImageFile
(
file
);
// 실제 파일
};
reader
.
readAsDataURL
(
file
);
// 파일을 URL로 변환
}
};
const
handleImageUpload
=
async
(
e
)
=>
{
//
e.preventDefault();
e
.
preventDefault
();
const
formData
=
new
FormData
();
formData
.
append
(
'
image
'
,
imageFile
);
...
...
@@ -81,28 +80,22 @@ function SignUp(){
if
(
response
.
ok
)
{
// 업로드 성공시, 서버에서 반환된 이미지 URL을 받음
const
imageUrl
=
data
.
image_url
;
return
imageUrl
;
}
else
{
console
.
error
(
data
.
error
);
alert
(
data
.
error
);
return
null
;
}
}
catch
(
error
)
{
console
.
error
(
error
);
alert
(
'
업로드 중 오류가 발생했습니다.
'
);
return
null
;
console
.
log
(
error
);
}
};
const
handleSubmit
=
async
(
e
)
=>
{
e
.
preventDefault
();
const
imageUrl
=
await
handleImageUpload
(
imageFile
);
// 이미지 업로드 함수 호출
console
.
log
(
imageUrl
);
if
(
isSportTypeID
)
{
if
(
imageFile
)
{
const
imageUrl
=
await
handleImageUpload
(
imageFile
);
// 이미지 업로드 함수 호출
const
user
=
{
name
:
name
,
...
...
@@ -115,21 +108,37 @@ function SignUp(){
birthDate
:
birthdate
,
experience
:
experience
,
introduction
:
introduction
,
sportTypeID
:
sportTypeMapping
[
sportTypeID
]
,
sportTypeID
:
sportTypeID
,
},
};
onCreateUser
(
user
);
alert
(
"
회원가입이 완료되었습니다!
"
);
navigate
(
'
/login
'
);
createUser
(
user
);
}
else
{
alert
(
"
원하는 운동 종목을 입력해 주세요.
"
);
}
}
const
createUser
=
async
(
newUser
)
=>
{
try
{
const
response
=
await
fetch
(
`
${
apiUrl
}
/api/users`
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
(
newUser
),
})
const
data
=
await
response
.
json
();
console
.
log
(
data
)
if
(
data
)
{
navigate
(
'
/login
'
);
}
}
catch
(
error
)
{
console
.
error
(
error
);
}
};
const
handleNameChange
=
(
e
)
=>
{
const
currentName
=
e
.
target
.
value
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment