@airporting/tech-app 0.0.76 → 0.0.78

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.
package/dist/mf/9669.js CHANGED
@@ -7,4 +7,4 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
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},5893:function(module,__unused_webpack_exports,__webpack_require__){module.exports=__webpack_require__(631)},4148:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{h:()=>useApi});var _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(9056);var _src_hooks_useAppConfig_ts__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(7936);function useApi(){const config=(0,_src_hooks_useAppConfig_ts__WEBPACK_IMPORTED_MODULE_0__.M)();const client=new _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__.eN({baseUrl:config.api.replace(/\/$/,""),baseApiParams:{headers:{Authorization:config.token?`Bearer ${config.token}`:"",From:config.owner}}});return new _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__.eT(client)}},9056:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{eN:()=>HttpClient,eT:()=>TechApi});class HttpClient{baseUrl="";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...fetchParams)=>fetch(...fetchParams);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(apiConfig={}){Object.assign(this,apiConfig)}setSecurityData=data=>{this.securityData=data};encodeQueryParam(key,value){const encodedKey=encodeURIComponent(key);return`${encodedKey}=${encodeURIComponent("number"==typeof value?value:`${value}`)}`}addQueryParam(query,key){return this.encodeQueryParam(key,query[key])}addArrayQueryParam(query,key){const value=query[key];return value.map(v=>this.encodeQueryParam(key,v)).join("&")}toQueryString(rawQuery){const query=rawQuery||{};const keys=Object.keys(query).filter(key=>void 0!==query[key]);return keys.map(key=>Array.isArray(query[key])?this.addArrayQueryParam(query,key):this.addQueryParam(query,key)).join("&")}addQueryParams(rawQuery){const queryString=this.toQueryString(rawQuery);return queryString?`?${queryString}`:""}contentFormatters={["application/json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["application/vnd.api+json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["text/plain"]:input=>null!==input&&"string"!=typeof input?JSON.stringify(input):input,["multipart/form-data"]:input=>{if(input instanceof FormData)return input;return Object.keys(input||{}).reduce((formData,key)=>{const property=input[key];formData.append(key,property instanceof Blob?property:"object"==typeof property&&null!==property?JSON.stringify(property):`${property}`);return formData},new FormData)},["application/x-www-form-urlencoded"]:input=>this.toQueryString(input)};mergeRequestParams(params1,params2){return{...this.baseApiParams,...params1,...params2||{},headers:{...this.baseApiParams.headers||{},...params1.headers||{},...params2&&params2.headers||{}}}}createAbortSignal=cancelToken=>{if(this.abortControllers.has(cancelToken)){const abortController=this.abortControllers.get(cancelToken);if(abortController)return abortController.signal;return}const abortController=new AbortController;this.abortControllers.set(cancelToken,abortController);return abortController.signal};abortRequest=cancelToken=>{const abortController=this.abortControllers.get(cancelToken);if(abortController){abortController.abort();this.abortControllers.delete(cancelToken)}};request=async({body,secure,path,type,query,format,baseUrl,cancelToken,...params})=>{const secureParams=("boolean"==typeof secure?secure:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{};const requestParams=this.mergeRequestParams(params,secureParams);const queryString=query&&this.toQueryString(query);const payloadFormatter=this.contentFormatters[type||"application/json"];const responseFormat=format||requestParams.format;return this.customFetch(`${baseUrl||this.baseUrl||""}${path}${queryString?`?${queryString}`:""}`,{...requestParams,headers:{...requestParams.headers||{},...type&&"multipart/form-data"!==type?{"Content-Type":type}:{}},signal:(cancelToken?this.createAbortSignal(cancelToken):requestParams.signal)||null,body:null==body?null:payloadFormatter(body)}).then(async response=>{const r=response;r.data=null;r.error=null;const responseToParse=responseFormat?response.clone():response;const data=responseFormat?await responseToParse[responseFormat]().then(data=>{if(r.ok)r.data=data;else r.error=data;return r}).catch(e=>{r.error=e;return r}):r;if(cancelToken)this.abortControllers.delete(cancelToken);if(!response.ok)throw data;return data})}}class TechApi{http;constructor(http){this.http=http}status=(params={})=>this.http.request({path:"/status",method:"GET",...params});getDashboard=(params={})=>this.http.request({path:"/dashboard",method:"GET",format:"json",...params});getScrapers=(params={})=>this.http.request({path:"/scrapers",method:"GET",format:"json",...params});getCompanies=(params={})=>this.http.request({path:"/companies",method:"GET",format:"json",...params});webhook={postSmsWebhook:(query,params={})=>this.http.request({path:"/sms/webhook",method:"POST",query:query,...params})};amex={getTransactionsV1:(query,params={})=>this.http.request({path:"/v1/amex/transactions",method:"GET",query:query,...params})};etatSaisie={getLatestV1:(params={})=>this.http.request({path:"/v1/etat-saisie/latest",method:"GET",format:"json",...params}),getDossiersV1:(params={})=>this.http.request({path:"/v1/etat-saisie/dossiers",method:"GET",format:"json",...params}),setManagedV1:({id,...query},data,params={})=>this.http.request({path:`/v1/etat-saisie/dossiers/${id}`,method:"PATCH",body:data,type:"application/json",format:"json",...params}),setResponsableV1:({id,...query},data,params={})=>this.http.request({path:`/v1/etat-saisie/dossiers/${id}/responsable`,method:"PATCH",body:data,type:"application/json",format:"json",...params}),recomputeV1:(params={})=>this.http.request({path:"/v1/etat-saisie/recompute",method:"POST",format:"json",...params})};sales={listLeadsV1:(query,params={})=>this.http.request({path:"/v1/sales/leads",method:"GET",query:query,format:"json",...params}),createLeadV1:(data,params={})=>this.http.request({path:"/v1/sales/leads",method:"POST",body:data,type:"application/json",format:"json",...params}),syncStateV1:(params={})=>this.http.request({path:"/v1/sales/sync-state",method:"GET",format:"json",...params}),getLeadV1:({id,...query},params={})=>this.http.request({path:`/v1/sales/leads/${id}`,method:"GET",format:"json",...params}),updateLeadV1:({id,...query},data,params={})=>this.http.request({path:`/v1/sales/leads/${id}`,method:"PATCH",body:data,type:"application/json",format:"json",...params}),deleteLeadV1:({id,...query},params={})=>this.http.request({path:`/v1/sales/leads/${id}`,method:"DELETE",format:"json",...params}),reconstructV1:({id,...query},params={})=>this.http.request({path:`/v1/sales/leads/${id}/reconstruct`,method:"POST",format:"json",...params}),setLifecycleV1:({id,...query},data,params={})=>this.http.request({path:`/v1/sales/leads/${id}/lifecycle`,method:"POST",body:data,type:"application/json",format:"json",...params}),addCommentV1:({id,...query},data,params={})=>this.http.request({path:`/v1/sales/leads/${id}/comment`,method:"POST",body:data,type:"application/json",format:"json",...params}),rescanV1:(params={})=>this.http.request({path:"/v1/sales/rescan",method:"POST",format:"json",...params}),recordScanRunV1:(data,params={})=>this.http.request({path:"/v1/sales/scan-runs",method:"POST",body:data,type:"application/json",format:"json",...params}),scanRunSummaryV1:(params={})=>this.http.request({path:"/v1/sales/scan-runs/summary",method:"GET",format:"json",...params})};financeJobs={getStockV1:(params={})=>this.http.request({path:"/v1/finance-jobs/stock",method:"GET",format:"json",...params}),listTasksV1:(query,params={})=>this.http.request({path:"/v1/finance-jobs/tasks",method:"GET",query:query,format:"json",...params}),unstickV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/unstick`,method:"POST",format:"json",...params}),retryV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/retry`,method:"POST",format:"json",...params}),discardV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/discard`,method:"POST",format:"json",...params}),setOwnerV1:({id,...query},data,params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/owner`,method:"PUT",body:data,type:"application/json",format:"json",...params}),deleteRedisLockV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/redis-lock`,method:"DELETE",format:"json",...params}),runRecipeV1:(data,params={})=>this.http.request({path:"/v1/finance-jobs/run-recipe",method:"POST",body:data,type:"application/json",format:"json",...params}),getRunnersV1:(params={})=>this.http.request({path:"/v1/finance-jobs/runners",method:"GET",format:"json",...params})};github={getJobsRunnersV1:(params={})=>this.http.request({path:"/v1/github/jobs/runners",method:"GET",format:"json",...params}),getLabelsV1:({host,...query},params={})=>this.http.request({path:`/v1/github/labels/${host}`,method:"GET",format:"json",...params}),getJobLogsV1:(query,params={})=>this.http.request({path:"/v1/github/job-logs",method:"GET",query:query,format:"json",...params})};gsheet={getStockV1:(params={})=>this.http.request({path:"/v1/gsheet/stock",method:"GET",format:"json",...params}),listTasksV1:(query,params={})=>this.http.request({path:"/v1/gsheet/tasks",method:"GET",query:query,format:"json",...params}),unstickV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/unstick`,method:"POST",format:"json",...params}),discardV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/discard`,method:"POST",format:"json",...params}),setOwnerV1:({id,...query},data,params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/owner`,method:"PUT",body:data,type:"application/json",format:"json",...params}),deleteRedisLockV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/redis-lock`,method:"DELETE",format:"json",...params})};notion={getKikouV1:(params={})=>this.http.request({path:"/v1/notion/kikou",method:"GET",format:"json",...params})};payfit={getChartV1:(query,params={})=>this.http.request({path:"/v1/payfit/chart",method:"GET",query:query,...params})};synchro={getRunStatsV1:(params={})=>this.http.request({path:"/v1/synchro/run/stats",method:"GET",format:"json",...params}),getTasksV1:(query,params={})=>this.http.request({path:"/v1/synchro/tasks",method:"GET",query:query,format:"json",...params}),getJobsDefaultsV1:(params={})=>this.http.request({path:"/v1/synchro/jobs/defaults",method:"GET",format:"json",...params}),putStopTaskV1:({id,...query},params={})=>this.http.request({path:`/v1/synchro/tasks/stop/${id}`,method:"PUT",...params}),resetOwnerStatsV1:({owner,value,...query},params={})=>this.http.request({path:`/v1/synchro/run/stats/${owner}/${value}`,method:"PUT",...params})}}},7936:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{$:()=>AppConfigProvider,M:()=>useAppConfig});var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(3106);const AppConfigCtx=(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(null);const AppConfigProvider=AppConfigCtx.Provider;function useAppConfig(){const config=(0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(AppConfigCtx);if(!config)throw new Error("Called `useAppConfig` outside a `<AppConfigProvider />`");return config}},7034:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{C:()=>Providers});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _airporting_app_front__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1380);var _mantine_core__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(207);var _mantine_modals__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4142);var _mantine_notifications__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(1455);var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(6197);var radash__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9877);var _hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(7936);const theme=(0,_mantine_core__WEBPACK_IMPORTED_MODULE_2__.createTheme)((0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.theme,{components:{}}));const cssVarResolver=x=>(0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.cssVarResolver(x),{dark:{},light:{},variables:{}});function Providers(props){const{children,config,mantine,tanstack}=props;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__.$,{value:config,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClientProvider,{client:tanstack?.queryClient??new _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClient,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_2__.MantineProvider,{theme:theme,cssVariablesResolver:cssVarResolver,defaultColorScheme:mantine?.defaultColorScheme,forceColorScheme:mantine?.forceColorScheme,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_modals__WEBPACK_IMPORTED_MODULE_3__.ModalsProvider,{children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_notifications__WEBPACK_IMPORTED_MODULE_4__.Notifications,{}),children]})})})})}}}]);
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},5893:function(module,__unused_webpack_exports,__webpack_require__){module.exports=__webpack_require__(631)},4148:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{h:()=>useApi});var _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(9056);var _src_hooks_useAppConfig_ts__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(7936);function useApi(){const config=(0,_src_hooks_useAppConfig_ts__WEBPACK_IMPORTED_MODULE_0__.M)();const client=new _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__.eN({baseUrl:config.api.replace(/\/$/,""),baseApiParams:{headers:{Authorization:config.token?`Bearer ${config.token}`:"",From:config.owner}}});return new _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__.eT(client)}},9056:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{eN:()=>HttpClient,eT:()=>TechApi});class HttpClient{baseUrl="";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...fetchParams)=>fetch(...fetchParams);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(apiConfig={}){Object.assign(this,apiConfig)}setSecurityData=data=>{this.securityData=data};encodeQueryParam(key,value){const encodedKey=encodeURIComponent(key);return`${encodedKey}=${encodeURIComponent("number"==typeof value?value:`${value}`)}`}addQueryParam(query,key){return this.encodeQueryParam(key,query[key])}addArrayQueryParam(query,key){const value=query[key];return value.map(v=>this.encodeQueryParam(key,v)).join("&")}toQueryString(rawQuery){const query=rawQuery||{};const keys=Object.keys(query).filter(key=>void 0!==query[key]);return keys.map(key=>Array.isArray(query[key])?this.addArrayQueryParam(query,key):this.addQueryParam(query,key)).join("&")}addQueryParams(rawQuery){const queryString=this.toQueryString(rawQuery);return queryString?`?${queryString}`:""}contentFormatters={["application/json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["application/vnd.api+json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["text/plain"]:input=>null!==input&&"string"!=typeof input?JSON.stringify(input):input,["multipart/form-data"]:input=>{if(input instanceof FormData)return input;return Object.keys(input||{}).reduce((formData,key)=>{const property=input[key];formData.append(key,property instanceof Blob?property:"object"==typeof property&&null!==property?JSON.stringify(property):`${property}`);return formData},new FormData)},["application/x-www-form-urlencoded"]:input=>this.toQueryString(input)};mergeRequestParams(params1,params2){return{...this.baseApiParams,...params1,...params2||{},headers:{...this.baseApiParams.headers||{},...params1.headers||{},...params2&&params2.headers||{}}}}createAbortSignal=cancelToken=>{if(this.abortControllers.has(cancelToken)){const abortController=this.abortControllers.get(cancelToken);if(abortController)return abortController.signal;return}const abortController=new AbortController;this.abortControllers.set(cancelToken,abortController);return abortController.signal};abortRequest=cancelToken=>{const abortController=this.abortControllers.get(cancelToken);if(abortController){abortController.abort();this.abortControllers.delete(cancelToken)}};request=async({body,secure,path,type,query,format,baseUrl,cancelToken,...params})=>{const secureParams=("boolean"==typeof secure?secure:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{};const requestParams=this.mergeRequestParams(params,secureParams);const queryString=query&&this.toQueryString(query);const payloadFormatter=this.contentFormatters[type||"application/json"];const responseFormat=format||requestParams.format;return this.customFetch(`${baseUrl||this.baseUrl||""}${path}${queryString?`?${queryString}`:""}`,{...requestParams,headers:{...requestParams.headers||{},...type&&"multipart/form-data"!==type?{"Content-Type":type}:{}},signal:(cancelToken?this.createAbortSignal(cancelToken):requestParams.signal)||null,body:null==body?null:payloadFormatter(body)}).then(async response=>{const r=response;r.data=null;r.error=null;const responseToParse=responseFormat?response.clone():response;const data=responseFormat?await responseToParse[responseFormat]().then(data=>{if(r.ok)r.data=data;else r.error=data;return r}).catch(e=>{r.error=e;return r}):r;if(cancelToken)this.abortControllers.delete(cancelToken);if(!response.ok)throw data;return data})}}class TechApi{http;constructor(http){this.http=http}status=(params={})=>this.http.request({path:"/status",method:"GET",...params});getDashboard=(params={})=>this.http.request({path:"/dashboard",method:"GET",format:"json",...params});getScrapers=(params={})=>this.http.request({path:"/scrapers",method:"GET",format:"json",...params});getCompanies=(params={})=>this.http.request({path:"/companies",method:"GET",format:"json",...params});webhook={postSmsWebhook:(query,params={})=>this.http.request({path:"/sms/webhook",method:"POST",query:query,...params})};amex={getTransactionsV1:(query,params={})=>this.http.request({path:"/v1/amex/transactions",method:"GET",query:query,...params})};etatSaisie={getLatestV1:(params={})=>this.http.request({path:"/v1/etat-saisie/latest",method:"GET",format:"json",...params}),getDossiersV1:(params={})=>this.http.request({path:"/v1/etat-saisie/dossiers",method:"GET",format:"json",...params}),setManagedV1:({id,...query},data,params={})=>this.http.request({path:`/v1/etat-saisie/dossiers/${id}`,method:"PATCH",body:data,type:"application/json",format:"json",...params}),setResponsableV1:({id,...query},data,params={})=>this.http.request({path:`/v1/etat-saisie/dossiers/${id}/responsable`,method:"PATCH",body:data,type:"application/json",format:"json",...params}),recomputeV1:(params={})=>this.http.request({path:"/v1/etat-saisie/recompute",method:"POST",format:"json",...params})};sales={listLeadsV1:(query,params={})=>this.http.request({path:"/v1/sales/leads",method:"GET",query:query,format:"json",...params}),createLeadV1:(data,params={})=>this.http.request({path:"/v1/sales/leads",method:"POST",body:data,type:"application/json",format:"json",...params}),syncStateV1:(params={})=>this.http.request({path:"/v1/sales/sync-state",method:"GET",format:"json",...params}),getLeadV1:({id,...query},params={})=>this.http.request({path:`/v1/sales/leads/${id}`,method:"GET",format:"json",...params}),updateLeadV1:({id,...query},data,params={})=>this.http.request({path:`/v1/sales/leads/${id}`,method:"PATCH",body:data,type:"application/json",format:"json",...params}),deleteLeadV1:({id,...query},params={})=>this.http.request({path:`/v1/sales/leads/${id}`,method:"DELETE",format:"json",...params}),reconstructV1:({id,...query},params={})=>this.http.request({path:`/v1/sales/leads/${id}/reconstruct`,method:"POST",format:"json",...params}),enrichLeadV1:({id,...query},params={})=>this.http.request({path:`/v1/sales/leads/${id}/enrich`,method:"POST",format:"json",...params}),setLifecycleV1:({id,...query},data,params={})=>this.http.request({path:`/v1/sales/leads/${id}/lifecycle`,method:"POST",body:data,type:"application/json",format:"json",...params}),addCommentV1:({id,...query},data,params={})=>this.http.request({path:`/v1/sales/leads/${id}/comment`,method:"POST",body:data,type:"application/json",format:"json",...params}),rescanV1:(params={})=>this.http.request({path:"/v1/sales/rescan",method:"POST",format:"json",...params}),recordScanRunV1:(data,params={})=>this.http.request({path:"/v1/sales/scan-runs",method:"POST",body:data,type:"application/json",format:"json",...params}),scanRunSummaryV1:(params={})=>this.http.request({path:"/v1/sales/scan-runs/summary",method:"GET",format:"json",...params})};financeJobs={getStockV1:(params={})=>this.http.request({path:"/v1/finance-jobs/stock",method:"GET",format:"json",...params}),listTasksV1:(query,params={})=>this.http.request({path:"/v1/finance-jobs/tasks",method:"GET",query:query,format:"json",...params}),unstickV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/unstick`,method:"POST",format:"json",...params}),retryV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/retry`,method:"POST",format:"json",...params}),discardV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/discard`,method:"POST",format:"json",...params}),setOwnerV1:({id,...query},data,params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/owner`,method:"PUT",body:data,type:"application/json",format:"json",...params}),deleteRedisLockV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/redis-lock`,method:"DELETE",format:"json",...params}),runRecipeV1:(data,params={})=>this.http.request({path:"/v1/finance-jobs/run-recipe",method:"POST",body:data,type:"application/json",format:"json",...params}),getRunnersV1:(params={})=>this.http.request({path:"/v1/finance-jobs/runners",method:"GET",format:"json",...params})};github={getJobsRunnersV1:(params={})=>this.http.request({path:"/v1/github/jobs/runners",method:"GET",format:"json",...params}),getLabelsV1:({host,...query},params={})=>this.http.request({path:`/v1/github/labels/${host}`,method:"GET",format:"json",...params}),getJobLogsV1:(query,params={})=>this.http.request({path:"/v1/github/job-logs",method:"GET",query:query,format:"json",...params})};gsheet={getStockV1:(params={})=>this.http.request({path:"/v1/gsheet/stock",method:"GET",format:"json",...params}),listTasksV1:(query,params={})=>this.http.request({path:"/v1/gsheet/tasks",method:"GET",query:query,format:"json",...params}),unstickV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/unstick`,method:"POST",format:"json",...params}),discardV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/discard`,method:"POST",format:"json",...params}),setOwnerV1:({id,...query},data,params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/owner`,method:"PUT",body:data,type:"application/json",format:"json",...params}),deleteRedisLockV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/redis-lock`,method:"DELETE",format:"json",...params})};mcpAccess={getAccessV1:(params={})=>this.http.request({path:"/v1/mcp-access",method:"GET",format:"json",...params}),getAdminsV1:(params={})=>this.http.request({path:"/v1/mcp-access/admins",method:"GET",format:"json",...params}),setAdminsV1:(data,params={})=>this.http.request({path:"/v1/mcp-access/admins",method:"PUT",body:data,type:"application/json",...params}),setUserAccessV1:({email,...query},data,params={})=>this.http.request({path:`/v1/mcp-access/${email}`,method:"PUT",body:data,type:"application/json",...params})};notion={getKikouV1:(params={})=>this.http.request({path:"/v1/notion/kikou",method:"GET",format:"json",...params})};payfit={getChartV1:(query,params={})=>this.http.request({path:"/v1/payfit/chart",method:"GET",query:query,...params})};synchro={getRunStatsV1:(params={})=>this.http.request({path:"/v1/synchro/run/stats",method:"GET",format:"json",...params}),getTasksV1:(query,params={})=>this.http.request({path:"/v1/synchro/tasks",method:"GET",query:query,format:"json",...params}),getJobsDefaultsV1:(params={})=>this.http.request({path:"/v1/synchro/jobs/defaults",method:"GET",format:"json",...params}),putStopTaskV1:({id,...query},params={})=>this.http.request({path:`/v1/synchro/tasks/stop/${id}`,method:"PUT",...params}),resetOwnerStatsV1:({owner,value,...query},params={})=>this.http.request({path:`/v1/synchro/run/stats/${owner}/${value}`,method:"PUT",...params})}}},7936:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{$:()=>AppConfigProvider,M:()=>useAppConfig});var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(3106);const AppConfigCtx=(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(null);const AppConfigProvider=AppConfigCtx.Provider;function useAppConfig(){const config=(0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(AppConfigCtx);if(!config)throw new Error("Called `useAppConfig` outside a `<AppConfigProvider />`");return config}},7034:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{C:()=>Providers});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _airporting_app_front__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1380);var _mantine_core__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(207);var _mantine_modals__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4142);var _mantine_notifications__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(1455);var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(6197);var radash__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9877);var _hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(7936);const theme=(0,_mantine_core__WEBPACK_IMPORTED_MODULE_2__.createTheme)((0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.theme,{components:{}}));const cssVarResolver=x=>(0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.cssVarResolver(x),{dark:{},light:{},variables:{}});function Providers(props){const{children,config,mantine,tanstack}=props;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__.$,{value:config,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClientProvider,{client:tanstack?.queryClient??new _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClient,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_2__.MantineProvider,{theme:theme,cssVariablesResolver:cssVarResolver,defaultColorScheme:mantine?.defaultColorScheme,forceColorScheme:mantine?.forceColorScheme,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_modals__WEBPACK_IMPORTED_MODULE_3__.ModalsProvider,{children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_notifications__WEBPACK_IMPORTED_MODULE_4__.Notifications,{}),children]})})})})}}}]);
@@ -0,0 +1,8 @@
1
+ export type McpAccessValue = string[] | boolean;
2
+ export type UserAccess = Record<string, McpAccessValue>;
3
+ export type AccessMap = Record<string, UserAccess>;
4
+ export type KnownSlugs = Record<string, string[]>;
5
+ export type SetUserAccessArgs = {
6
+ email: string;
7
+ access: UserAccess;
8
+ };
@@ -0,0 +1,2 @@
1
+ import { SetUserAccessArgs } from './mcpAccess.types.ts';
2
+ export declare function useSetUserAccess(): import("@tanstack/react-query").UseMutationResult<void, Error, SetUserAccessArgs, unknown>;
@@ -0,0 +1 @@
1
+ export declare function useMcpAccessQuery(): import("@tanstack/react-query").UseQueryResult<import("../../gen/TechApi").GetMcpAccessResponse, Error>;
@@ -0,0 +1,8 @@
1
+ export type EnrichLeadResult = {
2
+ found: {
3
+ emails: string[];
4
+ phones: string[];
5
+ };
6
+ added: number;
7
+ };
8
+ export declare function useEnrichLead(id: number): import("@tanstack/react-query").UseMutationResult<EnrichLeadResult, Error, void, unknown>;
@@ -0,0 +1 @@
1
+ export declare function McpAccessApp(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ type SourceIconProps = {
2
+ source: string;
3
+ size?: number;
4
+ };
5
+ export declare function LemlistIcon({ size }: {
6
+ size?: number;
7
+ }): import("react/jsx-runtime").JSX.Element;
8
+ export declare function SourceIcon({ source, size }: SourceIconProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -53,6 +53,17 @@ export interface DiscardV1Params {
53
53
  export interface DiscardV1Params2 {
54
54
  id: number;
55
55
  }
56
+ export interface EnrichFound {
57
+ emails: string[];
58
+ phones: string[];
59
+ }
60
+ export interface EnrichLeadResponse {
61
+ added: number;
62
+ found: EnrichFound;
63
+ }
64
+ export interface EnrichLeadV1Params {
65
+ id: number;
66
+ }
56
67
  export interface EtatSaisieCustomerRow {
57
68
  client: string;
58
69
  devise: string;
@@ -198,6 +209,10 @@ export interface FinanceJobsTaskItem {
198
209
  updated: string;
199
210
  worksheet: string | null;
200
211
  }
212
+ export interface GetAdminsResponse {
213
+ admins: string[];
214
+ canEdit: boolean;
215
+ }
201
216
  export interface GetChartQuery {
202
217
  absoluteMonth?: number;
203
218
  loadedDateAfter?: string;
@@ -338,6 +353,14 @@ export interface GetLabelsV1Params {
338
353
  export interface GetLeadV1Params {
339
354
  id: number;
340
355
  }
356
+ export interface GetMcpAccessResponse {
357
+ accessMap: object;
358
+ admins: string[];
359
+ canEdit: boolean;
360
+ knownSlugs: object;
361
+ mcpNames: string[];
362
+ multiDossierMcps: string[];
363
+ }
341
364
  export interface GetNotionDashboardResponse {
342
365
  bugs: string[][];
343
366
  users: NotionUser[];
@@ -605,6 +628,9 @@ export interface ScraperPennylane {
605
628
  isTooOld: boolean;
606
629
  lastTime: string;
607
630
  }
631
+ export interface SetAdminsBody {
632
+ admins: string[];
633
+ }
608
634
  export interface SetFinanceJobsOwnerBody {
609
635
  owner: string;
610
636
  }
@@ -638,6 +664,12 @@ export interface SetResponsableBody {
638
664
  export interface SetResponsableV1Params {
639
665
  id: number;
640
666
  }
667
+ export interface SetUserAccessBody {
668
+ access: object;
669
+ }
670
+ export interface SetUserAccessV1Params {
671
+ email: string;
672
+ }
641
673
  export interface SobankAccountItem {
642
674
  account: string;
643
675
  balance: number;
@@ -933,6 +965,22 @@ export declare namespace Sales {
933
965
  type RequestHeaders = {};
934
966
  type ResponseBody = OkResponse;
935
967
  }
968
+ /**
969
+ * No description
970
+ * @tags Sales
971
+ * @name EnrichLeadV1
972
+ * @request POST:/v1/sales/leads/{id}/enrich
973
+ * @response `201` `EnrichLeadResponse`
974
+ */
975
+ namespace EnrichLeadV1 {
976
+ type RequestParams = {
977
+ id: number;
978
+ };
979
+ type RequestQuery = {};
980
+ type RequestBody = never;
981
+ type RequestHeaders = {};
982
+ type ResponseBody = EnrichLeadResponse;
983
+ }
936
984
  /**
937
985
  * No description
938
986
  * @tags Sales
@@ -1307,6 +1355,74 @@ export declare namespace Gsheet {
1307
1355
  type ResponseBody = DeleteRedisLockResponse;
1308
1356
  }
1309
1357
  }
1358
+ export declare namespace McpAccess {
1359
+ /**
1360
+ * No description
1361
+ * @tags McpAccess
1362
+ * @name GetAccessV1
1363
+ * @request GET:/v1/mcp-access
1364
+ * @response `200` `GetMcpAccessResponse`
1365
+ */
1366
+ namespace GetAccessV1 {
1367
+ type RequestParams = {};
1368
+ type RequestQuery = {};
1369
+ type RequestBody = never;
1370
+ type RequestHeaders = {
1371
+ from: string;
1372
+ };
1373
+ type ResponseBody = GetMcpAccessResponse;
1374
+ }
1375
+ /**
1376
+ * No description
1377
+ * @tags McpAccess
1378
+ * @name GetAdminsV1
1379
+ * @request GET:/v1/mcp-access/admins
1380
+ * @response `200` `GetAdminsResponse`
1381
+ */
1382
+ namespace GetAdminsV1 {
1383
+ type RequestParams = {};
1384
+ type RequestQuery = {};
1385
+ type RequestBody = never;
1386
+ type RequestHeaders = {
1387
+ from: string;
1388
+ };
1389
+ type ResponseBody = GetAdminsResponse;
1390
+ }
1391
+ /**
1392
+ * No description
1393
+ * @tags McpAccess
1394
+ * @name SetAdminsV1
1395
+ * @request PUT:/v1/mcp-access/admins
1396
+ * @response `200` `void`
1397
+ */
1398
+ namespace SetAdminsV1 {
1399
+ type RequestParams = {};
1400
+ type RequestQuery = {};
1401
+ type RequestBody = SetAdminsBody;
1402
+ type RequestHeaders = {
1403
+ from: string;
1404
+ };
1405
+ type ResponseBody = void;
1406
+ }
1407
+ /**
1408
+ * No description
1409
+ * @tags McpAccess
1410
+ * @name SetUserAccessV1
1411
+ * @request PUT:/v1/mcp-access/{email}
1412
+ * @response `200` `void`
1413
+ */
1414
+ namespace SetUserAccessV1 {
1415
+ type RequestParams = {
1416
+ email: string;
1417
+ };
1418
+ type RequestQuery = {};
1419
+ type RequestBody = SetUserAccessBody;
1420
+ type RequestHeaders = {
1421
+ from: string;
1422
+ };
1423
+ type ResponseBody = void;
1424
+ }
1425
+ }
1310
1426
  export declare namespace Notion {
1311
1427
  /**
1312
1428
  * No description
@@ -1666,6 +1782,15 @@ export declare class TechApi<SecurityDataType extends unknown> {
1666
1782
  * @response `201` `OkResponse`
1667
1783
  */
1668
1784
  reconstructV1: ({ id, ...query }: ReconstructV1Params, params?: RequestParams) => Promise<HttpResponse<OkResponse, any>>;
1785
+ /**
1786
+ * No description
1787
+ *
1788
+ * @tags Sales
1789
+ * @name EnrichLeadV1
1790
+ * @request POST:/v1/sales/leads/{id}/enrich
1791
+ * @response `201` `EnrichLeadResponse`
1792
+ */
1793
+ enrichLeadV1: ({ id, ...query }: EnrichLeadV1Params, params?: RequestParams) => Promise<HttpResponse<EnrichLeadResponse, any>>;
1669
1794
  /**
1670
1795
  * No description
1671
1796
  *
@@ -1880,6 +2005,44 @@ export declare class TechApi<SecurityDataType extends unknown> {
1880
2005
  */
1881
2006
  deleteRedisLockV1: ({ id, ...query }: DeleteRedisLockV1Params2, params?: RequestParams) => Promise<HttpResponse<DeleteRedisLockResponse, any>>;
1882
2007
  };
2008
+ mcpAccess: {
2009
+ /**
2010
+ * No description
2011
+ *
2012
+ * @tags McpAccess
2013
+ * @name GetAccessV1
2014
+ * @request GET:/v1/mcp-access
2015
+ * @response `200` `GetMcpAccessResponse`
2016
+ */
2017
+ getAccessV1: (params?: RequestParams) => Promise<HttpResponse<GetMcpAccessResponse, any>>;
2018
+ /**
2019
+ * No description
2020
+ *
2021
+ * @tags McpAccess
2022
+ * @name GetAdminsV1
2023
+ * @request GET:/v1/mcp-access/admins
2024
+ * @response `200` `GetAdminsResponse`
2025
+ */
2026
+ getAdminsV1: (params?: RequestParams) => Promise<HttpResponse<GetAdminsResponse, any>>;
2027
+ /**
2028
+ * No description
2029
+ *
2030
+ * @tags McpAccess
2031
+ * @name SetAdminsV1
2032
+ * @request PUT:/v1/mcp-access/admins
2033
+ * @response `200` `void`
2034
+ */
2035
+ setAdminsV1: (data: SetAdminsBody, params?: RequestParams) => Promise<HttpResponse<void, any>>;
2036
+ /**
2037
+ * No description
2038
+ *
2039
+ * @tags McpAccess
2040
+ * @name SetUserAccessV1
2041
+ * @request PUT:/v1/mcp-access/{email}
2042
+ * @response `200` `void`
2043
+ */
2044
+ setUserAccessV1: ({ email, ...query }: SetUserAccessV1Params, data: SetUserAccessBody, params?: RequestParams) => Promise<HttpResponse<void, any>>;
2045
+ };
1883
2046
  notion: {
1884
2047
  /**
1885
2048
  * No description
@@ -0,0 +1,2 @@
1
+ import { ProvidersProps } from '@/src/providers.tsx';
2
+ export default function McpAccess(props: ProvidersProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './compiled-types/tabs/mcpAccess';
2
+ export { default } from './compiled-types/tabs/mcpAccess';
@@ -1,3 +1,3 @@
1
1
 
2
- export type RemoteKeys = 'REMOTE_ALIAS_IDENTIFIER/amex' | 'REMOTE_ALIAS_IDENTIFIER/bnpp' | 'REMOTE_ALIAS_IDENTIFIER/credmut' | 'REMOTE_ALIAS_IDENTIFIER/dashboard' | 'REMOTE_ALIAS_IDENTIFIER/etat-saisie' | 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' | 'REMOTE_ALIAS_IDENTIFIER/github' | 'REMOTE_ALIAS_IDENTIFIER/payfit' | 'REMOTE_ALIAS_IDENTIFIER/sales' | 'REMOTE_ALIAS_IDENTIFIER/scrapers' | 'REMOTE_ALIAS_IDENTIFIER/spendesk' | 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' | 'REMOTE_ALIAS_IDENTIFIER/synchro' | 'REMOTE_ALIAS_IDENTIFIER/wise';
3
- type PackageType<T> = T extends 'REMOTE_ALIAS_IDENTIFIER/wise' ? typeof import('REMOTE_ALIAS_IDENTIFIER/wise') :T extends 'REMOTE_ALIAS_IDENTIFIER/synchro' ? typeof import('REMOTE_ALIAS_IDENTIFIER/synchro') :T extends 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spreadsheet') :T extends 'REMOTE_ALIAS_IDENTIFIER/spendesk' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spendesk') :T extends 'REMOTE_ALIAS_IDENTIFIER/scrapers' ? typeof import('REMOTE_ALIAS_IDENTIFIER/scrapers') :T extends 'REMOTE_ALIAS_IDENTIFIER/sales' ? typeof import('REMOTE_ALIAS_IDENTIFIER/sales') :T extends 'REMOTE_ALIAS_IDENTIFIER/payfit' ? typeof import('REMOTE_ALIAS_IDENTIFIER/payfit') :T extends 'REMOTE_ALIAS_IDENTIFIER/github' ? typeof import('REMOTE_ALIAS_IDENTIFIER/github') :T extends 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' ? typeof import('REMOTE_ALIAS_IDENTIFIER/finance-jobs') :T extends 'REMOTE_ALIAS_IDENTIFIER/etat-saisie' ? typeof import('REMOTE_ALIAS_IDENTIFIER/etat-saisie') :T extends 'REMOTE_ALIAS_IDENTIFIER/dashboard' ? typeof import('REMOTE_ALIAS_IDENTIFIER/dashboard') :T extends 'REMOTE_ALIAS_IDENTIFIER/credmut' ? typeof import('REMOTE_ALIAS_IDENTIFIER/credmut') :T extends 'REMOTE_ALIAS_IDENTIFIER/bnpp' ? typeof import('REMOTE_ALIAS_IDENTIFIER/bnpp') :T extends 'REMOTE_ALIAS_IDENTIFIER/amex' ? typeof import('REMOTE_ALIAS_IDENTIFIER/amex') :any;
2
+ export type RemoteKeys = 'REMOTE_ALIAS_IDENTIFIER/amex' | 'REMOTE_ALIAS_IDENTIFIER/bnpp' | 'REMOTE_ALIAS_IDENTIFIER/credmut' | 'REMOTE_ALIAS_IDENTIFIER/dashboard' | 'REMOTE_ALIAS_IDENTIFIER/etat-saisie' | 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' | 'REMOTE_ALIAS_IDENTIFIER/github' | 'REMOTE_ALIAS_IDENTIFIER/mcp-access' | 'REMOTE_ALIAS_IDENTIFIER/payfit' | 'REMOTE_ALIAS_IDENTIFIER/sales' | 'REMOTE_ALIAS_IDENTIFIER/scrapers' | 'REMOTE_ALIAS_IDENTIFIER/spendesk' | 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' | 'REMOTE_ALIAS_IDENTIFIER/synchro' | 'REMOTE_ALIAS_IDENTIFIER/wise';
3
+ type PackageType<T> = T extends 'REMOTE_ALIAS_IDENTIFIER/wise' ? typeof import('REMOTE_ALIAS_IDENTIFIER/wise') :T extends 'REMOTE_ALIAS_IDENTIFIER/synchro' ? typeof import('REMOTE_ALIAS_IDENTIFIER/synchro') :T extends 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spreadsheet') :T extends 'REMOTE_ALIAS_IDENTIFIER/spendesk' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spendesk') :T extends 'REMOTE_ALIAS_IDENTIFIER/scrapers' ? typeof import('REMOTE_ALIAS_IDENTIFIER/scrapers') :T extends 'REMOTE_ALIAS_IDENTIFIER/sales' ? typeof import('REMOTE_ALIAS_IDENTIFIER/sales') :T extends 'REMOTE_ALIAS_IDENTIFIER/payfit' ? typeof import('REMOTE_ALIAS_IDENTIFIER/payfit') :T extends 'REMOTE_ALIAS_IDENTIFIER/mcp-access' ? typeof import('REMOTE_ALIAS_IDENTIFIER/mcp-access') :T extends 'REMOTE_ALIAS_IDENTIFIER/github' ? typeof import('REMOTE_ALIAS_IDENTIFIER/github') :T extends 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' ? typeof import('REMOTE_ALIAS_IDENTIFIER/finance-jobs') :T extends 'REMOTE_ALIAS_IDENTIFIER/etat-saisie' ? typeof import('REMOTE_ALIAS_IDENTIFIER/etat-saisie') :T extends 'REMOTE_ALIAS_IDENTIFIER/dashboard' ? typeof import('REMOTE_ALIAS_IDENTIFIER/dashboard') :T extends 'REMOTE_ALIAS_IDENTIFIER/credmut' ? typeof import('REMOTE_ALIAS_IDENTIFIER/credmut') :T extends 'REMOTE_ALIAS_IDENTIFIER/bnpp' ? typeof import('REMOTE_ALIAS_IDENTIFIER/bnpp') :T extends 'REMOTE_ALIAS_IDENTIFIER/amex' ? typeof import('REMOTE_ALIAS_IDENTIFIER/amex') :any;
Binary file
@@ -0,0 +1 @@
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["6215"],{1354:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{m:()=>PageHeader});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(9632);var react__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3106);function formatRelative(now,then){const seconds=Math.max(0,Math.floor((now-then)/1e3));if(seconds<5)return"\xe0 l’instant";if(seconds<60)return`il y a ${seconds}s`;const minutes=Math.floor(seconds/60);if(minutes<60)return`il y a ${minutes} min`;const hours=Math.floor(minutes/60);return`il y a ${hours} h`}function PageHeader({title,leading,badge,updatedAt,isFetching,isError,onRefresh,actions}){const[now,setNow]=(0,react__WEBPACK_IMPORTED_MODULE_3__.useState)(()=>Date.now());(0,react__WEBPACK_IMPORTED_MODULE_3__.useEffect)(()=>{if(!updatedAt)return;const id=window.setInterval(()=>setNow(Date.now()),1e3);return()=>window.clearInterval(id)},[updatedAt]);const relative=updatedAt?formatRelative(now,updatedAt):null;const color=isError?"orange":isFetching?"teal":"dimmed";return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{justify:"space-between",align:"center",mih:48,mb:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[leading,/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Title,{order:2,children:title}),badge]}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[relative&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Text,{size:"xs",c:color,fw:isFetching?600:400,"data-testid":"page-header-freshness",children:isError?"\xe9chec maj":isFetching?"maj…":relative}),onRefresh&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Tooltip,{label:"Rafra\xeechir",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.ActionIcon,{variant:"default",size:"md",onClick:onRefresh,loading:isFetching,"aria-label":"Refresh",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__.IconRefresh,{size:16})})}),actions]})]})}},8908:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>McpAccess});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useMcpAccessQuery(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","mcp-access"],queryFn:async()=>(await api.mcpAccess.getAccessV1()).data,refetchOnWindowFocus:true})}function useInvalidate(){const queryClient=(0,modern_index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","mcp-access"]})}function useSetUserAccess(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async({email,access})=>(await api.mcpAccess.setUserAccessV1({email},{access})).data,onSuccess:invalidate})}var PageHeader=__webpack_require__(1354);function isRevocation(value){if(null===value||false===value)return true;if(Array.isArray(value)&&0===value.length)return true;return false}function McpAccessApp(){const query=useMcpAccessQuery();const data=query.data;const setAccess=useSetUserAccess();const accessMap=data?.accessMap??{};const knownSlugs=data?.knownSlugs??{};const mcpNames=data?.mcpNames??[];const multiDossierMcps=data?.multiDossierMcps??[];const canEdit=data?.canEdit??false;const emails=Object.keys(accessMap).sort();function updateCell(email,mcp,value){if(!canEdit)return;if(isRevocation(value)){const ok=window.confirm(`Retirer l'acc\xe8s ${mcp} \xe0 ${email} ?`);if(!ok)return}const next={...accessMap[email]??{}};if(isRevocation(value))delete next[mcp];else next[mcp]=value;setAccess.mutate({email,access:next})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{fluid:true,my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(PageHeader.m,{title:"Acc\xe8s MCP",updatedAt:query.dataUpdatedAt,isFetching:query.isFetching,isError:query.isError,onRefresh:()=>query.refetch()}),!canEdit&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",fz:"sm",mb:"sm",children:"Lecture seule (non-admin)"}),data?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.ScrollContainer,{minWidth:1200,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{withTableBorder:true,withColumnBorders:true,stickyHeader: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:"Utilisateur"}),mcpNames.map(mcp=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:mcp},mcp))]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:emails.map(email=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:email}),mcpNames.map(mcp=>{const entry=accessMap[email]?.[mcp];if(multiDossierMcps.includes(mcp)){const slugs=Array.isArray(entry)?entry:[];return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TagsInput,{value:slugs,data:knownSlugs[mcp]??[],disabled:!canEdit,placeholder:"slugs ou *",onChange:value=>updateCell(email,mcp,value)})},mcp)}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Switch,{checked:true===entry,disabled:!canEdit,onChange:event=>updateCell(email,mcp,event.currentTarget.checked)})},mcp)})]},email))})]})}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Chargement…"})]})}var providers=__webpack_require__(7034);function McpAccess(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(McpAccessApp,{})})})}}}]);
@@ -1 +1 @@
1
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["610"],{3897:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{O:()=>BrandLogo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(243);function BrandLogo({domain,alt,size=24}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Image,{src:(0,_src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__.j)(domain),alt:alt,title:alt,w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}},243:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{j:()=>logoDevUrl});const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}},8034:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Sales});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(3863);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useSalesLeads(status){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sales","leads",status],queryFn:async()=>(await api.sales.listLeadsV1({status})).data,refetchOnWindowFocus:true})}var notifications_esm_index_mjs_=__webpack_require__(1455);function useSalesRescan(){const api=(0,useApi.h)();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\xe9",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??"\xc9chec du re-scan",color:"red"})}})}function useSalesSyncState(){const api=(0,useApi.h)();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.h)();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"\xe0 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)}const TEMPERATURE_META={burning:{emoji:"\uD83D\uDD25\uD83D\uDD25",label:"Br\xfblant",order:5},hot:{emoji:"\uD83D\uDD25",label:"Chaud",order:4},warm:{emoji:"\uD83C\uDF21️",label:"Ti\xe8de",order:3},cold:{emoji:"❄️",label:"Froid",order:2},frozen:{emoji:"\uD83E\uDDCA",label:"Gel\xe9",order:1}};const TEMPERATURE_ORDER=["burning","hot","warm","cold","frozen"];function dueLabel(value){if(!value)return"Pas de date fix\xe9e";return new Date(value).toLocaleDateString("fr-FR",{timeZone:"Europe/Paris"})}function compare(a,b,key,desc){let av;let bv;if("temperature"===key){av=TEMPERATURE_META[a.temperature].order;bv=TEMPERATURE_META[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\xe9rature"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Pr\xe9nom"}),/*#__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:"\xc9ch\xe9ance"})})]})}),/*#__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:TEMPERATURE_META[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__(9038);function useSalesLead(id){const api=(0,useApi.h)();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.h)();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\xe9es",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la mise \xe0 jour",color:"red"})}})}function useDeleteLead(){const api=(0,useApi.h)();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\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la suppression",color:"red"})}})}function useSetLifecycle(id){const api=(0,useApi.h)();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 \xe0 jour",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec",color:"red"})}})}function useAddComment(id){const api=(0,useApi.h)();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\xe9",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??"\xc9chec",color:"red"})}})}function useReconstructLead(id){const api=(0,useApi.h)();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\xe9 — trait\xe9 \xe0 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??"\xc9chec",color:"red"})}})}var tabler_icons_react_mjs_=__webpack_require__(9632);var BrandLogo=__webpack_require__(3897);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.O,{domain:domain,alt:source,size:size})}function directionLabel(direction){if("internal"===direction)return"\uD83D\uDCDD 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 \xe9change."});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\xe9sum\xe9)",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 \u{2248} ${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[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\xe9nom",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\xe9l\xe9phone",value:phone,onChange:e=>setPhone(e.currentTarget.value)})]}),/*#__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:"\xc9ch\xe9ance",placeholder:"Pas de date fix\xe9e",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\xe9rature",data:TEMPERATURE_ORDER.map(t=>({value:t,label:`${TEMPERATURE_META[t].emoji} ${TEMPERATURE_META[t].label}`})),value:temperature,onChange:setTemperature}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"D\xe9placer vers",data:[{value:"active",label:"Actif"},{value:"won",label:"Gagn\xe9"},{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__(5021);function useCreateLead(){const api=(0,useApi.h)();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\xe9e d\xe9j\xe0 connue — rattach\xe9 au lead existant":"Lead cr\xe9\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la cr\xe9ation",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\xe9e",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\xe9nom",...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\xe9l\xe9phone",...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\xe9e",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\xe9er"})]})]})})})}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=useSalesLeads(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:"Sales"}),/*#__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\xe9ratures",clearable:true,data:TEMPERATURE_ORDER.map(t=>({value:t,label:`${TEMPERATURE_META[t].emoji} ${TEMPERATURE_META[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",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 \u{2248} ${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\xe9s",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.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(SalesApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["610"],{3897:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{O:()=>BrandLogo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(243);function BrandLogo({domain,alt,size=24}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Image,{src:(0,_src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__.j)(domain),alt:alt,title:alt,w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}},243:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{j:()=>logoDevUrl});const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}},9147:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Sales});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(3863);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useSalesLeads(status){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sales","leads",status],queryFn:async()=>(await api.sales.listLeadsV1({status})).data,refetchOnWindowFocus:true})}var notifications_esm_index_mjs_=__webpack_require__(1455);function useSalesRescan(){const api=(0,useApi.h)();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\xe9",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??"\xc9chec du re-scan",color:"red"})}})}function useSalesSyncState(){const api=(0,useApi.h)();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.h)();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"\xe0 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)}const TEMPERATURE_META={burning:{emoji:"\uD83D\uDD25\uD83D\uDD25",label:"Br\xfblant",order:5},hot:{emoji:"\uD83D\uDD25",label:"Chaud",order:4},warm:{emoji:"\uD83C\uDF21️",label:"Ti\xe8de",order:3},cold:{emoji:"❄️",label:"Froid",order:2},frozen:{emoji:"\uD83E\uDDCA",label:"Gel\xe9",order:1}};const TEMPERATURE_ORDER=["burning","hot","warm","cold","frozen"];function dueLabel(value){if(!value)return"Pas de date fix\xe9e";return new Date(value).toLocaleDateString("fr-FR",{timeZone:"Europe/Paris"})}function compare(a,b,key,desc){let av;let bv;if("temperature"===key){av=TEMPERATURE_META[a.temperature].order;bv=TEMPERATURE_META[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\xe9rature"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Pr\xe9nom"}),/*#__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:"\xc9ch\xe9ance"})})]})}),/*#__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:TEMPERATURE_META[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__(9038);function useSalesLead(id){const api=(0,useApi.h)();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.h)();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\xe9es",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la mise \xe0 jour",color:"red"})}})}function useDeleteLead(){const api=(0,useApi.h)();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\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la suppression",color:"red"})}})}function useSetLifecycle(id){const api=(0,useApi.h)();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 \xe0 jour",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec",color:"red"})}})}function useAddComment(id){const api=(0,useApi.h)();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\xe9",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??"\xc9chec",color:"red"})}})}function useReconstructLead(id){const api=(0,useApi.h)();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\xe9 — trait\xe9 \xe0 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??"\xc9chec",color:"red"})}})}function useEnrichLead(id){const api=(0,useApi.h)();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__(9632);var BrandLogo=__webpack_require__(3897);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.O,{domain:domain,alt:source,size:size})}function directionLabel(direction){if("internal"===direction)return"\uD83D\uDCDD 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 \xe9change."});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\xe9sum\xe9)",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 \u{2248} ${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\xe9nom",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\xe9l\xe9phone",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\xe9e trouv\xe9e",color:"gray"})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Enrichissement",message:err?.error?.error??err?.message??"\xc9chec",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:"\xc9ch\xe9ance",placeholder:"Pas de date fix\xe9e",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\xe9rature",data:TEMPERATURE_ORDER.map(t=>({value:t,label:`${TEMPERATURE_META[t].emoji} ${TEMPERATURE_META[t].label}`})),value:temperature,onChange:setTemperature}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"D\xe9placer vers",data:[{value:"active",label:"Actif"},{value:"won",label:"Gagn\xe9"},{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__(5021);function useCreateLead(){const api=(0,useApi.h)();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\xe9e d\xe9j\xe0 connue — rattach\xe9 au lead existant":"Lead cr\xe9\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la cr\xe9ation",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\xe9e",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\xe9nom",...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\xe9l\xe9phone",...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\xe9e",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\xe9er"})]})]})})})}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=useSalesLeads(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:"Sales"}),/*#__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\xe9ratures",clearable:true,data:TEMPERATURE_ORDER.map(t=>({value:t,label:`${TEMPERATURE_META[t].emoji} ${TEMPERATURE_META[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 \u{2248} ${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\xe9s",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.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(SalesApp,{})})})}}}]);