@airporting/tech-app 0.0.125 → 0.0.127

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 (32) hide show
  1. package/dist/mf/{5429.15b34dd118.js → 5429.f4bca5be4b.js} +1 -1
  2. package/dist/mf/6755.d44651735b.js +1 -0
  3. package/dist/mf/{9698.5ba81b4ca1.css → 9698.7298203f5a.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/createLeadMutation.d.ts +1 -0
  6. package/dist/mf/@mf-types/compiled-types/api/tech/sales/dealsQuery.d.ts +2 -0
  7. package/dist/mf/@mf-types/compiled-types/api/tech/sales/deleteDealMutation.d.ts +1 -0
  8. package/dist/mf/@mf-types/compiled-types/api/tech/sales/enrichLeadMutation.d.ts +4 -1
  9. package/dist/mf/@mf-types/compiled-types/api/tech/sales/updateDealMutation.d.ts +11 -0
  10. package/dist/mf/@mf-types/compiled-types/api/tech/sales/updateLeadMutation.d.ts +1 -0
  11. package/dist/mf/@mf-types/compiled-types/apps/pipeline/DealCard.d.ts +8 -0
  12. package/dist/mf/@mf-types/compiled-types/apps/pipeline/DealDetailDrawer.d.ts +8 -0
  13. package/dist/mf/@mf-types/compiled-types/apps/pipeline/DealsTable.d.ts +9 -0
  14. package/dist/mf/@mf-types/compiled-types/apps/pipeline/KanbanBoard.d.ts +8 -0
  15. package/dist/mf/@mf-types/compiled-types/apps/pipeline/NewDealModal.d.ts +8 -0
  16. package/dist/mf/@mf-types/compiled-types/apps/pipeline/format.d.ts +3 -0
  17. package/dist/mf/@mf-types/compiled-types/apps/pipeline/types.d.ts +37 -0
  18. package/dist/mf/@mf-types/compiled-types/apps/pipeline.app.d.ts +1 -0
  19. package/dist/mf/@mf-types/compiled-types/apps/sales/types.d.ts +4 -1
  20. package/dist/mf/@mf-types/compiled-types/gen/TechApi/index.d.ts +182 -1
  21. package/dist/mf/@mf-types/compiled-types/tabs/pipeline.d.ts +2 -0
  22. package/dist/mf/__federation_expose_pipeline.48dbe478c4.js +10 -0
  23. package/dist/mf/__federation_expose_sales.dfbee2c4e2.js +10 -0
  24. package/dist/mf/__federation_expose_sales.dfbee2c4e2.js.LICENSE.txt +9 -0
  25. package/dist/mf/{index.f916e4edb7.js → index.118cfb08b9.js} +3 -3
  26. package/dist/mf/mf-manifest.json +75 -42
  27. package/dist/mf/mf-stats.json +96 -46
  28. package/dist/mf/{tech_app.8abb0b0510.js → tech_app.e57897e310.js} +3 -3
  29. package/package.json +1 -1
  30. package/dist/mf/6755.3b2751c6d2.js +0 -1
  31. package/dist/mf/__federation_expose_sales.b781a94a8a.js +0 -10
  32. /package/dist/mf/{__federation_expose_sales.b781a94a8a.js.LICENSE.txt → __federation_expose_pipeline.48dbe478c4.js.LICENSE.txt} +0 -0
@@ -0,0 +1,3 @@
1
+ export declare function formatEur(value: number): string;
2
+ export declare function formatAmount(value: number, currency: string): string;
3
+ export declare function formatDay(iso: string | null): string;
@@ -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;
@@ -11,6 +11,9 @@ export type LeadListItem = {
11
11
  next_action_due_at: string | null;
12
12
  manual_override: boolean;
13
13
  lifecycle_status: LifecycleStatus;
14
+ email: string | null;
15
+ phone: string | null;
16
+ linkedin_url: string | null;
14
17
  };
15
18
  export type InteractionItem = {
16
19
  id: number;
@@ -31,7 +34,7 @@ export type LeadScanCost = {
31
34
  cost_eur: number;
32
35
  last_ran_at: string | null;
33
36
  };
34
- export type LeadDetail = LeadListItem & {
37
+ export type LeadDetail = Omit<LeadListItem, 'email' | 'phone' | 'linkedin_url'> & {
35
38
  interactions: InteractionItem[];
36
39
  identities: LeadIdentity[];
37
40
  reconstruction_status: string | null;
@@ -13,11 +13,24 @@ 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[];
19
31
  first_name?: string | null;
20
32
  last_name?: string | null;
33
+ linkedin_url?: string | null;
21
34
  next_action_due_at?: string | null;
22
35
  note?: string | null;
23
36
  phones?: string[];
@@ -28,6 +41,9 @@ export interface CreateSalesLeadResponse {
28
41
  attached: boolean;
29
42
  id: number;
30
43
  }
44
+ export interface DeleteDealV1Params {
45
+ id: number;
46
+ }
31
47
  export interface DeleteFinanceJobsRedisLockResponse {
32
48
  existed: boolean;
33
49
  key: string;
@@ -59,10 +75,13 @@ export interface EnrichFound {
59
75
  }
60
76
  export interface EnrichLeadResponse {
61
77
  added: number;
78
+ attempted: string[];
62
79
  found: EnrichFound;
80
+ provider: string | null;
63
81
  }
64
82
  export interface EnrichLeadV1Params {
65
83
  id: number;
84
+ kind?: string;
66
85
  }
67
86
  export interface EtatSaisieCustomerRow {
68
87
  client: string;
@@ -382,6 +401,10 @@ export interface GetPayfitDashboardResponse {
382
401
  export interface GetRunStatsResponse {
383
402
  currentJobsCounters: UsersRunStatsResponse;
384
403
  }
404
+ export interface GetSalesDealsResponse {
405
+ deals: SalesDealItem[];
406
+ stages: SalesDealStageItem[];
407
+ }
385
408
  export interface GetSalesLeadResponse {
386
409
  company: string | null;
387
410
  first_name: string | null;
@@ -498,6 +521,10 @@ export interface ListFinanceJobsTasksResponse {
498
521
  items: FinanceJobsTaskItem[];
499
522
  total: number;
500
523
  }
524
+ export interface ListDealsV1Params {
525
+ pipeline: string;
526
+ status: string;
527
+ }
501
528
  export interface ListGsheetTasksResponse {
502
529
  items: GsheetTaskItem[];
503
530
  total: number;
@@ -584,6 +611,36 @@ export interface RunRecipeResponse {
584
611
  message?: string;
585
612
  ok: boolean;
586
613
  }
614
+ export interface SalesDealItem {
615
+ created_at: string;
616
+ currency: string;
617
+ expected_close_date: string | null;
618
+ id: number;
619
+ lead: SalesDealLeadItem;
620
+ lost_at: string | null;
621
+ lost_reason: string | null;
622
+ probability: number | null;
623
+ stage_id: number;
624
+ status: string;
625
+ title: string;
626
+ updated_at: string;
627
+ value: number;
628
+ won_at: string | null;
629
+ }
630
+ export interface SalesDealLeadItem {
631
+ company: string | null;
632
+ first_name: string | null;
633
+ id: number;
634
+ last_name: string | null;
635
+ temperature: string;
636
+ }
637
+ export interface SalesDealStageItem {
638
+ deal_count: number;
639
+ id: number;
640
+ name: string;
641
+ order_nr: number;
642
+ total_value: number;
643
+ }
587
644
  export interface SalesIdentityItem {
588
645
  type: string;
589
646
  value: string;
@@ -599,14 +656,17 @@ export interface SalesInteractionItem {
599
656
  }
600
657
  export interface SalesLeadListItem {
601
658
  company: string | null;
659
+ email: string | null;
602
660
  first_name: string | null;
603
661
  id: number;
604
662
  last_contact_at: string | null;
605
663
  last_name: string | null;
606
664
  lifecycle_status: string;
665
+ linkedin_url: string | null;
607
666
  manual_override: boolean;
608
667
  next_action: string | null;
609
668
  next_action_due_at: string | null;
669
+ phone: string | null;
610
670
  temperature: string;
611
671
  }
612
672
  export interface SalesSyncStateItem {
@@ -745,14 +805,28 @@ export interface UnstickV1Params {
745
805
  export interface UnstickV1Params2 {
746
806
  id: number;
747
807
  }
808
+ export interface UpdateDealV1Params {
809
+ id: number;
810
+ }
748
811
  export interface UpdateLeadV1Params {
749
812
  id: number;
750
813
  }
814
+ export interface UpdateSalesDealBody {
815
+ currency?: string;
816
+ expected_close_date?: string | null;
817
+ lost_reason?: string | null;
818
+ probability?: number | null;
819
+ stage_id?: number;
820
+ status?: string;
821
+ title?: string;
822
+ value?: number;
823
+ }
751
824
  export interface UpdateSalesLeadBody {
752
825
  company?: string | null;
753
826
  emails?: string[];
754
827
  first_name?: string | null;
755
828
  last_name?: string | null;
829
+ linkedin_url?: string | null;
756
830
  next_action?: string | null;
757
831
  next_action_due_at?: string | null;
758
832
  phones?: string[];
@@ -1009,7 +1083,9 @@ export declare namespace Sales {
1009
1083
  type RequestParams = {
1010
1084
  id: number;
1011
1085
  };
1012
- type RequestQuery = {};
1086
+ type RequestQuery = {
1087
+ kind?: string;
1088
+ };
1013
1089
  type RequestBody = never;
1014
1090
  type RequestHeaders = {};
1015
1091
  type ResponseBody = EnrichLeadResponse;
@@ -1092,6 +1168,75 @@ export declare namespace Sales {
1092
1168
  type RequestHeaders = {};
1093
1169
  type ResponseBody = ScanRunSummaryResponse;
1094
1170
  }
1171
+ /**
1172
+ * No description
1173
+ * @tags Sales
1174
+ * @name ListDealsV1
1175
+ * @request GET:/v1/sales/deals
1176
+ * @response `200` `GetSalesDealsResponse`
1177
+ */
1178
+ namespace ListDealsV1 {
1179
+ type RequestParams = {};
1180
+ type RequestQuery = {
1181
+ pipeline: string;
1182
+ status: string;
1183
+ };
1184
+ type RequestBody = never;
1185
+ type RequestHeaders = {};
1186
+ type ResponseBody = GetSalesDealsResponse;
1187
+ }
1188
+ /**
1189
+ * No description
1190
+ * @tags Sales
1191
+ * @name CreateDealV1
1192
+ * @request POST:/v1/sales/deals
1193
+ * @response `201` `CreateSalesDealResponse`
1194
+ */
1195
+ namespace CreateDealV1 {
1196
+ type RequestParams = {};
1197
+ type RequestQuery = {};
1198
+ type RequestBody = CreateSalesDealBody;
1199
+ type RequestHeaders = {
1200
+ from: string;
1201
+ };
1202
+ type ResponseBody = CreateSalesDealResponse;
1203
+ }
1204
+ /**
1205
+ * No description
1206
+ * @tags Sales
1207
+ * @name UpdateDealV1
1208
+ * @request PATCH:/v1/sales/deals/{id}
1209
+ * @response `200` `OkResponse`
1210
+ */
1211
+ namespace UpdateDealV1 {
1212
+ type RequestParams = {
1213
+ id: number;
1214
+ };
1215
+ type RequestQuery = {};
1216
+ type RequestBody = UpdateSalesDealBody;
1217
+ type RequestHeaders = {
1218
+ from: string;
1219
+ };
1220
+ type ResponseBody = OkResponse;
1221
+ }
1222
+ /**
1223
+ * No description
1224
+ * @tags Sales
1225
+ * @name DeleteDealV1
1226
+ * @request DELETE:/v1/sales/deals/{id}
1227
+ * @response `200` `OkResponse`
1228
+ */
1229
+ namespace DeleteDealV1 {
1230
+ type RequestParams = {
1231
+ id: number;
1232
+ };
1233
+ type RequestQuery = {};
1234
+ type RequestBody = never;
1235
+ type RequestHeaders = {
1236
+ from: string;
1237
+ };
1238
+ type ResponseBody = OkResponse;
1239
+ }
1095
1240
  }
1096
1241
  export declare namespace FinanceJobs {
1097
1242
  /**
@@ -1878,6 +2023,42 @@ export declare class TechApi<SecurityDataType extends unknown> {
1878
2023
  * @response `200` `ScanRunSummaryResponse`
1879
2024
  */
1880
2025
  scanRunSummaryV1: (params?: RequestParams) => Promise<HttpResponse<ScanRunSummaryResponse, any>>;
2026
+ /**
2027
+ * No description
2028
+ *
2029
+ * @tags Sales
2030
+ * @name ListDealsV1
2031
+ * @request GET:/v1/sales/deals
2032
+ * @response `200` `GetSalesDealsResponse`
2033
+ */
2034
+ listDealsV1: (query: ListDealsV1Params, params?: RequestParams) => Promise<HttpResponse<GetSalesDealsResponse, any>>;
2035
+ /**
2036
+ * No description
2037
+ *
2038
+ * @tags Sales
2039
+ * @name CreateDealV1
2040
+ * @request POST:/v1/sales/deals
2041
+ * @response `201` `CreateSalesDealResponse`
2042
+ */
2043
+ createDealV1: (data: CreateSalesDealBody, params?: RequestParams) => Promise<HttpResponse<CreateSalesDealResponse, any>>;
2044
+ /**
2045
+ * No description
2046
+ *
2047
+ * @tags Sales
2048
+ * @name UpdateDealV1
2049
+ * @request PATCH:/v1/sales/deals/{id}
2050
+ * @response `200` `OkResponse`
2051
+ */
2052
+ updateDealV1: ({ id, ...query }: UpdateDealV1Params, data: UpdateSalesDealBody, params?: RequestParams) => Promise<HttpResponse<OkResponse, any>>;
2053
+ /**
2054
+ * No description
2055
+ *
2056
+ * @tags Sales
2057
+ * @name DeleteDealV1
2058
+ * @request DELETE:/v1/sales/deals/{id}
2059
+ * @response `200` `OkResponse`
2060
+ */
2061
+ deleteDealV1: ({ id, ...query }: DeleteDealV1Params, params?: RequestParams) => Promise<HttpResponse<OkResponse, any>>;
1881
2062
  };
1882
2063
  financeJobs: {
1883
2064
  /**
@@ -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.dfbee2c4e2.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,lead.email,lead.phone,lead.linkedin_url].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.jsx)(index_mjs_.Table.ScrollContainer,{minWidth:1250,children:/*#__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:"Email"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Téléphone"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"LinkedIn"}),/*#__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.email??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.phone??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.linkedin_url?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Anchor,{href:l.linkedin_url,target:"_blank",rel:"noreferrer",onClick:event=>event.stopPropagation(),children:"Profil"}):"—"}),/*#__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);var tabler_icons_react_mjs_=__webpack_require__(2638);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 kind=>(await api.sales.enrichLeadV1({id,kind})).data,onSuccess:()=>{queryClient.invalidateQueries({queryKey:["tech","sales"]})}})}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 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[linkedinUrl,setLinkedinUrl]=(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??"");setLinkedinUrl(detail.data.identities?.find(i=>"linkedin_url"===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]:[],linkedin_url:linkedinUrl||null,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.jsx)(index_mjs_.TextInput,{label:"URL LinkedIn",placeholder:"https://www.linkedin.com/in/...",value:linkedinUrl,onChange:e=>setLinkedinUrl(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.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconAt,{size:16}),loading:enrich.isPending&&"email"===enrich.variables,disabled:enrich.isPending||Boolean(email),onClick:()=>{enrich.mutate("email",{onSuccess:result=>{const value=result.found.emails[0];if(value)setEmail(value);if(result.added>0)notifications_esm_index_mjs_.notifications.show({title:"Email trouvé",message:`${value}${result.provider?` \xb7 ${result.provider}`:""}`,color:"green"});else notifications_esm_index_mjs_.notifications.show({title:"Email",message:"Aucun email trouvé",color:"gray"})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Email",message:err?.error?.error??err?.message??"Échec",color:"red"})}})},children:"Obtenir email"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconPhone,{size:16}),loading:enrich.isPending&&"phone"===enrich.variables,disabled:enrich.isPending||Boolean(phone),onClick:()=>{enrich.mutate("phone",{onSuccess:result=>{const value=result.found.phones[0];if(value)setPhone(value);notifications_esm_index_mjs_.notifications.show({title:result.added>0?"Téléphone trouvé":"Téléphone",message:result.added>0?`${value}${result.provider?` \xb7 ${result.provider}`:""}`:"Aucun téléphone trouvé",color:result.added>0?"green":"gray"})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Téléphone",message:err?.error?.error??err?.message??"Échec",color:"red"})}})},children:"Obtenir téléphone"})]}),/*#__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:"",linkedin_url:"",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)||Boolean(values.linkedin_url);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]:[],linkedin_url:values.linkedin_url||null,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.jsx)(index_mjs_.TextInput,{label:"URL LinkedIn",placeholder:"https://www.linkedin.com/in/...",...form.getInputProps("linkedin_url")}),/*#__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 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 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 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
+ */