Skip to content

Commit

Permalink
update: signUpForm exception
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyoon committed Dec 30, 2023
1 parent 3236e6b commit 7053c64
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
58 changes: 31 additions & 27 deletions src/routes/(mono-column)/signup/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -86,33 +86,37 @@
}
};
const signInForm = async (data) => {
const requestData = {
"email": data[0],
"nickname": data[1],
"password": data[2],
"departId": data[3],
};
const fetchData = {
method: 'post',
body: JSON.stringify(requestData),
headers: {
'Content-Type': 'application/json',
'charset': 'UTF-8'
},
}
await fetch(`/api/members`, fetchData).then(async (response) => {
console.log(`signIn data sending...`);
if (response.status >= 200 && response.status < 300) {
console.log(`회원가입 완료`);
goto("/login", { replaceState: true });
return response.json();
} else {
const errData = response.json();
console.log(errData);
throw new Error("Something went wrong!");
const signUpForm = async (data) => {
if (data[0].split("").indexOf(" ") === -1 && data[1].split("").indexOf(" ") === -1 && data[2].split("").indexOf(" ") === -1 && typeof data[3] === 'number') {
const requestData = {
"email": data[0],
"nickname": data[1],
"password": data[2],
"departId": data[3],
};
const fetchData = {
method: 'post',
body: JSON.stringify(requestData),
headers: {
'Content-Type': 'application/json',
'charset': 'UTF-8'
},
}
})
await fetch(`/api/members`, fetchData).then(async (response) => {
console.log(`signUp data sending...`);
if (response.status >= 200 && response.status < 300) {
console.log(`회원가입 완료`);
goto("/login", { replaceState: true });
return response.json();
} else {
const errData = response.json();
console.log(errData);
throw new Error("Something went wrong!");
}
})
} else {
alert("회원가입 형식이 올바르지 않습니다. 다시 작성해주세요.");
}
};
const serviceAgree = () => {
Expand Down Expand Up @@ -156,7 +160,7 @@
{:else if step === "servAgree"}
<Card {step} {serviceAgree} />
{:else}
<Card {step} {signInForm} bind:email={userEmail} />
<Card {step} {signUpForm} bind:email={userEmail} />
{/if}
{/each}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(mono-column)/signup/Card.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
export let emailAuth;
export let authCodeVerification;
export let serviceAgree;
export let signInForm;
export let signUpForm;
export let backStep;
</script>

Expand All @@ -21,7 +21,7 @@
{:else if step === "servAgree"}
<Content3 {serviceAgree} />
{:else if step === "signIn"}
<Content4 {signInForm} bind:email={email} />
<Content4 {signUpForm} bind:email={email} />
{/if}
</div>
</div>
Expand Down
16 changes: 6 additions & 10 deletions src/routes/(mono-column)/signup/contents/Content4.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@
import Textfield from "@smui/textfield";
import Button, { Label } from "@smui/button";
import Select, { Option } from "@smui/select";
export let signInForm;
export let signUpForm;
export let email;
let departures = [
1,
2,
];
let departures = [1, 2, 3, 4, 5];
email = "";
let userData = ["","","1"];
$: console.log(userData);
$: console.log(email);
let userData = ["", "", "1"];
</script>

<div class="side-image flex-child_center">
Expand Down Expand Up @@ -71,7 +65,9 @@
<div style="flex:0.15">
<Button
color="primary"
on:click={() => {signInForm([email, ...userData])}}
on:click={() => {
signUpForm([email, ...userData]);
}}
class="wd_200 bd-rd_28 hg_60"
style="margin-top: 1vh;"
variant="raised"
Expand Down

0 comments on commit 7053c64

Please sign in to comment.