diff --git a/src/lib/userFunction.js b/src/lib/userFunction.js index fdc1811..8e102be 100644 --- a/src/lib/userFunction.js +++ b/src/lib/userFunction.js @@ -16,6 +16,53 @@ export async function UserCheck(){ } } + export async function checkName(username) { + const response = await fetch('http://localhost:8000/api/users/check_existing_username', { + method:'POST', + credentials:"include", + headers:{ + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + "username": username + }) + }) + if(response.status === 200){ + } + else if(response.status === 409){ + let data = "ник занят" + return data + } + else if(response.status === 422){ + let data = await response.json(); + return data + } +} + +export async function checkMail(mail) { + const response = await fetch('http://localhost:8000/api/users/check_existing_email', { + method:'POST', + credentials:"include", + headers:{ + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + "email": mail + }) + }) + if(response.status === 200){ + } + else if(response.status === 409){ + let data = "почта занята" + return data + } + else if(response.status === 422){ + let data = "не похоже на почту" + return data + } +} + + export async function handleRegister(username,password,email,date_of_birth){ const response = await fetch('http://localhost:8000/api/users/register',{ method:'POST', @@ -31,13 +78,16 @@ export async function UserCheck(){ }) }) - if(!response.ok){ - console.log(response.status) - } - else{ + if(response.status === 201){ const data = await response.json(); + console.log(data) return data; } + else if(response.status === 422){ + console.log(response.status) + let data = "Validation Error" + return data + } } diff --git a/src/routes/Header.svelte b/src/routes/Header.svelte index 7cb74d8..d33df90 100644 --- a/src/routes/Header.svelte +++ b/src/routes/Header.svelte @@ -49,10 +49,8 @@ display: flex; justify-content: space-around; align-items: center; - - background-color: rgba(255, 255, 255, 0.3); - border: 0; - + background-color: rgba(255, 255, 255, 0.3); + border: 0; } @@ -78,10 +76,7 @@ cursor: pointer; } - div, h3 { - font-weight: 600; - font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important; - } + .headerClass > * { margin-bottom: 0; } diff --git a/src/routes/register/+page.svelte b/src/routes/register/+page.svelte index 3c1d017..50c1773 100644 --- a/src/routes/register/+page.svelte +++ b/src/routes/register/+page.svelte @@ -1,287 +1,391 @@ + +{#if VisiblePopUp} +
+{/if} -
-
-
-

Регистрация

+
+
+
+
+

Регистрация

+
+
+

имя

+ {#if nameError && nameError !== ''} +

+ {nameError} +

+ {/if} +
+ +
- - -
-
-

имя

-

- -
- -
-
-

эл почта

-

- -
- +
+
+

эл почта

+ {#if mailError && mailError !== ''} +

+ {mailError} +

+ {/if} +
+ +
-
-
-

пароль

-

- -
+
+
+

пароль

+ {#if passwordError && passwordError !== ''} +

+ {passwordError} +

+ {/if} +
+ +
-
-
-

повтори пароль

-

- -
+
+
+

повтори пароль

+ {#if password2Error && password2Error !== ''} +

{password2Error}

+ {/if} +
+ +
-
-

Дата рождения

-
- - +
+

Дата рождения

+
+ - + - - -
-
- -
- -
- - -
-
-
+ +
+
+ + +
+
+
\ No newline at end of file + h1, + h2, + h3, + h4, + h5, + h6, + p, + input, + select, + button[type='submit'] { + color: var(--fontColor); + } + h1 { + display: flex; + justify-content: center; + align-items: center; + text-shadow: 0 0 20px white; + font-size: 48px; + height: 10%; + } + h3 { + font-weight: 100; + font-size: 24px; + } +