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";
|
||||
|
||||
function App() {
|
||||
const locallyStoredUserId = window.localStorage.getItem("paysplit-user-id");
|
||||
const locallyStoredUserIdAsNumber = locallyStoredUserId
|
||||
? parseInt(locallyStoredUserId)
|
||||
: null;
|
||||
const [userId, setUserId] = useState<number | null>(
|
||||
locallyStoredUserIdAsNumber,
|
||||
const [userId, setUserId] = useState<string | null>(
|
||||
window.localStorage.getItem("paysplit-user-id")
|
||||
);
|
||||
const storeUserId = (id: number) => {
|
||||
const storeUserId = (id: string) => {
|
||||
window.localStorage.setItem("paysplit-user-id", id.toString());
|
||||
setUserId(id);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import axios, { type AxiosResponse } from "axios";
|
||||
|
||||
interface AccessResponse {
|
||||
userId: number;
|
||||
userId: string;
|
||||
}
|
||||
|
||||
export const login = (name: string, password: string) =>
|
||||
|
|
@ -16,12 +16,12 @@ export const registerUser = (name: string, password: string) =>
|
|||
password,
|
||||
}) 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<
|
||||
AxiosResponse<{ url: string }, unknown, {}>
|
||||
>;
|
||||
|
||||
export const completeBuyFlow = (userId: number) =>
|
||||
export const completeBuyFlow = (userId: string) =>
|
||||
axios.post("/buy/complete", { userId }) as Promise<
|
||||
AxiosResponse<{ url: string }, unknown, {}>
|
||||
>;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { createContext } from "react";
|
||||
|
||||
interface LoggedInPageContextProps {
|
||||
userId: number;
|
||||
userId: string;
|
||||
}
|
||||
|
||||
export const LoggedInPageContext =
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { createContext } from "react";
|
||||
|
||||
interface PreLoginPageContextProps {
|
||||
setUserId: (id: number) => void;
|
||||
setUserId: (id: string) => void;
|
||||
}
|
||||
|
||||
export const PreLoginPageContext =
|
||||
|
|
|
|||
Loading…
Reference in New Issue