diff --git a/src/app/components/header/header.html b/src/app/components/header/header.html index 64460f7..d2db4f6 100644 --- a/src/app/components/header/header.html +++ b/src/app/components/header/header.html @@ -15,8 +15,8 @@ - - + +
LineGestão @@ -44,20 +44,30 @@
- -
+ + - - + + - -
-
-
- - -
-
-
@@ -195,6 +186,17 @@
+
+
+ + +
+
+ + + diff --git a/src/app/pages/home/home.scss b/src/app/pages/home/home.scss index e7dcede..af6de79 100644 --- a/src/app/pages/home/home.scss +++ b/src/app/pages/home/home.scss @@ -467,7 +467,7 @@ /* faixa de valores */ .value-strip { - margin-top: 26px; + margin-top: 50px; padding: 14px 16px; border-radius: var(--radius-xl); background: rgba(255, 255, 255, 0.80); diff --git a/src/app/pages/login/login.ts b/src/app/pages/login/login.ts index 53af01b..9371e74 100644 --- a/src/app/pages/login/login.ts +++ b/src/app/pages/login/login.ts @@ -59,6 +59,15 @@ export class LoginComponent { } } + private saveToken(token: string) { + // ✅ SSR-safe + if (!isPlatformBrowser(this.platformId)) return; + + // evita token antigo conflitar + localStorage.removeItem('token'); + localStorage.setItem('token', token); + } + onSubmit(): void { this.apiError = ''; @@ -77,10 +86,19 @@ export class LoginComponent { }; this.authService.login(payload).subscribe({ - next: (res) => { + next: async (res) => { this.isSubmitting = false; - const nome = this.getNameFromToken(res.token); + const token = res?.token; + if (!token) { + this.apiError = 'Login retornou sem token. Verifique a resposta da API.'; + return; + } + + // ✅ salva token para o Interceptor anexar nas próximas requisições + this.saveToken(token); + + const nome = this.getNameFromToken(token); // ✅ Vai para /geral já levando a mensagem do toast this.router.navigate(['/geral'], { diff --git a/src/app/services/lines.service.ts b/src/app/services/lines.service.ts new file mode 100644 index 0000000..db73ffa --- /dev/null +++ b/src/app/services/lines.service.ts @@ -0,0 +1,86 @@ +import { HttpClient, HttpParams } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; + +export interface PagedResult { + page: number; + pageSize: number; + total: number; + items: T[]; +} + +export interface MobileLineList { + id: string; + item: number; + conta: string | null; + linha: string | null; + chip: string | null; + cliente: string | null; + usuario: string | null; + planoContrato: string | null; + status: string | null; + skil: string | null; + modalidade: string | null; + vencConta: string | null; +} + +export interface MobileLineDetail extends MobileLineList { + franquiaVivo?: number | null; + valorPlanoVivo?: number | null; + gestaoVozDados?: number | null; + skeelo?: number | null; + vivoNewsPlus?: number | null; + vivoTravelMundo?: number | null; + vivoGestaoDispositivo?: number | null; + valorContratoVivo?: number | null; + + franquiaLine?: number | null; + franquiaGestao?: number | null; + locacaoAp?: number | null; + valorContratoLine?: number | null; + + desconto?: number | null; + lucro?: number | null; + + dataBloqueio?: string | null; + cedente?: string | null; + solicitante?: string | null; + dataEntregaOpera?: string | null; + dataEntregaCliente?: string | null; +} + +@Injectable({ providedIn: 'root' }) +export class LinesService { + // ajuste aqui conforme sua API (mesmo host do auth) + private baseUrl = 'http://localhost:5000/api/lines'; + + constructor(private http: HttpClient) {} + + getLines(page: number, pageSize: number, search: string): Observable> { + let params = new HttpParams() + .set('page', page) + .set('pageSize', pageSize); + + if (search?.trim()) params = params.set('search', search.trim()); + + return this.http.get>(this.baseUrl, { params }); + } + + getById(id: string): Observable { + return this.http.get(`${this.baseUrl}/${id}`); + } + + update(id: string, payload: any): Observable { + return this.http.put(`${this.baseUrl}/${id}`, payload); + } + + delete(id: string): Observable { + return this.http.delete(`${this.baseUrl}/${id}`); + } + + importExcel(file: File): Observable<{ imported: number }> { + const form = new FormData(); + form.append('file', file); + return this.http.post<{ imported: number }>(`${this.baseUrl}/import-excel`, form); + } +}