Compare commits
No commits in common. "e7f6de4a299b1941dff872ab242f9a8bde042e48" and "faba9fa3cb17da6d8df5899ce35308789172c3f1" have entirely different histories.
e7f6de4a29
...
faba9fa3cb
7
.idea/discord.xml
generated
7
.idea/discord.xml
generated
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="APPLICATION" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
@ -14,7 +14,7 @@ import { Label } from "@/components/ui/label";
|
||||
import type { IUserData } from "@/interfaces/userdata.interface";
|
||||
|
||||
import { CopyButton } from "@/components/ui/copy-button";
|
||||
import { doDisconnect, getWallet } from "@/services/account.handler";
|
||||
import { doDisconnect } from "@/services/account.handler";
|
||||
import { Bitcoin, Fingerprint, Key, Landmark, Unplug, User, Wallet } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import type React from "react";
|
||||
@ -28,9 +28,6 @@ export function AccountInfo({
|
||||
setUserData: React.Dispatch<React.SetStateAction<IUserData | undefined>>;
|
||||
isDisconnected: boolean;
|
||||
}) {
|
||||
getWallet().then(() => {
|
||||
console.log("pong !");
|
||||
});
|
||||
if (isDisconnected) {
|
||||
return (
|
||||
<div className={"flex flex-col justify-center items-center h-10 p-2 text-xs mt-2"}>
|
||||
|
@ -1,25 +1,21 @@
|
||||
"use client";
|
||||
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import {Tabs, TabsContent, TabsList, TabsTrigger} from "@/components/ui/tabs";
|
||||
|
||||
import AutoForm, { AutoFormSubmit } from "@/components/auto-form";
|
||||
import { UserDataContext } from "@/components/providers/userdata-provider";
|
||||
import { ToastBox, toastType } from "@/components/ui/toast-box";
|
||||
import { useToast } from "@/components/ui/use-toast";
|
||||
import type {
|
||||
IApiLoginReq,
|
||||
IApiLoginRes,
|
||||
IApiRegisterReq,
|
||||
IApiRegisterRes,
|
||||
} from "@/interfaces/api.interface";
|
||||
import { EReturnState, type IStandardisedReturn } from "@/interfaces/general.interface";
|
||||
import type { IUserData } from "@/interfaces/userdata.interface";
|
||||
import AutoForm, {AutoFormSubmit} from "@/components/auto-form";
|
||||
import {UserDataContext} from "@/components/providers/userdata-provider";
|
||||
import type {IApiLoginReq, IApiLoginRes, IApiRegisterReq, IApiRegisterRes} from "@/interfaces/api.interface";
|
||||
import type {IUserData} from "@/interfaces/userdata.interface";
|
||||
import ApiRequest from "@/services/apiRequest";
|
||||
import { useLocalStorage } from "@/services/localStorage";
|
||||
import { Bug, RefreshCw } from "lucide-react";
|
||||
import {EReturnState, type IStandardisedReturn} from "@/services/general.interface";
|
||||
import {useLocalStorage} from "@/services/localStorage";
|
||||
import {Bug, RefreshCw} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { type Dispatch, type SetStateAction, useContext, useState } from "react";
|
||||
import {type Dispatch, type SetStateAction, useContext, useState} from "react";
|
||||
import * as z from "zod";
|
||||
import {ToastBox, toastType} from "@/components/ui/toast-box";
|
||||
import {useToast} from "@/components/ui/use-toast";
|
||||
|
||||
|
||||
const loginSchema = z.object({
|
||||
email: z
|
||||
@ -66,7 +62,7 @@ export function AuthForms() {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [sub, setSub] = useLocalStorage<string | undefined>("sub", "");
|
||||
const userContext = useContext(UserDataContext);
|
||||
const { toast } = useToast();
|
||||
const { toast } = useToast()
|
||||
|
||||
async function doRegister(
|
||||
registerData: IApiRegisterReq,
|
||||
@ -80,15 +76,8 @@ export function AuthForms() {
|
||||
>("auth/signup", registerData);
|
||||
console.trace(ReqRes.data);
|
||||
if (ReqRes.data.user) {
|
||||
userDataSetter({
|
||||
...ReqRes.data.user,
|
||||
wallet: {
|
||||
uat: Date.now(),
|
||||
update_interval: 30_000,
|
||||
owned_cryptos: [],
|
||||
},
|
||||
});
|
||||
setSub(ReqRes.data.access_token?.toString());
|
||||
userDataSetter(ReqRes.data.user);
|
||||
setSub(ReqRes.data.access_token);
|
||||
}
|
||||
console.debug(ReqRes.data.message || "Not additional message from request");
|
||||
return {
|
||||
@ -158,19 +147,19 @@ export function AuthForms() {
|
||||
toast({
|
||||
description: res.message || "An unexpected error occurred..",
|
||||
variant: "destructive",
|
||||
});
|
||||
setIsLoading(false);
|
||||
return;
|
||||
})
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
//toast.custom(<ToastBox message={"Login successful ! \n You will be redirected."} type={toastType.success}/>)
|
||||
toast({
|
||||
description: "Login successful ! \n You will be redirected.",
|
||||
});
|
||||
setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
location.href = "/";
|
||||
console.log("Moving to home.");
|
||||
}, 3_000);
|
||||
description: "Login successful ! \n You will be redirected."
|
||||
})
|
||||
setTimeout(()=>{
|
||||
setIsLoading(false)
|
||||
location.href = "/"
|
||||
console.log('Moving to home.')
|
||||
}, 3_000)
|
||||
});
|
||||
}}
|
||||
fieldConfig={{
|
||||
@ -204,15 +193,15 @@ export function AuthForms() {
|
||||
).then((res) => {
|
||||
if (res.state !== EReturnState.done) {
|
||||
//toast.custom(<ToastBox message={res.message || "An unexpected error occurred.."} type={toastType.error}/>)
|
||||
setIsLoading(false);
|
||||
return;
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
//toast.custom(<ToastBox message={"Register successful ! \n You will be redirected."} type={toastType.success}/>)
|
||||
setTimeout(() => {
|
||||
setIsLoading(false);
|
||||
setTimeout(()=>{
|
||||
setIsLoading(false)
|
||||
//location.href = "/"
|
||||
console.log("Moving to home.");
|
||||
}, 5_000);
|
||||
console.log('Moving to home.')
|
||||
}, 5_000)
|
||||
});
|
||||
}}
|
||||
fieldConfig={{
|
||||
|
@ -49,7 +49,7 @@ export function Footer() {
|
||||
<h3 className={"text-nowrap text-center"}>Support Center</h3>
|
||||
</Link>
|
||||
</div>
|
||||
<div />
|
||||
<div/>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
|
@ -18,15 +18,6 @@ export interface IApiLoginReq {
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface IApiTradeCreateRq {
|
||||
id_offer: string;
|
||||
}
|
||||
|
||||
export interface IApiOfferCreateReq {
|
||||
id_crypto: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
// ----- Response -----
|
||||
|
||||
export interface IAbstractApiResponse {
|
||||
@ -52,12 +43,4 @@ export interface IApiUserAssetsRes extends IAbstractApiResponse {
|
||||
UserHasCrypto?: IUserWalletCryptos[];
|
||||
}
|
||||
|
||||
export interface IApiAllTradesRes extends IAbstractApiResponse {}
|
||||
|
||||
export interface IAllRankRes extends IAbstractApiResponse {}
|
||||
|
||||
export interface IAllReferralCodeRes extends IAbstractApiResponse {}
|
||||
|
||||
export interface IReferralCodeUpdateRes extends IAbstractApiResponse {}
|
||||
|
||||
export interface IReferralCodeDeleteRes extends IAbstractApiResponse {}
|
||||
export interface IApiAllTrades extends IAbstractApiResponse {}
|
||||
|
@ -1,10 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import type { IApiAllTradesRes, IApiUserAssetsRes } from "@/interfaces/api.interface";
|
||||
import { IUserWalletCryptos } from "@/interfaces/crypto.interface";
|
||||
import { EReturnState, type IStandardisedReturn } from "@/interfaces/general.interface";
|
||||
import type { IUserData, IUserWallet } from "@/interfaces/userdata.interface";
|
||||
import type {
|
||||
IApiLoginReq,
|
||||
IApiLoginRes,
|
||||
IApiRegisterReq,
|
||||
IApiRegisterRes,
|
||||
} from "@/interfaces/api.interface";
|
||||
import type { IUserData } from "@/interfaces/userdata.interface";
|
||||
import ApiRequest from "@/services/apiRequest";
|
||||
import { EReturnState, IStandardisedReturn } from "@/services/general.interface";
|
||||
import { useLocalStorage } from "@/services/localStorage";
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
|
||||
//TODO Run disconnect task
|
||||
@ -16,97 +21,9 @@ export function doDisconnect() {
|
||||
return true;
|
||||
}
|
||||
console.log(
|
||||
"Whut ? Why trying to remove an item from the localStorage when running in SSR ?",
|
||||
"Whut ? Why trying to remove an item from the localStorage when runner in SSR ?",
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function getWallet(): Promise<IStandardisedReturn<IApiUserAssetsRes>> {
|
||||
try {
|
||||
const ReqRes =
|
||||
await ApiRequest.authenticated.get.json<IStandardisedReturn<IApiUserAssetsRes>>(
|
||||
"user/my-assets",
|
||||
);
|
||||
console.log(ReqRes.data);
|
||||
|
||||
if (ReqRes.status !== 200) {
|
||||
return {
|
||||
state: EReturnState.clientError,
|
||||
};
|
||||
}
|
||||
return {
|
||||
state: EReturnState.done,
|
||||
resolved: ReqRes.data,
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
state: EReturnState.serverError,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getUserTrades() {
|
||||
try {
|
||||
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,
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
state: EReturnState.serverError,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAlltrades() {
|
||||
try {
|
||||
const ReqRes =
|
||||
await ApiRequest.authenticated.get.json<IStandardisedReturn<IApiAllTradesRes>>(
|
||||
"trade/all",
|
||||
);
|
||||
console.log(ReqRes.data);
|
||||
|
||||
if (ReqRes.status !== 200) {
|
||||
return {
|
||||
state: EReturnState.clientError,
|
||||
};
|
||||
}
|
||||
return {
|
||||
state: EReturnState.done,
|
||||
resolved: ReqRes.data,
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
state: EReturnState.serverError,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function createTrade() {}
|
||||
|
||||
export async function getAllTrade() {}
|
||||
|
||||
export async function getUserTrade() {}
|
||||
|
||||
export async function getAllReferralCode() {}
|
||||
|
||||
export async function createReferralCode() {}
|
||||
|
||||
export async function getAllCryptos() {}
|
||||
|
||||
export async function getCryptoHistory(cryptoId: string) {}
|
||||
|
||||
export async function sellCrypto() {}
|
||||
|
||||
export async function buyCrypto() {}
|
||||
//TODO Run update user data
|
||||
|
Loading…
x
Reference in New Issue
Block a user