refactor(v1 cleanup): added in removal of localstoage items from v1

This commit is contained in:
2025-04-21 07:46:24 -05:00
parent b42b8a4c83
commit f44e5a87e7
5 changed files with 57 additions and 7 deletions

View File

@@ -23,6 +23,13 @@ export const SessionProvider = ({
fetchUserRoles();
fetchSubModules();
}, []);
//temp
localStorage.removeItem("ally-supports-cache");
localStorage.removeItem("auth-storage");
localStorage.removeItem("nextauth.message");
localStorage.removeItem("prod");
localStorage.removeItem("card-storage");
return (
<QueryClientProvider client={queryClient}>
{children}

View File

@@ -5,12 +5,6 @@ import { useEffect } from "react";
const fetchSession = async () => {
const token = localStorage.getItem("auth_token");
//temp
localStorage.removeItem("ally-supports-cache");
localStorage.removeItem("auth-storage");
localStorage.removeItem("nextauth.message");
localStorage.removeItem("prod");
if (!token) {
throw new Error("No token found");
}

View File

@@ -43,7 +43,7 @@ export const useCardStore = create<CardStore>()(
cards: state.cards.filter((card) => card.name !== name),
})),
}),
{ name: "card-storage" }
{ name: "cards" }
)
)
);

View File

@@ -31,6 +31,7 @@ import { Route as ocmeCyclecountIndexImport } from './routes/(ocme)/cyclecount/i
import { Route as logisticsSiloAdjustmentsIndexImport } from './routes/(logistics)/siloAdjustments/index'
import { Route as logisticsOpenOrdersIndexImport } from './routes/(logistics)/openOrders/index'
import { Route as logisticsMaterialHelperIndexImport } from './routes/(logistics)/materialHelper/index'
import { Route as logisticsDmIndexImport } from './routes/(logistics)/dm/index'
import { Route as EomArticleAvImport } from './routes/_eom/article/$av'
import { Route as logisticsSiloAdjustmentsHistImport } from './routes/(logistics)/siloAdjustments/$hist'
import { Route as logisticsMaterialHelperSiloLinkIndexImport } from './routes/(logistics)/materialHelper/siloLink/index'
@@ -158,6 +159,12 @@ const logisticsMaterialHelperIndexRoute =
getParentRoute: () => rootRoute,
} as any)
const logisticsDmIndexRoute = logisticsDmIndexImport.update({
id: '/(logistics)/dm/',
path: '/dm/',
getParentRoute: () => rootRoute,
} as any)
const EomArticleAvRoute = EomArticleAvImport.update({
id: '/article/$av',
path: '/article/$av',
@@ -322,6 +329,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof EomArticleAvImport
parentRoute: typeof EomImport
}
'/(logistics)/dm/': {
id: '/(logistics)/dm/'
path: '/dm'
fullPath: '/dm'
preLoaderRoute: typeof logisticsDmIndexImport
parentRoute: typeof rootRoute
}
'/(logistics)/materialHelper/': {
id: '/(logistics)/materialHelper/'
path: '/materialHelper'
@@ -435,6 +449,7 @@ export interface FileRoutesByFullPath {
'/ocp': typeof OcpIndexRoute
'/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
'/article/$av': typeof EomArticleAvRoute
'/dm': typeof logisticsDmIndexRoute
'/materialHelper': typeof logisticsMaterialHelperIndexRoute
'/openOrders': typeof logisticsOpenOrdersIndexRoute
'/siloAdjustments': typeof logisticsSiloAdjustmentsIndexRoute
@@ -461,6 +476,7 @@ export interface FileRoutesByTo {
'/ocp': typeof OcpIndexRoute
'/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
'/article/$av': typeof EomArticleAvRoute
'/dm': typeof logisticsDmIndexRoute
'/materialHelper': typeof logisticsMaterialHelperIndexRoute
'/openOrders': typeof logisticsOpenOrdersIndexRoute
'/siloAdjustments': typeof logisticsSiloAdjustmentsIndexRoute
@@ -490,6 +506,7 @@ export interface FileRoutesById {
'/ocp/': typeof OcpIndexRoute
'/(logistics)/siloAdjustments/$hist': typeof logisticsSiloAdjustmentsHistRoute
'/_eom/article/$av': typeof EomArticleAvRoute
'/(logistics)/dm/': typeof logisticsDmIndexRoute
'/(logistics)/materialHelper/': typeof logisticsMaterialHelperIndexRoute
'/(logistics)/openOrders/': typeof logisticsOpenOrdersIndexRoute
'/(logistics)/siloAdjustments/': typeof logisticsSiloAdjustmentsIndexRoute
@@ -518,6 +535,7 @@ export interface FileRouteTypes {
| '/ocp'
| '/siloAdjustments/$hist'
| '/article/$av'
| '/dm'
| '/materialHelper'
| '/openOrders'
| '/siloAdjustments'
@@ -543,6 +561,7 @@ export interface FileRouteTypes {
| '/ocp'
| '/siloAdjustments/$hist'
| '/article/$av'
| '/dm'
| '/materialHelper'
| '/openOrders'
| '/siloAdjustments'
@@ -570,6 +589,7 @@ export interface FileRouteTypes {
| '/ocp/'
| '/(logistics)/siloAdjustments/$hist'
| '/_eom/article/$av'
| '/(logistics)/dm/'
| '/(logistics)/materialHelper/'
| '/(logistics)/openOrders/'
| '/(logistics)/siloAdjustments/'
@@ -590,6 +610,7 @@ export interface RootRouteChildren {
LoginRoute: typeof LoginRoute
OcpIndexRoute: typeof OcpIndexRoute
logisticsSiloAdjustmentsHistRoute: typeof logisticsSiloAdjustmentsHistRoute
logisticsDmIndexRoute: typeof logisticsDmIndexRoute
logisticsMaterialHelperIndexRoute: typeof logisticsMaterialHelperIndexRoute
logisticsOpenOrdersIndexRoute: typeof logisticsOpenOrdersIndexRoute
logisticsSiloAdjustmentsIndexRoute: typeof logisticsSiloAdjustmentsIndexRoute
@@ -609,6 +630,7 @@ const rootRouteChildren: RootRouteChildren = {
LoginRoute: LoginRoute,
OcpIndexRoute: OcpIndexRoute,
logisticsSiloAdjustmentsHistRoute: logisticsSiloAdjustmentsHistRoute,
logisticsDmIndexRoute: logisticsDmIndexRoute,
logisticsMaterialHelperIndexRoute: logisticsMaterialHelperIndexRoute,
logisticsOpenOrdersIndexRoute: logisticsOpenOrdersIndexRoute,
logisticsSiloAdjustmentsIndexRoute: logisticsSiloAdjustmentsIndexRoute,
@@ -640,6 +662,7 @@ export const routeTree = rootRoute
"/login",
"/ocp/",
"/(logistics)/siloAdjustments/$hist",
"/(logistics)/dm/",
"/(logistics)/materialHelper/",
"/(logistics)/openOrders/",
"/(logistics)/siloAdjustments/",
@@ -727,6 +750,9 @@ export const routeTree = rootRoute
"filePath": "_eom/article/$av.tsx",
"parent": "/_eom"
},
"/(logistics)/dm/": {
"filePath": "(logistics)/dm/index.tsx"
},
"/(logistics)/materialHelper/": {
"filePath": "(logistics)/materialHelper/index.tsx"
},

View File

@@ -0,0 +1,23 @@
import { createFileRoute, redirect } from "@tanstack/react-router";
export const Route = createFileRoute("/(logistics)/dm/")({
component: RouteComponent,
beforeLoad: async () => {
const auth = localStorage.getItem("auth_token");
if (!auth) {
throw redirect({
to: "/login",
search: {
// Use the current location to power a redirect after login
// (Do not use `router.state.resolvedLocation` as it can
// potentially lag behind the actual current location)
redirect: location.pathname + location.search,
},
});
}
},
});
function RouteComponent() {
return <div>Hello "/(logistics)/dm/"!</div>;
}