Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
final-exam
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nawasan Wisitsingkhon
final-exam
Commits
69925dae
Commit
69925dae
authored
Sep 30, 2023
by
Nawasan Wisitsingkhon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish: register from front to back end;
parent
e9c70125
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
7 deletions
+37
-7
Navbar.js
src/components/Navbar.js
+1
-1
register.js
src/pages/register.js
+36
-6
No files found.
src/components/Navbar.js
View file @
69925dae
...
@@ -226,7 +226,7 @@ function Navbar(props) {
...
@@ -226,7 +226,7 @@ function Navbar(props) {
component="
div
"
component="
div
"
sx={{ display: { xs: "
none
", md: "
block
" } }}
sx={{ display: { xs: "
none
", md: "
block
" } }}
>
>
<Link href={"
/
"}>
MUI
</Link>
<Link href={"
/
"}>
OpenShop
</Link>
</Typography>
</Typography>
<Search>
<Search>
<SearchIconWrapper>
<SearchIconWrapper>
...
...
src/pages/register.js
View file @
69925dae
...
@@ -6,6 +6,7 @@ import { UserContext } from "./_app";
...
@@ -6,6 +6,7 @@ import { UserContext } from "./_app";
import
{
Container
}
from
"@mui/material"
;
import
{
Container
}
from
"@mui/material"
;
import
{
Google
}
from
"@mui/icons-material"
;
import
{
Google
}
from
"@mui/icons-material"
;
import
{
useState
}
from
"react"
;
import
{
useState
}
from
"react"
;
import
axios
from
"axios"
;
export
default
function
Login
()
{
export
default
function
Login
()
{
const
[
errorMessage
,
setErrorMessage
]
=
useState
(
""
);
const
[
errorMessage
,
setErrorMessage
]
=
useState
(
""
);
...
@@ -29,9 +30,38 @@ export default function Login() {
...
@@ -29,9 +30,38 @@ export default function Login() {
*
*
* @param {FormDataEvent} e
* @param {FormDataEvent} e
*/
*/
function
onSubmitForm
(
e
)
{
async
function
onSubmitForm
(
e
)
{
e
.
preventDefault
()
e
.
preventDefault
();
alert
(
"form submit"
)
let
response
=
await
axios
.
post
(
"/api/user"
,
{
name
,
email
,
phone
,
image
,
username
,
password
,
});
if
(
response
.
data
.
status
===
201
)
{
setSuccessMessage
(
"สมัครสมาชิกสำเร็จ!"
);
setTimeout
(()
=>
{
setSuccessMessage
(
""
);
},
3000
);
setName
(
""
)
setEmail
(
""
)
setPhone
(
""
)
setImage
(
""
)
setUsername
(
""
)
setPassword
(
""
)
}
else
if
(
response
.
data
.
status
===
202
)
{
setErrorMessage
(
"ชื่อผู้ใช้งานนี้ถูกใช้แล้ว กรุณาลองใหม่อีกครั้ง"
);
setTimeout
(()
=>
{
setErrorMessage
(
""
);
},
3000
);
}
else
{
setErrorMessage
(
"ขออภัย มีบางอย่างไม่ถูกต้อง กรุณาลองใหม่อีกครั้ง"
);
setTimeout
(()
=>
{
setErrorMessage
(
""
);
},
3000
);
}
}
}
return
(
return
(
...
@@ -40,8 +70,8 @@ export default function Login() {
...
@@ -40,8 +70,8 @@ export default function Login() {
<
Snackbar
<
Snackbar
ContentProps
=
{{
className
:
"bg-red-500"
}}
ContentProps
=
{{
className
:
"bg-red-500"
}}
anchorOrigin
=
{{
horizontal
:
"center"
,
vertical
:
"top"
}}
anchorOrigin
=
{{
horizontal
:
"center"
,
vertical
:
"top"
}}
open
=
{
errorMessage
}
open
=
{
errorMessage
.
length
}
message
=
{
errorMessage
.
length
}
message
=
{
errorMessage
}
/
>
/
>
<
Snackbar
<
Snackbar
ContentProps
=
{{
className
:
"bg-green-500"
}}
ContentProps
=
{{
className
:
"bg-green-500"
}}
...
@@ -120,7 +150,7 @@ export default function Login() {
...
@@ -120,7 +150,7 @@ export default function Login() {
<
Divider
/>
<
Divider
/>
<
Box
component
=
{
"h4"
}
>
หรือสมัครด้วยบัญชี
google
<
/Box
>
<
Box
component
=
{
"h4"
}
>
หรือสมัครด้วยบัญชี
google
<
/Box
>
<
button
className
=
"bg-white rounded-full border-none hover:shadow-md shadow-gray-400 duration-300 hover:-translate-y-1"
>
<
button
className
=
"bg-white rounded-full border-none hover:shadow-md shadow-gray-400 duration-300 hover:-translate-y-1"
>
<
Google
fontSize
=
"large"
/>
<
Google
color
=
"primary"
fontSize
=
"large"
/>
<
/button
>
<
/button
>
<
/div
>
<
/div
>
<
/Grid
>
<
/Grid
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment