@airporting/tech-app 0.0.125 → 0.0.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/mf/{5429.15b34dd118.js → 5429.61cff3da77.js} +1 -1
  2. package/dist/mf/{6755.3b2751c6d2.js → 6755.4779da6101.js} +1 -1
  3. package/dist/mf/{9698.5ba81b4ca1.css → 9698.3008e872db.css} +73 -73
  4. package/dist/mf/@mf-types/compiled-types/api/tech/sales/createDealMutation.d.ts +10 -0
  5. package/dist/mf/@mf-types/compiled-types/api/tech/sales/dealsQuery.d.ts +2 -0
  6. package/dist/mf/@mf-types/compiled-types/api/tech/sales/deleteDealMutation.d.ts +1 -0
  7. package/dist/mf/@mf-types/compiled-types/api/tech/sales/updateDealMutation.d.ts +11 -0
  8. package/dist/mf/@mf-types/compiled-types/apps/pipeline/DealCard.d.ts +8 -0
  9. package/dist/mf/@mf-types/compiled-types/apps/pipeline/DealDetailDrawer.d.ts +8 -0
  10. package/dist/mf/@mf-types/compiled-types/apps/pipeline/DealsTable.d.ts +9 -0
  11. package/dist/mf/@mf-types/compiled-types/apps/pipeline/KanbanBoard.d.ts +8 -0
  12. package/dist/mf/@mf-types/compiled-types/apps/pipeline/NewDealModal.d.ts +8 -0
  13. package/dist/mf/@mf-types/compiled-types/apps/pipeline/format.d.ts +3 -0
  14. package/dist/mf/@mf-types/compiled-types/apps/pipeline/types.d.ts +37 -0
  15. package/dist/mf/@mf-types/compiled-types/apps/pipeline.app.d.ts +1 -0
  16. package/dist/mf/@mf-types/compiled-types/gen/TechApi/index.d.ts +171 -0
  17. package/dist/mf/@mf-types/compiled-types/tabs/pipeline.d.ts +2 -0
  18. package/dist/mf/__federation_expose_pipeline.48dbe478c4.js +10 -0
  19. package/dist/mf/__federation_expose_sales.792debdfc0.js +10 -0
  20. package/dist/mf/__federation_expose_sales.792debdfc0.js.LICENSE.txt +9 -0
  21. package/dist/mf/{index.f916e4edb7.js → index.26a8175ef8.js} +3 -3
  22. package/dist/mf/mf-manifest.json +75 -42
  23. package/dist/mf/mf-stats.json +96 -46
  24. package/dist/mf/{tech_app.8abb0b0510.js → tech_app.b6f1ed84aa.js} +3 -3
  25. package/package.json +1 -1
  26. package/dist/mf/__federation_expose_sales.b781a94a8a.js +0 -10
  27. /package/dist/mf/{__federation_expose_sales.b781a94a8a.js.LICENSE.txt → __federation_expose_pipeline.48dbe478c4.js.LICENSE.txt} +0 -0
@@ -0,0 +1,37 @@
1
+ import { Temperature } from '@/src/apps/sales/types.ts';
2
+ export type SalesPipeline = 'new_business' | 'upsell';
3
+ export type DealStatus = 'open' | 'won' | 'lost';
4
+ export type DealStageItem = {
5
+ id: number;
6
+ name: string;
7
+ order_nr: number;
8
+ deal_count: number;
9
+ total_value: number;
10
+ };
11
+ export type DealLead = {
12
+ id: number;
13
+ first_name: string | null;
14
+ last_name: string | null;
15
+ company: string | null;
16
+ temperature: Temperature;
17
+ };
18
+ export type DealItem = {
19
+ id: number;
20
+ title: string;
21
+ value: number;
22
+ currency: string;
23
+ status: DealStatus;
24
+ probability: number | null;
25
+ expected_close_date: string | null;
26
+ stage_id: number;
27
+ won_at: string | null;
28
+ lost_at: string | null;
29
+ lost_reason: string | null;
30
+ created_at: string;
31
+ updated_at: string;
32
+ lead: DealLead;
33
+ };
34
+ export type DealsResponse = {
35
+ stages: DealStageItem[];
36
+ deals: DealItem[];
37
+ };
@@ -0,0 +1 @@
1
+ export declare function PipelineApp(): import("react").JSX.Element;
@@ -13,6 +13,18 @@ export interface CompanyItem {
13
13
  display_name: string | null;
14
14
  id: number;
15
15
  }
