Compare commits
2 Commits
e7f6de4a29
...
aa322d0c8f
Author | SHA1 | Date | |
---|---|---|---|
aa322d0c8f | |||
87245c702e |
@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import type { IApiAllTradesRes, IApiUserAssetsRes } from "@/interfaces/api.interface";
|
import type {IAllReferralCodeRes, IApiAllTradesRes, IApiUserAssetsRes} from "@/interfaces/api.interface";
|
||||||
import { IUserWalletCryptos } from "@/interfaces/crypto.interface";
|
import { IUserWalletCryptos } from "@/interfaces/crypto.interface";
|
||||||
import { EReturnState, type IStandardisedReturn } from "@/interfaces/general.interface";
|
import { EReturnState, type IStandardisedReturn } from "@/interfaces/general.interface";
|
||||||
import type { IUserData, IUserWallet } from "@/interfaces/userdata.interface";
|
import type { IUserData, IUserWallet } from "@/interfaces/userdata.interface";
|
||||||
@ -93,15 +93,99 @@ export async function getAlltrades() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createTrade() {}
|
export async function createTrade(data: any) {
|
||||||
|
const ReqRes =
|
||||||
|
await ApiRequest.authenticated.post.json<IStandardisedReturn<IApiAllTradesRes>>(
|
||||||
|
"trade/create",
|
||||||
|
{
|
||||||
|
|
||||||
export async function getAllTrade() {}
|
}
|
||||||
|
);
|
||||||
|
console.log(ReqRes.data);
|
||||||
|
|
||||||
export async function getUserTrade() {}
|
if (ReqRes.status !== 200) {
|
||||||
|
return {
|
||||||
|
state: EReturnState.clientError,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
state: EReturnState.done,
|
||||||
|
resolved: ReqRes.data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export async function getAllReferralCode() {}
|
export async function getAllTrade() {
|
||||||
|
const ReqRes =
|
||||||
|
await ApiRequest.authenticated.get.json<IStandardisedReturn<IApiAllTradesRes>>(
|
||||||
|
"trade/all",
|
||||||
|
);
|
||||||
|
console.log(ReqRes.data);
|
||||||
|
|
||||||
export async function createReferralCode() {}
|
if (ReqRes.status !== 200) {
|
||||||
|
return {
|
||||||
|
state: EReturnState.clientError,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
state: EReturnState.done,
|
||||||
|
resolved: ReqRes.data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getUserTrade() {
|
||||||
|
const ReqRes =
|
||||||
|
await ApiRequest.authenticated.get.json<IStandardisedReturn<IApiAllTradesRes>>(
|
||||||
|
"user/my-trades",
|
||||||
|
);
|
||||||
|
console.log(ReqRes.data);
|
||||||
|
|
||||||
|
if (ReqRes.status !== 200) {
|
||||||
|
return {
|
||||||
|
state: EReturnState.clientError,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
state: EReturnState.done,
|
||||||
|
resolved: ReqRes.data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getAllReferralCode() {
|
||||||
|
const ReqRes =
|
||||||
|
await ApiRequest.authenticated.get.json<IStandardisedReturn<IAllReferralCodeRes>>(
|
||||||
|
"promoCode/all",
|
||||||
|
);
|
||||||
|
console.log(ReqRes.data);
|
||||||
|
|
||||||
|
if (ReqRes.status !== 200) {
|
||||||
|
return {
|
||||||
|
state: EReturnState.clientError,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
state: EReturnState.done,
|
||||||
|
resolved: ReqRes.data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createReferralCode(data: any) {
|
||||||
|
const ReqRes =
|
||||||
|
await ApiRequest.authenticated.post.json<IStandardisedReturn<IAllReferralCodeRes>>(
|
||||||
|
"promoCode/create",
|
||||||
|
data
|
||||||
|
);
|
||||||
|
console.log(ReqRes.data);
|
||||||
|
|
||||||
|
if (ReqRes.status !== 200) {
|
||||||
|
return {
|
||||||
|
state: EReturnState.clientError,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
state: EReturnState.done,
|
||||||
|
resolved: ReqRes.data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export async function getAllCryptos() {}
|
export async function getAllCryptos() {}
|
||||||
|
|
||||||
|
400
temp.ts
Normal file
400
temp.ts
Normal file
@ -0,0 +1,400 @@
|
|||||||
|
////////apiTypes.ts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface ResponseSuccess {
|
||||||
|
|
||||||
|
data: any
|
||||||
|
|
||||||
|
status: number
|
||||||
|
|
||||||
|
statusText: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface ResponseFailed {
|
||||||
|
|
||||||
|
code: string
|
||||||
|
|
||||||
|
message: string
|
||||||
|
|
||||||
|
name: string
|
||||||
|
|
||||||
|
response: {
|
||||||
|
|
||||||
|
data: {
|
||||||
|
|
||||||
|
error: string
|
||||||
|
|
||||||
|
message: string
|
||||||
|
|
||||||
|
statusCode: number
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
status: number
|
||||||
|
|
||||||
|
statusText: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////cryptoTypes.ts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export enum RoleName {
|
||||||
|
|
||||||
|
user = 'user',
|
||||||
|
|
||||||
|
admin = 'admin',
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type Role = {
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
name: RoleName
|
||||||
|
|
||||||
|
created_at?: string
|
||||||
|
|
||||||
|
updated_at?: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type PromoCode = {
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
name: string
|
||||||
|
|
||||||
|
value: number
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type CryptoHistory = {
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
id_crypto: string
|
||||||
|
|
||||||
|
value: number
|
||||||
|
|
||||||
|
created_at: string
|
||||||
|
|
||||||
|
updated_at: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface Offer {
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
User: {
|
||||||
|
|
||||||
|
pseudo: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
amount: number
|
||||||
|
|
||||||
|
created_at: string
|
||||||
|
|
||||||
|
id_user: string
|
||||||
|
|
||||||
|
Crypto: CryptoData
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface UserAssets {
|
||||||
|
|
||||||
|
firstName: string
|
||||||
|
|
||||||
|
lastName: string
|
||||||
|
|
||||||
|
dollarAvailables: number
|
||||||
|
|
||||||
|
pseudo: string
|
||||||
|
|
||||||
|
age: number
|
||||||
|
|
||||||
|
UserHasCrypto: CryptoData[]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface Signin {
|
||||||
|
|
||||||
|
access_token: string
|
||||||
|
|
||||||
|
user: UserExtended
|
||||||
|
|
||||||
|
Role: Role
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface CryptoData {
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
name: string
|
||||||
|
|
||||||
|
value: number
|
||||||
|
|
||||||
|
image: string
|
||||||
|
|
||||||
|
quantity: number
|
||||||
|
|
||||||
|
created_at: string
|
||||||
|
|
||||||
|
updated_at: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface MyCryptoData {
|
||||||
|
|
||||||
|
Crypto: CryptoData
|
||||||
|
|
||||||
|
amount: number
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface Trade {
|
||||||
|
|
||||||
|
Giver: User
|
||||||
|
|
||||||
|
Receiver: User
|
||||||
|
|
||||||
|
Crypto: CryptoData
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface User {
|
||||||
|
|
||||||
|
firstName: string
|
||||||
|
|
||||||
|
lastName: string
|
||||||
|
|
||||||
|
pseudo: string
|
||||||
|
|
||||||
|
dollarAvailables: number
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserHasCrypto {
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
id_user: string
|
||||||
|
|
||||||
|
id_crypto: string
|
||||||
|
|
||||||
|
amount: number
|
||||||
|
|
||||||
|
createdAt: string
|
||||||
|
|
||||||
|
updated_at: string
|
||||||
|
|
||||||
|
Crypto: CryptoData
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserExtended extends User {
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
hash: string
|
||||||
|
|
||||||
|
email: string
|
||||||
|
|
||||||
|
roleId: string
|
||||||
|
|
||||||
|
isActive: boolean
|
||||||
|
|
||||||
|
city: string
|
||||||
|
|
||||||
|
age: number
|
||||||
|
|
||||||
|
created_at: string
|
||||||
|
|
||||||
|
updated_at: string
|
||||||
|
|
||||||
|
UserHasCrypto?: UserHasCrypto
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface MyTrade {
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
id_giver: string
|
||||||
|
|
||||||
|
id_receiver: string
|
||||||
|
|
||||||
|
id_crypto: string
|
||||||
|
|
||||||
|
amount_traded: number
|
||||||
|
|
||||||
|
created_at: string
|
||||||
|
|
||||||
|
updated_at: string
|
||||||
|
|
||||||
|
Crypto: CryptoData
|
||||||
|
|
||||||
|
Giver: UserExtended
|
||||||
|
|
||||||
|
Receiver: UserExtended
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export interface AuthData {
|
||||||
|
|
||||||
|
access_token: string
|
||||||
|
|
||||||
|
user: {
|
||||||
|
|
||||||
|
id: string
|
||||||
|
|
||||||
|
firstName: string
|
||||||
|
|
||||||
|
lastName: string
|
||||||
|
|
||||||
|
pseudo: string
|
||||||
|
|
||||||
|
hash: null | any
|
||||||
|
|
||||||
|
email: string
|
||||||
|
|
||||||
|
roleId: string
|
||||||
|
|
||||||
|
isActive: boolean
|
||||||
|
|
||||||
|
city: string
|
||||||
|
|
||||||
|
dollarAvailables: number
|
||||||
|
|
||||||
|
age: number
|
||||||
|
|
||||||
|
created_at: string
|
||||||
|
|
||||||
|
updated_at: string
|
||||||
|
|
||||||
|
UserHasCrypto: UserHasCrypto[]
|
||||||
|
|
||||||
|
Role: Role
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////formTypes.ts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type RegisterInput = {
|
||||||
|
|
||||||
|
firstName: string
|
||||||
|
|
||||||
|
lastName: string
|
||||||
|
|
||||||
|
pseudo: string
|
||||||
|
|
||||||
|
city: string
|
||||||
|
|
||||||
|
email: string
|
||||||
|
|
||||||
|
password: string
|
||||||
|
|
||||||
|
confirmPassword: string
|
||||||
|
|
||||||
|
promoCode: string
|
||||||
|
|
||||||
|
age: number
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type LoginInput = {
|
||||||
|
|
||||||
|
email: string
|
||||||
|
|
||||||
|
password: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type RoleInput = {
|
||||||
|
|
||||||
|
name: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type PromoCodeInput = {
|
||||||
|
|
||||||
|
name: string
|
||||||
|
|
||||||
|
value: number
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type TradeInput = {
|
||||||
|
|
||||||
|
id_offer: string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type OfferInput = {
|
||||||
|
|
||||||
|
id_crypto: string
|
||||||
|
|
||||||
|
amount: number
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user