chore: remove portal from admin app — extracted to fiberops-portal (FIBEROPS-249)
- Delete app/(portal)/ route group (login, dashboard, invoices, tickets) - Delete lib/portal-api.ts and lib/portal-auth-store.ts - Remove Phase 9 portal tests (17–22) from business-flow E2E spec - Keep portalAccessEnabled in Client type and admin client profile view
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const portalApi = axios.create({
|
||||
baseURL: process.env.NEXT_PUBLIC_API_URL || 'http://192.168.1.167:3001',
|
||||
});
|
||||
|
||||
portalApi.interceptors.request.use((config) => {
|
||||
if (typeof window !== 'undefined') {
|
||||
const token = localStorage.getItem('portal_token');
|
||||
const authRaw = localStorage.getItem('portal_auth');
|
||||
const tenantSlug = authRaw ? JSON.parse(authRaw)?.state?.tenantSlug : null;
|
||||
if (token) config.headers.Authorization = `Bearer ${token}`;
|
||||
if (tenantSlug) {
|
||||
config.headers['x-tenant-slug'] = tenantSlug;
|
||||
config.headers['X-Tenant-Slug'] = tenantSlug;
|
||||
}
|
||||
}
|
||||
return config;
|
||||
});
|
||||
|
||||
portalApi.interceptors.response.use(
|
||||
(res) => res,
|
||||
(err) => {
|
||||
if (err.response?.status === 401 && typeof window !== 'undefined') {
|
||||
localStorage.removeItem('portal_token');
|
||||
localStorage.removeItem('portal_auth');
|
||||
window.location.href = '/portal/login';
|
||||
}
|
||||
return Promise.reject(err);
|
||||
}
|
||||
);
|
||||
|
||||
export default portalApi;
|
||||
@@ -1,49 +0,0 @@
|
||||
import { create } from 'zustand';
|
||||
import { persist } from 'zustand/middleware';
|
||||
import portalApi from './portal-api';
|
||||
|
||||
interface PortalSubscriber {
|
||||
accountNumber: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}
|
||||
|
||||
interface PortalAuthState {
|
||||
subscriber: PortalSubscriber | null;
|
||||
portalToken: string | null;
|
||||
tenantSlug: string | null;
|
||||
isAuthenticated: boolean;
|
||||
login: (tenantSlug: string, accountNumber: string, password: string) => Promise<void>;
|
||||
logout: () => void;
|
||||
}
|
||||
|
||||
export const usePortalAuthStore = create<PortalAuthState>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
subscriber: null,
|
||||
portalToken: null,
|
||||
tenantSlug: null,
|
||||
isAuthenticated: false,
|
||||
login: async (tenantSlug, accountNumber, password) => {
|
||||
const res = await portalApi.post('/api/v1/portal/auth/login', {
|
||||
tenantSlug,
|
||||
accountNumber,
|
||||
password,
|
||||
});
|
||||
const { accessToken } = res.data;
|
||||
localStorage.setItem('portal_token', accessToken);
|
||||
set({
|
||||
portalToken: accessToken,
|
||||
tenantSlug,
|
||||
subscriber: { accountNumber, firstName: '', lastName: '' },
|
||||
isAuthenticated: true,
|
||||
});
|
||||
},
|
||||
logout: () => {
|
||||
localStorage.removeItem('portal_token');
|
||||
set({ subscriber: null, portalToken: null, tenantSlug: null, isAuthenticated: false });
|
||||
},
|
||||
}),
|
||||
{ name: 'portal_auth' }
|
||||
)
|
||||
);
|
||||
Reference in New Issue
Block a user