Transform userId into UUID format
parent
44b3ef8b70
commit
ad28e29e85
10
src/App.tsx
10
src/App.tsx
|
|
@ -13,14 +13,10 @@ import { BuyReturn } from "./pages/BuyReturn.tsx";
|
||||||
import { Grid, Paper } from "@mui/material";
|
import { Grid, Paper } from "@mui/material";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const locallyStoredUserId = window.localStorage.getItem("paysplit-user-id");
|
const [userId, setUserId] = useState<string | null>(
|
||||||
const locallyStoredUserIdAsNumber = locallyStoredUserId
|
window.localStorage.getItem("paysplit-user-id")
|
||||||
? parseInt(locallyStoredUserId)
|
|
||||||
: null;
|
|
||||||
const [userId, setUserId] = useState<number | null>(
|
|
||||||
locallyStoredUserIdAsNumber,
|
|
||||||
);
|
);
|
||||||
const storeUserId = (id: number) => {
|
const storeUserId = (id: string) => {
|
||||||
window.localStorage.setItem("paysplit-user-id", id.toString());
|
window.localStorage.setItem("paysplit-user-id", id.toString());
|
||||||
setUserId(id);
|
setUserId(id);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import axios, { type AxiosResponse } from "axios";
|
import axios, { type AxiosResponse } from "axios";
|
||||||
|
|
||||||
interface AccessResponse {
|
interface AccessResponse {
|
||||||
userId: number;
|
userId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const login = (name: string, password: string) =>
|
export const login = (name: string, password: string) =>
|
||||||
|
|
@ -16,12 +16,12 @@ export const registerUser = (name: string, password: string) =>
|
||||||
password,
|
password,
|
||||||
}) as Promise<AxiosResponse<AccessResponse, unknown, {}>>;
|
}) as Promise<AxiosResponse<AccessResponse, unknown, {}>>;
|
||||||
|
|
||||||
export const startBuyFlow = (userId: number, quantity: number) =>
|
export const startBuyFlow = (userId: string, quantity: number) =>
|
||||||
axios.post("/buy/start", { userId, quantity }) as Promise<
|
axios.post("/buy/start", { userId, quantity }) as Promise<
|
||||||
AxiosResponse<{ url: string }, unknown, {}>
|
AxiosResponse<{ url: string }, unknown, {}>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export const completeBuyFlow = (userId: number) =>
|
export const completeBuyFlow = (userId: string) =>
|
||||||
axios.post("/buy/complete", { userId }) as Promise<
|
axios.post("/buy/complete", { userId }) as Promise<
|
||||||
AxiosResponse<{ url: string }, unknown, {}>
|
AxiosResponse<{ url: string }, unknown, {}>
|
||||||
>;
|
>;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { createContext } from "react";
|
import { createContext } from "react";
|
||||||
|
|
||||||
interface LoggedInPageContextProps {
|
interface LoggedInPageContextProps {
|
||||||
userId: number;
|
userId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LoggedInPageContext =
|
export const LoggedInPageContext =
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { createContext } from "react";
|
import { createContext } from "react";
|
||||||
|
|
||||||
interface PreLoginPageContextProps {
|
interface PreLoginPageContextProps {
|
||||||
setUserId: (id: number) => void;
|
setUserId: (id: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PreLoginPageContext =
|
export const PreLoginPageContext =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue