Planificateur « Suggérer » : 4 stratégies (smart / meilleurs d'abord / équilibré / juste ce qu'il faut), compétences+niveaux par tech (édition inline), niveau requis par compétence + par job, carte des tournées (1 couleur/tech, domicile→arrêts, sélecteur de jour), fenêtre de dispatch auj.+demain (dates sélectionnées), règle week-end + placeholder « en attente du quart », clustering + lasso + filtre-date sur la carte, accès rapide « À assigner » (badge). Boîte : liste /conversations allégée (45 Mo → ~1 Mo, 17×) + messages chargés à l'ouverture. Rapports : cache SWR sur revenue-explorer (22×). Session : keep-alive + timeout fetch global + authFetch durci → fin des rechargements manuels. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
36 lines
1.5 KiB
JavaScript
36 lines
1.5 KiB
JavaScript
/**
|
|
* api/billing.js — Client for Hub /billing approval endpoints (P1).
|
|
*
|
|
* Porte d'approbation de facturation : lister les installations complétées en
|
|
* attente, prévisualiser le prorata (LECTURE SEULE), approuver (= active le
|
|
* service ; la facturation reste gatée côté hub par PRORATION_WRITE).
|
|
*/
|
|
import { HUB_URL } from 'src/config/hub'
|
|
|
|
async function hubFetch (path, { method = 'GET', body } = {}) {
|
|
const opts = { method, headers: { 'Content-Type': 'application/json' } }
|
|
if (body) opts.body = JSON.stringify(body)
|
|
const res = await fetch(`${HUB_URL}${path}`, opts)
|
|
const text = await res.text()
|
|
let data
|
|
try { data = text ? JSON.parse(text) : {} } catch { throw new Error(`Invalid JSON from ${path}: ${text.slice(0, 200)}`) }
|
|
if (!res.ok) { const err = new Error(data.error || `HTTP ${res.status}`); err.status = res.status; throw err }
|
|
return data
|
|
}
|
|
|
|
// Activations en attente d'approbation (enrichies client + adresse).
|
|
export function getApprovals () {
|
|
return hubFetch('/billing/approvals').then(r => r.pending || [])
|
|
}
|
|
|
|
// Aperçu prorata consolidé pour un job (LECTURE SEULE — aucune facture créée).
|
|
export function getApprovalPreview (job) {
|
|
return hubFetch(`/billing/approvals/preview?job=${encodeURIComponent(job)}`)
|
|
}
|
|
|
|
// Approuve → active les abonnements. L'approbateur est attribué côté serveur
|
|
// (en-tête x-authentik-email). La facturation reste gatée (PRORATION_WRITE).
|
|
export function approveActivation (job) {
|
|
return hubFetch('/billing/approvals/approve', { method: 'POST', body: { job } })
|
|
}
|