Transform userId into UUID format

main
MiguelMLorente 2025-11-30 20:32:33 +01:00
parent 44b3ef8b70
commit ad28e29e85
4 changed files with 8 additions and 12 deletions

View File

@ -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);
}; };

View File

@ -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, {}>
>; >;

View File

@ -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 =

View File

@ -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 =