feat: layout padding and scroll added
This commit is contained in:
82
src/features/authentication/api/authorizationAPI.ts
Normal file
82
src/features/authentication/api/authorizationAPI.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import type { ApiResponse } from '@/types/apiResponse';
|
||||
import type {
|
||||
ConfirmEmailOtpRequest,
|
||||
ConfirmForgetPassCodeRequest,
|
||||
ConfirmOtpResponse,
|
||||
ConfirmSmsOtpRequest,
|
||||
GetUserStatusByPhoneNumberOrEmailRequest,
|
||||
GetUserStatusByPhoneNumberOrEmailResponse,
|
||||
LoginOrSignUpWithGoogleRequest,
|
||||
LoginOrSignUpWithGoogleResponse,
|
||||
LoginRequest,
|
||||
LoginResponse,
|
||||
PasswordLoginRequest,
|
||||
ResetPasswordRequest,
|
||||
ResetPasswordResponse,
|
||||
SendEmailOtpRequest,
|
||||
SendForgetPassCodeRequest,
|
||||
SendSmsOtpRequest,
|
||||
} from '../types/userTypes';
|
||||
import apiClient from '@/lib/apiClient';
|
||||
|
||||
// GetUserStatusByPhoneNumberOrEmail
|
||||
|
||||
export const getUserStatusByPhoneNumberOrEmail = async (
|
||||
body: GetUserStatusByPhoneNumberOrEmailRequest,
|
||||
) => {
|
||||
return apiClient.post<GetUserStatusByPhoneNumberOrEmailResponse>(
|
||||
'User/GetUserStatusByPhoneNumberOrEmail',
|
||||
body,
|
||||
);
|
||||
};
|
||||
|
||||
export const loginOrSignUpWithOtp = async (body: LoginRequest) => {
|
||||
return apiClient.post<LoginResponse>('User/LoginOrSignUpWithOtp', body);
|
||||
};
|
||||
|
||||
export const loginWithPassword = async (body: PasswordLoginRequest) => {
|
||||
return apiClient.post<LoginResponse>('User/LoginWithPassword', body);
|
||||
};
|
||||
|
||||
export const sendSmsOtp = async (body: SendSmsOtpRequest) => {
|
||||
return apiClient.post<ApiResponse>('User/SendSmsOtp', body);
|
||||
};
|
||||
|
||||
export const sendEmailOtp = async (body: SendEmailOtpRequest) => {
|
||||
return apiClient.post<ApiResponse>('User/SendEmailOtp', body);
|
||||
};
|
||||
|
||||
export const confirmSmsOtp = async (body: ConfirmSmsOtpRequest) => {
|
||||
return apiClient.post<ConfirmOtpResponse>('User/ConfirmSmsOtp', body);
|
||||
};
|
||||
|
||||
export const confirmEmailOtp = async (body: ConfirmEmailOtpRequest) => {
|
||||
return apiClient.post<ConfirmOtpResponse>('User/ConfirmEmailOtp', body);
|
||||
};
|
||||
|
||||
export const resetPassword = async (body: ResetPasswordRequest) => {
|
||||
return apiClient.post<ResetPasswordResponse>('User/ResetPassword', body);
|
||||
};
|
||||
|
||||
export const sendForgetPassCode = async (body: SendForgetPassCodeRequest) => {
|
||||
return apiClient.post<ApiResponse>('User/SendForgetPassCode', body);
|
||||
};
|
||||
|
||||
export const confirmForgetPassCode = async (
|
||||
body: ConfirmForgetPassCodeRequest,
|
||||
) => {
|
||||
return apiClient.post<ConfirmOtpResponse>('User/ConfirmForgetPassCode', body);
|
||||
};
|
||||
|
||||
export const loginOrSignUpWithGoogle = async (
|
||||
body: LoginOrSignUpWithGoogleRequest,
|
||||
) => {
|
||||
return apiClient.post<LoginOrSignUpWithGoogleResponse>(
|
||||
'User/LoginOrSignUpWithGoogle',
|
||||
body,
|
||||
);
|
||||
};
|
||||
|
||||
export const logOut = async () => {
|
||||
return apiClient.post<ApiResponse>('User/LogOut', {});
|
||||
};
|
||||
83
src/features/authentication/api/identityAPI.ts
Normal file
83
src/features/authentication/api/identityAPI.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import apiClient from '@/lib/apiClient';
|
||||
|
||||
export interface GenerateTokenWithPassword {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface GenerateTokenResponse {
|
||||
access_token: string;
|
||||
expires_in: number;
|
||||
token_type: 'Bearer';
|
||||
refresh_token: string;
|
||||
scope: string;
|
||||
}
|
||||
|
||||
export const generateTokenWithPassword = (
|
||||
request: GenerateTokenWithPassword,
|
||||
) => {
|
||||
const body = new URLSearchParams();
|
||||
body.set('grant_type', 'password');
|
||||
body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID);
|
||||
body.set('scope', import.meta.env.VITE_IDENTITY_SCOPE);
|
||||
body.set('username', request.username);
|
||||
body.set('password', request.password);
|
||||
|
||||
return apiClient.post<GenerateTokenResponse>(
|
||||
import.meta.env.VITE_IDENTITY_URL,
|
||||
body.toString(),
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
export interface GenerateTokenWithOTP {
|
||||
email?: string;
|
||||
phonenumber?: string;
|
||||
otp: string;
|
||||
}
|
||||
|
||||
export const generateTokenWithOtp = (request: GenerateTokenWithOTP) => {
|
||||
const body = new URLSearchParams();
|
||||
body.set('grant_type', 'otp');
|
||||
body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID);
|
||||
body.set('scope', import.meta.env.VITE_IDENTITY_SCOPE);
|
||||
if (request.email) body.set('email', request.email);
|
||||
if (request.phonenumber) body.set('phonenumber', request.phonenumber);
|
||||
body.set('otp_code', request.otp);
|
||||
|
||||
return apiClient.post<GenerateTokenResponse>(
|
||||
import.meta.env.VITE_IDENTITY_URL,
|
||||
body.toString(),
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
export interface GenerateTokenWithGoogle {
|
||||
idToken: string;
|
||||
}
|
||||
|
||||
export const generateTokenWithGoogle = (request: GenerateTokenWithGoogle) => {
|
||||
const body = new URLSearchParams();
|
||||
body.set('grant_type', 'google');
|
||||
body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID);
|
||||
body.set('scope', import.meta.env.VITE_IDENTITY_SCOPE);
|
||||
body.set('idtoken', request.idToken);
|
||||
|
||||
return apiClient.post<GenerateTokenResponse>(
|
||||
import.meta.env.VITE_IDENTITY_URL,
|
||||
body.toString(),
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
20
src/features/authentication/api/userCompletion.ts
Normal file
20
src/features/authentication/api/userCompletion.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {
|
||||
type SendEmailOtpPayload,
|
||||
type ConfirmEmailOtpPayload,
|
||||
type CompleteUserInfoPayload,
|
||||
} from '../types/completionFormApiTypes';
|
||||
import apiClient from '@/lib/apiClient';
|
||||
|
||||
export const sendEmailOtpApi = async (payload: SendEmailOtpPayload) => {
|
||||
return apiClient.post('/User/SendEmailOtp', payload);
|
||||
};
|
||||
|
||||
export const confirmEmailOtpApi = async (payload: ConfirmEmailOtpPayload) => {
|
||||
return apiClient.post('/User/ConfirmEmailOtp', payload);
|
||||
};
|
||||
|
||||
export const completeUserInformationApi = async (
|
||||
payload: CompleteUserInfoPayload,
|
||||
) => {
|
||||
return apiClient.post('/User/CompleteUserInformation', payload);
|
||||
};
|
||||
Reference in New Issue
Block a user