16
+ export interface CreateSalesDealBody {
17
+ currency?: string;
18
+ expected_close_date?: string | null;
19
+ lead_id: number;
20
+ probability?: number | null;
21
+ stage_id: number;
22
+ title: string;
23
+ value?: number;
24
+ }
25
+ export interface CreateSalesDealResponse {
26
+ id: number;
27
+ }
16
28
  export interface CreateSalesLeadBody {
17
29
  company?: string | null;
18
30
  emails?: string[];
@@ -28,6 +40,9 @@ export interface CreateSalesLeadResponse {
28
40
  attached: boolean;
29
41
  id: number;
30
42
  }
43
+ export interface DeleteDealV1Params {
44
+ id: number;
45
+ }
31
46
  export interface DeleteFinanceJobsRedisLockResponse {
32
47
  existed: boolean;
33
48
  key: string;
@@ -382,6 +397,10 @@ export interface GetPayfitDashboardResponse {
382
397
  export interface GetRunStatsResponse {
383
398
  currentJobsCounters: UsersRunStatsResponse;
384
399
  }
400
+ export interface GetSalesDealsResponse {
401
+ deals: SalesDealItem[];
402
+ stages: SalesDealStageItem[];
403
+ }
385
404
  export interface GetSalesLeadResponse {
386
405
  company: string | null;
387
406
  first_name: string | null;
@@ -498,6 +517,10 @@ export interface ListFinanceJobsTasksResponse {
498
517
  items: FinanceJobsTaskItem[];
499
518
  total: number;
500
519
  }
520
+ export interface ListDealsV1Params {
521
+ pipeline: string;
522
+ status: string;
523
+ }
501
524
  export interface ListGsheetTasksResponse {
502
525
  items: GsheetTaskItem[];
503
526
  total: number;
@@ -584,6 +607,36 @@ export interface RunRecipeResponse {
584
607
  message?: string;
585
608
  ok: boolean;
586
609
  }
610
+ export interface SalesDealItem {
611
+ created_at: string;
612
+ currency: string;
613
+ expected_close_date: string | null;
614
+ id: number;
615
+ lead: SalesDealLeadItem;
616
+ lost_at: string | null;
617
+ lost_reason: string | null;
618
+ probability: number | null;
619
+ stage_id: number;
620
+ status: string;
621
+ title: string;
622
+ updated_at: string;
623
+ value: number;
624
+ won_at: string | null;
625
+ }
626
+ export interface SalesDealLeadItem {
627
+ company: string | null;
628
+ first_name: string | null;
629
+ id: number;
630
+ last_name: string | null;
631
+ temperature: string;
632
+ }
633
+ export interface SalesDealStageItem {
634
+ deal_count: number;
635
+ id: number;
636
+ name: string;
637
+ order_nr: number;
638
+ total_value: number;
639
+ }
587
640
  export interface SalesIdentityItem {
588
641
  type: string;
589
642
  value: string;
@@ -745,9 +798,22 @@ export interface UnstickV1Params {
745
798
  export interface UnstickV1Params2 {
746
799
  id: number;
747
800
  }
801
+ export interface UpdateDealV1Params {
802
+ id: number;
803
+ }
748
804
  export interface UpdateLeadV1Params {
749
805
  id: number;
750
806
  }
807
+ export interface UpdateSalesDealBody {
808
+ currency?: string;
809
+ expected_close_date?: string | null;
810
+ lost_reason?: string | null;
811
+ probability?: number | null;
812
+ stage_id?: number;
813
+ status?: string;
814
+ title?: string;
815
+ value?: number;
816
+ }
751
817
  export interface UpdateSalesLeadBody {
752
818
  company?: string | null;
753
819
  emails?: string[];
@@ -1092,6 +1158,75 @@ export declare namespace Sales {
1092
1158
  type RequestHeaders = {};
1093
1159
  type ResponseBody = ScanRunSummaryResponse;
1094
1160
  }
1161
+ /**
1162
+ * No description
1163
+ * @tags Sales
1164
+ * @name ListDealsV1
1165
+ * @request GET:/v1/sales/deals
1166
+ * @response `200` `GetSalesDealsResponse`
1167
+ */
1168
+ namespace ListDealsV1 {
1169
+ type RequestParams = {};
1170
+ type RequestQuery = {
1171
+ pipeline: string;
1172
+ status: string;
1173
+ };
1174
+ type RequestBody = never;
1175
+ type RequestHeaders = {};
1176
+ type ResponseBody = GetSalesDealsResponse;
1177
+ }
1178
+ /**
1179
+ * No description
1180
+ * @tags Sales
1181
+ * @name CreateDealV1
1182
+ * @request POST:/v1/sales/deals
1183
+ * @response `201` `CreateSalesDealResponse`
1184
+ */
1185
+ namespace CreateDealV1 {
1186
+ type RequestParams = {};
1187
+ type RequestQuery = {};
1188
+ type RequestBody = CreateSalesDealBody;
1189
+ type RequestHeaders = {
1190
+ from: string;
1191
+ };
1192
+ type ResponseBody = CreateSalesDealResponse;
1193
+ }
1194
+ /**
1195
+ * No description
1196
+ * @tags Sales
1197
+ * @name UpdateDealV1
1198
+ * @request PATCH:/v1/sales/deals/{id}
1199
+ * @response `200` `OkResponse`
1200
+ */
1201
+ namespace UpdateDealV1 {
1202
+ type RequestParams = {
1203
+ id: number;
1204
+ };
1205
+ type RequestQuery = {};
1206
+ type RequestBody = UpdateSalesDealBody;
1207
+ type RequestHeaders = {
1208
+ from: string;
1209
+ };
1210
+ type ResponseBody = OkResponse;
1211
+ }
1212
+ /**
1213
+ * No description
1214
+ * @tags Sales
1215
+ * @name DeleteDealV1
1216
+ * @request DELETE:/v1/sales/deals/{id}
1217
+ * @response `200` `OkResponse`
1218
+ */
1219
+ namespace DeleteDealV1 {
1220
+ type RequestParams = {
1221
+ id: number;
1222
+ };
1223
+ type RequestQuery = {};
1224
+ type RequestBody = never;
1225
+ type RequestHeaders = {
1226
+ from: string;
1227
+ };
1228
+ type ResponseBody = OkResponse;
1229
+ }
1095
1230
  }
1096
1231
  export declare namespace FinanceJobs {
1097
1232
  /**
@@ -1878,6 +2013,42 @@ export declare class TechApi<SecurityDataType extends unknown> {
1878
2013
  * @response `200` `ScanRunSummaryResponse`
1879
2014
  */
1880
2015
  scanRunSummaryV1: (params?: RequestParams) => Promise<HttpResponse<ScanRunSummaryResponse, any>>;
2016
+ /**
2017
+ * No description
2018
+ *
2019
+ * @tags Sales
2020
+ * @name ListDealsV1
2021
+ * @request GET:/v1/sales/deals
2022
+ * @response `200` `GetSalesDealsResponse`
2023
+ */
2024
+ listDealsV1: (query: ListDealsV1Params, params?: RequestParams) => Promise<HttpResponse<GetSalesDealsResponse, any>>;
2025
+ /**
2026
+ * No description
2027
+ *
2028
+ * @tags Sales
2029
+ * @name CreateDealV1
2030
+ * @request POST:/v1/sales/deals
2031
+ * @response `201` `CreateSalesDealResponse`
2032
+ */
2033
+ createDealV1: (data: CreateSalesDealBody, params?: RequestParams) => Promise<HttpResponse<CreateSalesDealResponse, any>>;
2034
+ /**
2035
+ * No description
2036
+ *
2037
+ * @tags Sales
2038
+ * @name UpdateDealV1
2039
+ * @request PATCH:/v1/sales/deals/{id}
2040
+ * @response `200` `OkResponse`
2041
+ */
2042
+ updateDealV1: ({ id, ...query }: UpdateDealV1Params, data: UpdateSalesDealBody, params?: RequestParams) => Promise<HttpResponse<OkResponse, any>>;
2043
+ /**
2044
+ * No description
2045
+ *
2046
+ * @tags Sales
2047
+ * @name DeleteDealV1
2048
+ * @request DELETE:/v1/sales/deals/{id}
2049
+ * @response `200` `OkResponse`
2050
+ */
2051
+ deleteDealV1: ({ id, ...query }: DeleteDealV1Params, params?: RequestParams) => Promise<HttpResponse<OkResponse, any>>;
1881
2052
  };
1882
2053
  financeJobs: {
1883
2054
  /**
@@ -0,0 +1,2 @@
1
+ import { ProvidersProps } from '../providers.tsx';
2
+ export default function Pipeline(props: ProvidersProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ /*! LICENSE: __federation_expose_pipeline.48dbe478c4.js.LICENSE.txt */
2
+ "use strict";(globalThis["chunk_tech_app "]||=[]).push([[3767],{9698(__unused_rspack_module,exports){/**
3
+ * @license React
4
+ * react-jsx-runtime.production.js
5
+ *
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element"),REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");function jsxProd(type,config,maybeKey){var key=null;void 0!==maybeKey&&(key=""+maybeKey);void 0!==config.key&&(key=""+config.key);if("key"in config){maybeKey={};for(var propName in config)"key"!==propName&&(maybeKey[propName]=config[propName])}else maybeKey=config;config=maybeKey.ref;return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:key,ref:void 0!==config?config:null,props:maybeKey}}exports.Fragment=REACT_FRAGMENT_TYPE;exports.jsx=jsxProd;exports.jsxs=jsxProd},4848(module,__unused_rspack_exports,__webpack_require__){module.exports=__webpack_require__(9698)},6032(__unused_rspack_module,__webpack_exports__,__webpack_require__){var _tanstack_react_query__rspack_import_0=__webpack_require__(3411);var _useApi_ts__rspack_import_1=__webpack_require__(4691);function useSalesLeads(status){const api=(0,_useApi_ts__rspack_import_1.g)();return(0,_tanstack_react_query__rspack_import_0.useQuery)({queryKey:["tech","sales","leads",status],queryFn:async()=>(await api.sales.listLeadsV1({status})).data,refetchOnWindowFocus:true})}__webpack_require__.d(__webpack_exports__,{p:()=>useSalesLeads})},7510(__unused_rspack_module,__webpack_exports__,__webpack_require__){const TEMPERATURE_META={burning:{emoji:"🔥🔥",label:"Brûlant",order:5},hot:{emoji:"🔥",label:"Chaud",order:4},warm:{emoji:"🌡️",label:"Tiède",order:3},cold:{emoji:"❄️",label:"Froid",order:2},frozen:{emoji:"🧊",label:"Gelé",order:1}};const TEMPERATURE_ORDER=["burning","hot","warm","cold","frozen"];__webpack_require__.d(__webpack_exports__,{},{E:TEMPERATURE_ORDER,z:TEMPERATURE_META})},905(__unused_rspack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Pipeline});var jsx_runtime=__webpack_require__(4848);var index_js_=__webpack_require__(814);var providers=__webpack_require__(9528);var index_mjs_=__webpack_require__(4618);var esm_index_mjs_=__webpack_require__(1810);var modern_index_js_=__webpack_require__(3411);var useApi=__webpack_require__(4691);function useSalesDeals(pipeline,status){const api=(0,useApi.g)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sales","deals",pipeline,status],queryFn:async()=>(await api.sales.listDealsV1({pipeline,status})).data,refetchOnWindowFocus:true})}var dates_esm_index_mjs_=__webpack_require__(2506);var notifications_esm_index_mjs_=__webpack_require__(7250);function useDeleteDeal(){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.sales.deleteDealV1({id})).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Deal supprimé",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"Échec de la suppression",color:"red"})}})}function useUpdateDeal(id){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async payload=>(await api.sales.updateDealV1({id},payload)).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Modifications enregistrées",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"Échec de la mise à jour",color:"red"})}})}const eurFormatter=new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR",maximumFractionDigits:0});const dayFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:"Europe/Paris",day:"2-digit",month:"2-digit",year:"numeric"});function formatEur(value){if(Number.isNaN(value))return eurFormatter.format(0);return eurFormatter.format(value)}function formatAmount(value,currency){if("EUR"===currency||""===currency)return formatEur(value);return new Intl.NumberFormat("fr-FR",{style:"currency",currency,maximumFractionDigits:0}).format(value)}function formatDay(iso){if(null===iso)return"";const date=new Date(iso);if(Number.isNaN(date.getTime()))return"";return dayFormatter.format(date)}var temperature=__webpack_require__(7510);const STATUS_META={open:{label:"Ouvert",color:"blue"},won:{label:"Gagné",color:"green"},lost:{label:"Perdu",color:"red"}};function personLabel(deal){const parts=[deal.lead.first_name,deal.lead.last_name].filter(Boolean);return parts.join(" ")}function DealDetailForm({deal,stages,onClose}){const update=useUpdateDeal(deal.id);const remove=useDeleteDeal();const[title,setTitle]=(0,index_js_.useState)(deal.title);const[value,setValue]=(0,index_js_.useState)(deal.value);const[probability,setProbability]=(0,index_js_.useState)(null===deal.probability?"":deal.probability);const[expectedCloseDate,setExpectedCloseDate]=(0,index_js_.useState)(deal.expected_close_date??"");const[stageId,setStageId]=(0,index_js_.useState)(String(deal.stage_id));const[lostReason,setLostReason]=(0,index_js_.useState)(deal.lost_reason??"");const statusMeta=STATUS_META[deal.status];function save(){update.mutate({title,value:""===value?0:Number(value),probability:""===probability?null:Number(probability),expected_close_date:""===expectedCloseDate?null:expectedCloseDate,stage_id:null===stageId?void 0:Number(stageId)})}function markWon(){update.mutate({status:"won"},{onSuccess:onClose})}function markLost(){update.mutate({status:"lost",lost_reason:""===lostReason?null:lostReason},{onSuccess:onClose})}function reopen(){update.mutate({status:"open"},{onSuccess:onClose})}function handleDelete(){remove.mutate(deal.id,{onSuccess:onClose})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[statusMeta?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:statusMeta.color,children:statusMeta.label}):null,"won"===deal.status&&null!==deal.won_at?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:`Gagn\xe9 le ${formatDay(deal.won_at)}`}):null,"lost"===deal.status&&null!==deal.lost_at?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:`Perdu le ${formatDay(deal.lost_at)}`}):null]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:`${temperature.z[deal.lead.temperature]?.emoji??""} ${personLabel(deal)}`.trim()}),deal.lead.company?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:deal.lead.company}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Anchor,{href:"/console/sales",size:"sm",children:"Voir le lead"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Titre",value:title,onChange:e=>setTitle(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Montant",value:value,onChange:setValue,min:0,thousandSeparator:" ",decimalSeparator:",",suffix:` ${deal.currency}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Probabilité (%)",value:probability,onChange:setProbability,min:0,max:100})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(dates_esm_index_mjs_.DateInput,{label:"Échéance",placeholder:"Pas de date fixée",clearable:true,valueFormat:"DD/MM/YYYY",value:expectedCloseDate?new Date(expectedCloseDate):null,onChange:v=>setExpectedCloseDate(v?new Date(v).toISOString():"")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Étape",data:stages.map(s=>({value:String(s.id),label:s.name})),value:stageId,onChange:setStageId}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",variant:"light",onClick:handleDelete,children:"Supprimer"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:update.isPending,onClick:save,children:"Enregistrer"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{mt:"md"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,children:"Statut"}),"open"===deal.status?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Raison de la perte (optionnelle)",value:lostReason,onChange:e=>setLostReason(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",variant:"light",loading:update.isPending,onClick:markLost,children:"Perdu"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"green",loading:update.isPending,onClick:markWon,children:"Gagné"})]})]}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",loading:update.isPending,onClick:reopen,children:"Rouvrir"})})]})}function DealDetailDrawer({deal,stages,onClose}){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Drawer,{opened:null!==deal,onClose:onClose,position:"right",size:"lg",title:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,children:"Deal"}),children:deal?/*#__PURE__*/(0,jsx_runtime.jsx)(DealDetailForm,{deal:deal,stages:stages,onClose:onClose},deal.id):null})}function stageName(stages,stageId){const stage=stages.find(s=>s.id===stageId);if(!stage)return"";return stage.name}function DealsTable({deals,stages,status,onRowClick}){const isLost="lost"===status;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Titre"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Montant"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:isLost?"Perdu le":"Gagné le"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Étape"}),isLost?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Raison"}):null]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:deals.map(deal=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{style:{cursor:"pointer"},onClick:()=>onRowClick(deal.id),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:deal.title}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:deal.lead.company??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:formatAmount(deal.value,deal.currency)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:formatDay(isLost?deal.lost_at:deal.won_at)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:stageName(stages,deal.stage_id)}),isLost?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:deal.lost_reason?void 0:"dimmed",children:deal.lost_reason??"Non renseignée"})}):null]},deal.id))})]})}var tabler_icons_react_mjs_=__webpack_require__(2638);function DealCard_personLabel(deal){const parts=[deal.lead.first_name,deal.lead.last_name].filter(Boolean);return parts.join(" ")}function DealCard({deal,stages,onOpen}){const update=useUpdateDeal(deal.id);const index=stages.findIndex(s=>s.id===deal.stage_id);const previous=index>0?stages[index-1]:null;const next=index>=0&&index<stages.length-1?stages[index+1]:null;function move(target){if(null===target)return;update.mutate({stage_id:target.id})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,padding:"sm",radius:"md",style:{cursor:"pointer"},onClick:()=>onOpen(deal.id),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:6,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",align:"flex-start",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:500,size:"sm",lineClamp:2,children:deal.title}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"blue",children:formatAmount(deal.value,deal.currency)})]}),deal.lead.company?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:deal.lead.company}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:`${temperature.z[deal.lead.temperature]?.emoji??""} ${DealCard_personLabel(deal)}`.trim()}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[null!==deal.probability?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"gray",size:"sm",children:`${deal.probability} %`}):null,null!==deal.expected_close_date?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"gray",size:"sm",children:`\xc9ch\xe9ance : ${formatDay(deal.expected_close_date)}`}):null]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",size:"sm","aria-label":"Étape précédente",disabled:null===previous||update.isPending,onClick:e=>{e.stopPropagation();move(previous)},children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronLeft,{size:16})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",size:"sm","aria-label":"Étape suivante",disabled:null===next||update.isPending,onClick:e=>{e.stopPropagation();move(next)},children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronRight,{size:16})})]})]})})}function KanbanBoard({stages,deals,onOpen}){if(0===stages.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:"Aucune étape configurée pour ce pipeline"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Box,{style:{display:"flex",gap:"var(--mantine-spacing-md)",alignItems:"flex-start",overflowX:"auto",paddingBottom:"var(--mantine-spacing-sm)"},children:stages.map(stage=>{const stageDeals=deals.filter(d=>d.stage_id===stage.id);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"sm",style:{flex:"0 0 300px",width:300},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,size:"sm",children:stage.name}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"gray",children:stage.deal_count})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:formatEur(stage.total_value)})]}),0===stageDeals.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:"Aucun deal"}):null,stageDeals.map(deal=>/*#__PURE__*/(0,jsx_runtime.jsx)(DealCard,{deal:deal,stages:stages,onOpen:onOpen},deal.id))]})},stage.id)})})}function useCreateDeal(){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async payload=>(await api.sales.createDealV1(payload)).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Deal créé",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"Échec de la création",color:"red"})}})}var leadsQuery=__webpack_require__(6032);function leadLabel(lead){const name=[lead.first_name,lead.last_name].filter(Boolean).join(" ");if(lead.company&&name)return`${name} (${lead.company})`;if(lead.company)return lead.company;if(name)return name;return`Lead ${lead.id}`}function NewDealForm({onClose,stages}){const leads=(0,leadsQuery.p)("active");const create=useCreateDeal();const[leadId,setLeadId]=(0,index_js_.useState)(null);const[title,setTitle]=(0,index_js_.useState)("");const[value,setValue]=(0,index_js_.useState)("");const[stageId,setStageId]=(0,index_js_.useState)(stages.length>0?String(stages[0].id):null);function submit(){if(null===leadId||null===stageId||""===title.trim())return void notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Renseignez un lead, un titre et une étape",color:"orange"});create.mutate({lead_id:Number(leadId),stage_id:Number(stageId),title:title.trim(),value:""===value?0:Number(value),currency:"EUR"},{onSuccess:onClose})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Lead",placeholder:"Rechercher un lead",searchable:true,nothingFoundMessage:"Aucun lead",data:(leads.data?.leads??[]).map(l=>({value:String(l.id),label:leadLabel(l)})),value:leadId,onChange:setLeadId}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Titre",value:title,onChange:e=>setTitle(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Montant (EUR)",value:value,onChange:setValue,min:0,thousandSeparator:" ",decimalSeparator:","}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Étape",data:stages.map(s=>({value:String(s.id),label:s.name})),value:stageId,onChange:setStageId}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:onClose,children:"Annuler"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:create.isPending,onClick:submit,children:"Créer"})]})]})}function NewDealModal({opened,onClose,stages}){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:opened,onClose:onClose,title:"Nouveau deal",children:opened?/*#__PURE__*/(0,jsx_runtime.jsx)(NewDealForm,{onClose:onClose,stages:stages}):null})}function PipelineApp(){const[pipeline,setPipeline]=(0,index_js_.useState)("new_business");const[status,setStatus]=(0,index_js_.useState)("open");const[selectedId,setSelectedId]=(0,index_js_.useState)(null);const[newDealOpened,newDeal]=(0,esm_index_mjs_.useDisclosure)(false);const deals=useSalesDeals(pipeline,status);const stages=deals.data?.stages??[];const rows=deals.data?.deals??[];const selected=(0,index_js_.useMemo)(()=>{if(null===selectedId)return null;return rows.find(d=>d.id===selectedId)??null},[rows,selectedId]);const total=rows.reduce((acc,d)=>acc+d.value,0);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{fluid:true,my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",mb:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Pipeline"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"blue",children:`${rows.length} deal(s) : ${formatEur(total)}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:newDeal.open,disabled:0===stages.length,children:"+ Nouveau deal"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",mb:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:pipeline,onChange:setPipeline,data:[{label:"New Business",value:"new_business"},{label:"Upsell / Cross-sell",value:"upsell"}]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:status,onChange:setStatus,data:[{label:"Ouverts",value:"open"},{label:"Gagnés",value:"won"},{label:"Perdus",value:"lost"}]})]}),deals.isLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Loader,{}):null,deals.data&&"open"===status?/*#__PURE__*/(0,jsx_runtime.jsx)(KanbanBoard,{stages:stages,deals:rows,onOpen:setSelectedId}):null,deals.data&&"open"!==status?/*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:0===rows.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:"Aucun deal"}):/*#__PURE__*/(0,jsx_runtime.jsx)(DealsTable,{deals:rows,stages:stages,status:status,onRowClick:setSelectedId})}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(NewDealModal,{opened:newDealOpened,onClose:newDeal.close,stages:stages}),/*#__PURE__*/(0,jsx_runtime.jsx)(DealDetailDrawer,{deal:selected,stages:stages,onClose:()=>setSelectedId(null)})]})}function Pipeline(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.b,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(PipelineApp,{})})})}}}]);
@@ -0,0 +1,10 @@
1
+ /*! LICENSE: __federation_expose_sales.792debdfc0.js.LICENSE.txt */
2
+ "use strict";(globalThis["chunk_tech_app "]||=[]).push([[5761],{9698(__unused_rspack_module,exports){/**
3
+ * @license React
4
+ * react-jsx-runtime.production.js
5
+ *
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element"),REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");function jsxProd(type,config,maybeKey){var key=null;void 0!==maybeKey&&(key=""+maybeKey);void 0!==config.key&&(key=""+config.key);if("key"in config){maybeKey={};for(var propName in config)"key"!==propName&&(maybeKey[propName]=config[propName])}else maybeKey=config;config=maybeKey.ref;return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:key,ref:void 0!==config?config:null,props:maybeKey}}exports.Fragment=REACT_FRAGMENT_TYPE;exports.jsx=jsxProd;exports.jsxs=jsxProd},4848(module,__unused_rspack_exports,__webpack_require__){module.exports=__webpack_require__(9698)},6032(__unused_rspack_module,__webpack_exports__,__webpack_require__){var _tanstack_react_query__rspack_import_0=__webpack_require__(3411);var _useApi_ts__rspack_import_1=__webpack_require__(4691);function useSalesLeads(status){const api=(0,_useApi_ts__rspack_import_1.g)();return(0,_tanstack_react_query__rspack_import_0.useQuery)({queryKey:["tech","sales","leads",status],queryFn:async()=>(await api.sales.listLeadsV1({status})).data,refetchOnWindowFocus:true})}__webpack_require__.d(__webpack_exports__,{p:()=>useSalesLeads})},7510(__unused_rspack_module,__webpack_exports__,__webpack_require__){const TEMPERATURE_META={burning:{emoji:"🔥🔥",label:"Brûlant",order:5},hot:{emoji:"🔥",label:"Chaud",order:4},warm:{emoji:"🌡️",label:"Tiède",order:3},cold:{emoji:"❄️",label:"Froid",order:2},frozen:{emoji:"🧊",label:"Gelé",order:1}};const TEMPERATURE_ORDER=["burning","hot","warm","cold","frozen"];__webpack_require__.d(__webpack_exports__,{},{E:TEMPERATURE_ORDER,z:TEMPERATURE_META})},1239(__unused_rspack_module,__webpack_exports__,__webpack_require__){var react_jsx_runtime__rspack_import_0=__webpack_require__(4848);var _mantine_core__rspack_import_1=__webpack_require__(4618);var _src_components_logoDev_ts__rspack_import_2=__webpack_require__(2137);function BrandLogo({domain,alt,size=24}){return/*#__PURE__*/(0,react_jsx_runtime__rspack_import_0.jsx)(_mantine_core__rspack_import_1.Image,{src:(0,_src_components_logoDev_ts__rspack_import_2.w)(domain),alt:alt,title:alt,w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}__webpack_require__.d(__webpack_exports__,{F:()=>BrandLogo})},2137(__unused_rspack_module,__webpack_exports__,__webpack_require__){const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}__webpack_require__.d(__webpack_exports__,{w:()=>logoDevUrl})},721(__unused_rspack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Sales});var jsx_runtime=__webpack_require__(4848);var index_js_=__webpack_require__(814);var providers=__webpack_require__(9528);var index_mjs_=__webpack_require__(4618);var esm_index_mjs_=__webpack_require__(1810);var leadsQuery=__webpack_require__(6032);var modern_index_js_=__webpack_require__(3411);var notifications_esm_index_mjs_=__webpack_require__(7250);var useApi=__webpack_require__(4691);function useSalesRescan(){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async()=>(await api.sales.rescanV1()).data,onSuccess:data=>{notifications_esm_index_mjs_.notifications.show({title:"Re-scan",message:data?.message??"Re-scan lancé",color:data?.ok?"green":"orange"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Re-scan",message:err?.error?.error??err?.message??"Échec du re-scan",color:"red"})}})}function useSalesSyncState(){const api=(0,useApi.g)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sales","sync-state"],queryFn:async()=>(await api.sales.syncStateV1()).data,refetchOnWindowFocus:true})}function useSalesScanSummary(){const api=(0,useApi.g)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sales","scan-summary"],queryFn:async()=>(await api.sales.scanRunSummaryV1()).data,refetchOnWindowFocus:true})}const dateFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:"Europe/Paris",day:"2-digit",month:"2-digit"});const dateTimeFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:"Europe/Paris",day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"});function parisDayKey(date){return dateFormatter.format(date)}function formatRelativeParis(iso){if(null===iso)return"jamais";const date=new Date(iso);if(Number.isNaN(date.getTime()))return"jamais";const now=new Date;const diffMs=now.getTime()-date.getTime();if(diffMs<0)return`le ${dateFormatter.format(date)}`;const diffMinutes=Math.floor(diffMs/6e4);if(diffMinutes<1)return"à l'instant";if(diffMinutes<60)return`il y a ${diffMinutes} min`;const diffHours=Math.floor(diffMinutes/60);if(diffHours<24)return`il y a ${diffHours} h`;const todayKey=parisDayKey(now);const yesterday=new Date(now.getTime()-864e5);const yesterdayKey=parisDayKey(yesterday);const dateKey=parisDayKey(date);if(dateKey===yesterdayKey&&dateKey!==todayKey)return"hier";return`le ${dateFormatter.format(date)}`}function formatDateParis(iso){if(null===iso)return"";const date=new Date(iso);if(Number.isNaN(date.getTime()))return"";return dateTimeFormatter.format(date)}var sales_temperature=__webpack_require__(7510);function dueLabel(value){if(!value)return"Pas de date fixée";return new Date(value).toLocaleDateString("fr-FR",{timeZone:"Europe/Paris"})}function compare(a,b,key,desc){let av;let bv;if("temperature"===key){av=sales_temperature.z[a.temperature].order;bv=sales_temperature.z[b.temperature].order}else{av=a[key]?new Date(a[key]).getTime():0;bv=b[key]?new Date(b[key]).getTime():0}if(desc)return bv-av;return av-bv}function matchesSearch(lead,query){const q=query.trim().toLowerCase();if(!q)return true;const haystack=[lead.first_name,lead.last_name,lead.company].filter(Boolean).join(" ").toLowerCase();return haystack.includes(q)}function LeadsTable({leads,temperatureFilter,search,onRowClick}){const[sortKey,setSortKey]=(0,index_js_.useState)("last_contact_at");const[desc,setDesc]=(0,index_js_.useState)(true);function toggleSort(key){if(key===sortKey)setDesc(d=>!d);else{setSortKey(key);setDesc(true)}}const rows=(0,index_js_.useMemo)(()=>{const filtered=leads.filter(l=>{if(temperatureFilter&&l.temperature!==temperatureFilter)return false;return matchesSearch(l,search)});return[...filtered].sort((a,b)=>compare(a,b,sortKey,desc))},[leads,temperatureFilter,search,sortKey,desc]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>toggleSort("temperature"),children:"Température"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Prénom"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Nom"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>toggleSort("last_contact_at"),children:"Dernier contact"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Prochaine action"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>toggleSort("next_action_due_at"),children:"Échéance"})})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map(l=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{style:{cursor:"pointer"},onClick:()=>onRowClick(l.id),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:sales_temperature.z[l.temperature].emoji}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.first_name??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.last_name??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.company??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.last_contact_at?new Date(l.last_contact_at).toLocaleDateString("fr-FR",{timeZone:"Europe/Paris"}):"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.next_action??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:l.next_action_due_at?void 0:"dimmed",children:dueLabel(l.next_action_due_at)})})]},l.id))})]})}var dates_esm_index_mjs_=__webpack_require__(2506);function useSalesLead(id){const api=(0,useApi.g)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sales","lead",id],enabled:null!==id,queryFn:async()=>(await api.sales.getLeadV1({id})).data})}function useUpdateLead(id){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async payload=>(await api.sales.updateLeadV1({id},payload)).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:"Modifications enregistrées",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"Échec de la mise à jour",color:"red"})}})}function useDeleteLead(){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.sales.deleteLeadV1({id})).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:"Lead supprimé",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"Échec de la suppression",color:"red"})}})}function useSetLifecycle(id){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async status=>(await api.sales.setLifecycleV1({id},{status})).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:"Statut mis à jour",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"Échec",color:"red"})}})}function useAddComment(id){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async text=>(await api.sales.addCommentV1({id},{text})).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:"Commentaire ajouté",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales","lead",id]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"Échec",color:"red"})}})}function useReconstructLead(id){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async()=>(await api.sales.reconstructV1({id})).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Scan approfondi",message:"Scan demandé — traité à la prochaine session agent",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Scan approfondi",message:err?.error?.error??err?.message??"Échec",color:"red"})}})}function useEnrichLead(id){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async()=>(await api.sales.enrichLeadV1({id})).data,onSuccess:()=>{queryClient.invalidateQueries({queryKey:["tech","sales"]})}})}var tabler_icons_react_mjs_=__webpack_require__(2638);var BrandLogo=__webpack_require__(1239);const SOURCE_DOMAIN={pipedrive:"pipedrive.com",gmail:"google.com",claap:"claap.io",granola:"granola.ai",lemlist:"lemlist.com",linkedin:"linkedin.com",imessage:"apple.com",whatsapp:"whatsapp.com",slack:"slack.com",calendar:"google.com",pennylane:"pennylane.com",yousign:"yousign.com",notion:"notion.so"};function SourceLogo({source,size=18}){if("manual"===source)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ThemeIcon,{size:size,variant:"light",color:"gray",title:"Note",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconNote,{size:size-4})});const domain=SOURCE_DOMAIN[source];if(!domain)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:"light",color:"gray",title:source,children:source.slice(0,2).toUpperCase()});return/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.F,{domain:domain,alt:source,size:size})}function directionLabel(direction){if("internal"===direction)return"📝 Note";if("inbound"===direction)return"↘ Entrant";return"↗ Sortant"}function LeadTimeline({items}){if(0===items.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Aucun échange."});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Timeline,{active:items.length,bulletSize:14,lineWidth:2,children:items.map(it=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Timeline.Item,{title:it.summary??"(sans résumé)",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",mb:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SourceLogo,{source:it.source}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",fw:500,tt:"capitalize",children:it.source}),it.channel?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:"outline",children:it.channel}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:directionLabel(it.direction)})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:new Date(it.occurred_at).toLocaleString("fr-FR",{timeZone:"Europe/Paris"})}),it.external_url?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Anchor,{href:it.external_url,target:"_blank",size:"xs",children:"Ouvrir la source"}):null]})]},it.id))})}const BRAND_COLOR={pipedrive:"#017737",gmail:"#EA4335",pennylane:"#4B4BF5",claap:"#6C5CE7",granola:"#F26B3A",slack:"#4A154B",calendar:"#4285F4",imessage:"#0B93F6",whatsapp:"#25D366",linkedin:"#0A66C2",notion:"#111111",lemlist:"#4B4BF5"};function Tile({size,color,children}){return/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:size,height:size,viewBox:"0 0 24 24",role:"img","aria-hidden":"true",style:{display:"block",flex:"none"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)("rect",{x:"0",y:"0",width:"24",height:"24",rx:"5",fill:color}),children]})}function LetterGlyph({letter}){return/*#__PURE__*/(0,jsx_runtime.jsx)("text",{x:"12",y:"12",textAnchor:"middle",dominantBaseline:"central",fontFamily:"system-ui, sans-serif",fontSize:"13",fontWeight:"700",fill:"#fff",children:letter})}function bubbleGlyph(){return/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M12 5.5c-3.9 0-7 2.4-7 5.4 0 1.6.9 3.1 2.3 4.1-.1 1-.6 1.9-1 2.5 1.1-.2 2.2-.6 3-1.2.8.2 1.6.3 2.7.3 3.9 0 7-2.4 7-5.4s-3.1-5.7-7-5.7z",fill:"#fff"})}function glyphFor(source){if("gmail"===source)return/*#__PURE__*/(0,jsx_runtime.jsxs)("g",{stroke:"#fff",strokeWidth:"1.6",fill:"none",strokeLinejoin:"round",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("rect",{x:"5",y:"8",width:"14",height:"9",rx:"1"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M5.5 8.5 12 13l6.5-4.5"})]});if("calendar"===source)return/*#__PURE__*/(0,jsx_runtime.jsxs)("g",{stroke:"#fff",strokeWidth:"1.6",fill:"none",strokeLinecap:"round",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("rect",{x:"5",y:"6.5",width:"14",height:"12.5",rx:"1.5"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M5 10.5h14"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M9 4.5v3.5M15 4.5v3.5"})]});if("slack"===source)return/*#__PURE__*/(0,jsx_runtime.jsx)("g",{stroke:"#fff",strokeWidth:"1.7",strokeLinecap:"round",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M9.7 6 8.5 18M15.5 6l-1.2 12M6 9.7h12M5.5 14.3h12"})});if("whatsapp"===source||"imessage"===source)return bubbleGlyph();if("claap"===source)return/*#__PURE__*/(0,jsx_runtime.jsxs)("g",{fill:"none",stroke:"#fff",strokeWidth:"1.6",strokeLinejoin:"round",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("circle",{cx:"12",cy:"12",r:"7"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M10.5 9.2 15 12l-4.5 2.8z",fill:"#fff",stroke:"none"})]});if("granola"===source)return/*#__PURE__*/(0,jsx_runtime.jsxs)("g",{fill:"none",stroke:"#fff",strokeWidth:"1.5",strokeLinecap:"round",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("rect",{x:"6.5",y:"5",width:"11",height:"14",rx:"1.5",strokeWidth:"1.6"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M9 9h6M9 12h6M9 15h4"})]});if("pipedrive"===source)return/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M6 7h12l-4.5 5.2V18l-3-1.5v-4.3z",fill:"#fff"});if("lemlist"===source)return/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M5 12 19 6l-6 13-2.4-5.4z",fill:"#fff"});if("linkedin"===source)return/*#__PURE__*/(0,jsx_runtime.jsx)(LetterGlyph,{letter:"in"});if("notion"===source)return/*#__PURE__*/(0,jsx_runtime.jsx)(LetterGlyph,{letter:"N"});if("pennylane"===source)return/*#__PURE__*/(0,jsx_runtime.jsx)(LetterGlyph,{letter:"P"});return null}function LemlistIcon({size=16}){return/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{size:size,color:BRAND_COLOR.lemlist,children:glyphFor("lemlist")})}function SourceIcon({source,size=16}){const color=BRAND_COLOR[source];const glyph=glyphFor(source);if(color&&glyph)return/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{size:size,color:color,children:glyph});const initial=source.length>0?source.charAt(0).toUpperCase():"?";return/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:size,height:size,viewBox:"0 0 24 24",role:"img","aria-hidden":"true",style:{display:"block",flex:"none"},children:[/*#__PURE__*/(0,jsx_runtime.jsx)("circle",{cx:"12",cy:"12",r:"12",fill:"#868e96"}),/*#__PURE__*/(0,jsx_runtime.jsx)(LetterGlyph,{letter:initial})]})}const eurFormatter=new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR"});function scanCostLabel(lead){const{runs,tokens,cost_eur,last_ran_at}=lead.scan_cost;return`${runs} scan(s) approfondi(s) \xb7 ~${Math.round(tokens/1e3)} k tokens ≈ ${eurFormatter.format(cost_eur)} (dernier : ${formatDateParis(last_ran_at)})`}function scanStatusLabel(lead){if("requested"===lead.reconstruction_status)return`Scan demand\xe9 le ${formatDateParis(lead.reconstruction_requested_at)}`;if("done"===lead.reconstruction_status)return`Reconstruit le ${formatDateParis(lead.reconstruction_done_at)}`;return"Jamais reconstruit"}function LeadDetailDrawer({leadId,onClose}){const detail=useSalesLead(leadId);const update=useUpdateLead(leadId??0);const remove=useDeleteLead();const setLifecycle=useSetLifecycle(leadId??0);const addComment=useAddComment(leadId??0);const reconstruct=useReconstructLead(leadId??0);const enrich=useEnrichLead(leadId??0);const[firstName,setFirstName]=(0,index_js_.useState)("");const[lastName,setLastName]=(0,index_js_.useState)("");const[company,setCompany]=(0,index_js_.useState)("");const[email,setEmail]=(0,index_js_.useState)("");const[phone,setPhone]=(0,index_js_.useState)("");const[temperature,setTemperature]=(0,index_js_.useState)(null);const[nextAction,setNextAction]=(0,index_js_.useState)("");const[dueAt,setDueAt]=(0,index_js_.useState)("");const[comment,setComment]=(0,index_js_.useState)("");(0,index_js_.useEffect)(()=>{if(detail.data){setFirstName(detail.data.first_name??"");setLastName(detail.data.last_name??"");setCompany(detail.data.company??"");setEmail(detail.data.identities?.find(i=>"email"===i.type)?.value??"");setPhone(detail.data.identities?.find(i=>"phone"===i.type)?.value??"");setTemperature(detail.data.temperature);setNextAction(detail.data.next_action??"");setDueAt(detail.data.next_action_due_at??"")}},[detail.data]);function save(){update.mutate({first_name:""===firstName?null:firstName,last_name:""===lastName?null:lastName,company:""===company?null:company,emails:email?[email]:[],phones:phone?[phone]:[],temperature:temperature??void 0,next_action:""===nextAction?null:nextAction,next_action_due_at:""===dueAt?null:dueAt})}function handleDelete(){if(null===leadId)return;remove.mutate(leadId,{onSuccess:onClose})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Drawer,{opened:null!==leadId,onClose:onClose,position:"right",size:"lg",title:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,children:"Lead"}),children:[detail.isLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Loader,{}):null,detail.data?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Prénom",value:firstName,onChange:e=>setFirstName(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Nom",value:lastName,onChange:e=>setLastName(e.currentTarget.value)})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Entreprise",value:company,onChange:e=>setCompany(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Email",value:email,onChange:e=>setEmail(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Téléphone",value:phone,onChange:e=>setPhone(e.currentTarget.value)})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(LemlistIcon,{size:16}),loading:enrich.isPending,disabled:enrich.isPending,onClick:()=>{enrich.mutate(void 0,{onSuccess:result=>{if(result.added>0)notifications_esm_index_mjs_.notifications.show({title:"Enrichissement",message:`Enrichi : ${result.found.emails.length} email(s), ${result.found.phones.length} t\xe9l.`,color:"green"});else notifications_esm_index_mjs_.notifications.show({title:"Enrichissement",message:"Aucune coordonnée trouvée",color:"gray"})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Enrichissement",message:err?.error?.error??err?.message??"Échec",color:"red"})}})},children:"Enrichir lead"})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Prochaine action",value:nextAction,onChange:e=>setNextAction(e.currentTarget.value),flex:1}),/*#__PURE__*/(0,jsx_runtime.jsx)(dates_esm_index_mjs_.DateInput,{label:"Échéance",placeholder:"Pas de date fixée",clearable:true,valueFormat:"DD/MM/YYYY",value:dueAt?new Date(dueAt):null,onChange:v=>setDueAt(v?new Date(v).toISOString():"")})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Température",data:sales_temperature.E.map(t=>({value:t,label:`${sales_temperature.z[t].emoji} ${sales_temperature.z[t].label}`})),value:temperature,onChange:setTemperature}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Déplacer vers",data:[{value:"active",label:"Actif"},{value:"won",label:"Gagné"},{value:"lost",label:"Perdu"}],value:detail.data.lifecycle_status,onChange:v=>{if(v)setLifecycle.mutate(v)}}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",variant:"light",onClick:handleDelete,children:"Supprimer"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:update.isPending,onClick:save,children:"Enregistrer"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Textarea,{label:"Ajouter un commentaire",value:comment,onChange:e=>setComment(e.currentTarget.value),autosize:true,minRows:2}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{disabled:!comment,loading:addComment.isPending,onClick:()=>{addComment.mutate(comment,{onSuccess:()=>setComment("")})},children:"Commenter"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{mt:"md"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,children:"Scan"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:scanStatusLabel(detail.data)}),detail.data.scan_cost.runs>0?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:scanCostLabel(detail.data)}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",loading:reconstruct.isPending,disabled:"requested"===detail.data.reconstruction_status,onClick:()=>reconstruct.mutate(),children:"Demander un scan approfondi"})})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,mt:"md",children:"Historique"}),/*#__PURE__*/(0,jsx_runtime.jsx)(LeadTimeline,{items:detail.data.interactions})]}):null]})}var form_esm_index_mjs_=__webpack_require__(6220);function useCreateLead(){const api=(0,useApi.g)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async payload=>(await api.sales.createLeadV1(payload)).data,onSuccess:data=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:data?.attached?"Coordonnée déjà connue — rattaché au lead existant":"Lead créé",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"Échec de la création",color:"red"})}})}function NewLeadModal({opened,onClose}){const create=useCreateLead();const form=(0,form_esm_index_mjs_.useForm)({initialValues:{first_name:"",last_name:"",company:"",email:"",phone:"",note:"",next_action_due_at:null,request_reconstruction:true}});function submit(values){const hasAny=Boolean(values.first_name)||Boolean(values.last_name)||Boolean(values.company)||Boolean(values.email)||Boolean(values.phone);if(!hasAny)return void notifications_esm_index_mjs_.notifications.show({title:"Lead",message:"Renseignez au moins un nom, une entreprise ou une coordonnée",color:"orange"});create.mutate({first_name:values.first_name||null,last_name:values.last_name||null,company:values.company||null,emails:values.email?[values.email]:[],phones:values.phone?[values.phone]:[],note:values.note||null,next_action_due_at:values.next_action_due_at?new Date(values.next_action_due_at).toISOString():null,request_reconstruction:values.request_reconstruction},{onSuccess:()=>{form.reset();onClose()}})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:opened,onClose:onClose,title:"Nouveau lead",children:/*#__PURE__*/(0,jsx_runtime.jsx)("form",{onSubmit:form.onSubmit(submit),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Prénom",...form.getInputProps("first_name")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Nom",...form.getInputProps("last_name")})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Entreprise",...form.getInputProps("company")}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Email",...form.getInputProps("email")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Téléphone",...form.getInputProps("phone")})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Textarea,{label:"Note / prochaine action",...form.getInputProps("note")}),/*#__PURE__*/(0,jsx_runtime.jsx)(dates_esm_index_mjs_.DateInput,{label:"Relancer le",placeholder:"Pas de date fixée",clearable:true,valueFormat:"DD/MM/YYYY",...form.getInputProps("next_action_due_at")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{label:"Reconstruire l'historique (recherche multi-sources)",...form.getInputProps("request_reconstruction",{type:"checkbox"})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:onClose,children:"Annuler"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{type:"submit",loading:create.isPending,children:"Créer"})]})]})})})}const sales_app_eurFormatter=new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR"});function sourceLabel(source){if(0===source.length)return source;return source.charAt(0).toUpperCase()+source.slice(1)}function SalesApp(){const[status,setStatus]=(0,index_js_.useState)("active");const leads=(0,leadsQuery.p)(status);const rescan=useSalesRescan();const syncState=useSalesSyncState();const scanSummary=useSalesScanSummary();const[selectedId,setSelectedId]=(0,index_js_.useState)(null);const[temperatureFilter,setTemperatureFilter]=(0,index_js_.useState)(null);const[search,setSearch]=(0,index_js_.useState)("");const[newLeadOpened,newLead]=(0,esm_index_mjs_.useDisclosure)(false);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{fluid:true,my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",mb:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Leads"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{placeholder:"Rechercher (nom, entreprise)",value:search,onChange:e=>setSearch(e.currentTarget.value),w:260}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{placeholder:"Toutes températures",clearable:true,data:sales_temperature.E.map(t=>({value:t,label:`${sales_temperature.z[t].emoji} ${sales_temperature.z[t].label}`})),value:temperatureFilter,onChange:v=>setTemperatureFilter(v)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:newLead.open,children:"+ Nouveau lead"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:rescan.isPending,onClick:()=>rescan.mutate(),variant:"light",children:"Re-scanner"})]})]}),syncState.data&&syncState.data.sources.length>0||scanSummary.data&&scanSummary.data.total_runs>0?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",mb:"md",children:[syncState.data?syncState.data.sources.map(s=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"gray",leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(SourceIcon,{source:s.source,size:14}),children:`${sourceLabel(s.source)} \xb7 ${formatRelativeParis(s.last_sync_at)}`},s.source)):null,scanSummary.data&&scanSummary.data.total_runs>0?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"blue",children:`Scans agent ce mois : ${scanSummary.data.month_runs} \xb7 ~${Math.round(scanSummary.data.month_tokens/1e3)} k tokens ≈ ${sales_app_eurFormatter.format(scanSummary.data.month_cost_eur)}`}):null]}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:status,onChange:setStatus,mb:"md",data:[{label:"Actifs",value:"active"},{label:"Gagnés",value:"won"},{label:"Perdus",value:"lost"}]}),leads.isLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Loader,{}):null,leads.data?/*#__PURE__*/(0,jsx_runtime.jsx)(LeadsTable,{leads:leads.data.leads,temperatureFilter:temperatureFilter,search:search,onRowClick:setSelectedId}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(NewLeadModal,{opened:newLeadOpened,onClose:newLead.close}),/*#__PURE__*/(0,jsx_runtime.jsx)(LeadDetailDrawer,{leadId:selectedId,onClose:()=>setSelectedId(null)})]})}function Sales(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.b,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(SalesApp,{})})})}}}]);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */