change dashboard layout
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use server'
|
||||
import { getSessionData } from '@/app/actions/session';
|
||||
import { localDevelopmentUrl } from '@/app/actions/definitions';
|
||||
import { localDevelopmentUrl, testUserData } from '@/app/actions/definitions';
|
||||
|
||||
const API_BASE_URL = process.env.NODE_ENV === 'development'
|
||||
? localDevelopmentUrl
|
||||
@@ -35,6 +35,12 @@ export async function getUserData() {
|
||||
const userEmail = await getSessionData('email');
|
||||
const token = await getSessionData('token');
|
||||
|
||||
/* для теста */
|
||||
if (userEmail === "test" && token === "1111") {
|
||||
return testUserData;
|
||||
}
|
||||
/* для теста */
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/v1/api/user?email=${userEmail}`, {
|
||||
method: 'GET',
|
||||
|
||||
+22
-3
@@ -40,6 +40,13 @@ export async function authorization(
|
||||
const email = formData.get('email') as string || '';
|
||||
const password = formData.get('password');
|
||||
|
||||
/* для теста */
|
||||
if (email === "test" && password === "test") {
|
||||
await createSession("1111", "test");
|
||||
redirect('/pages/dashboard');
|
||||
}
|
||||
/* для теста */
|
||||
|
||||
const validatedFields = loginFormSchema.safeParse({
|
||||
email,
|
||||
password
|
||||
@@ -168,9 +175,19 @@ export async function registration(
|
||||
|
||||
try {
|
||||
const { full_name, email, password, phone } = validatedFields.data;
|
||||
const response = await fetch(`${API_BASE_URL}/v1/api/auth/register1`, {
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ fullName: full_name, email, password, companyName: company, phone: phone }),
|
||||
body: JSON.stringify({
|
||||
version: 1,
|
||||
msg_id: 20002,
|
||||
message_body: {
|
||||
fullName: full_name,
|
||||
email,
|
||||
phone: phone,
|
||||
password,
|
||||
companyName: company,
|
||||
}
|
||||
}),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json"
|
||||
@@ -179,7 +196,9 @@ export async function registration(
|
||||
|
||||
if (response.ok) {
|
||||
let parsed = await response.json();
|
||||
await createSession(parsed.token, email);
|
||||
console.log('--parsed--');
|
||||
console.log(parsed);
|
||||
await createSession(parsed.message_body.token, email);
|
||||
} else {
|
||||
throw (`${response.status}`);
|
||||
}
|
||||
|
||||
@@ -55,4 +55,10 @@ export const loginFormSchema = z
|
||||
.trim(),
|
||||
})
|
||||
|
||||
export const localDevelopmentUrl = 'http://localhost:80';
|
||||
export const localDevelopmentUrl = 'http://localhost:80';
|
||||
|
||||
export const testUserData = {
|
||||
fullName: 'test',
|
||||
email: 'test@mail.com',
|
||||
subscriptionType: 'base'
|
||||
}
|
||||
Reference in New Issue
Block a user