@airporting/tech-app 0.0.154 → 0.0.156

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}),setConnectorManagedV1:({id,provider,...query},data,params={})=>this.http.request({path:`/v1/etat-saisie/dossiers/${id}/connectors/${provider}`,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}),setReconciliationMuteV1:(data,params={})=>this.http.request({path:"/v1/etat-saisie/reconciliation-mute",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",query:query,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}),listDealsV1:(query,params={})=>this.http.request({path:"/v1/sales/deals",method:"GET",query:query,format:"json",...params}),createDealV1:(data,params={})=>this.http.request({path:"/v1/sales/deals",method:"POST",body:data,type:"application/json",format:"json",...params}),updateDealV1:({id,...query},data,params={})=>this.http.request({path:`/v1/sales/deals/${id}`,method:"PATCH",body:data,type:"application/json",format:"json",...params}),deleteDealV1:({id,...query},params={})=>this.http.request({path:`/v1/sales/deals/${id}`,method:"DELETE",format:"json",...params}),exportDealsV1:(params={})=>this.http.request({path:"/v1/sales/deals/export",method:"POST",format:"json",...params})};financeJobs={getStockV1:(query,params={})=>this.http.request({path:"/v1/finance-jobs/stock",method:"GET",query:query,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:(query,params={})=>this.http.request({path:"/v1/gsheet/stock",method:"GET",query:query,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})};connectorToken={getConnectorToken:(params={})=>this.http.request({path:"/internal/connector-token",method:"GET",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}),deleteUserAccessV1:({email,...query},params={})=>this.http.request({path:`/v1/mcp-access/${email}`,method:"DELETE",...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})};usage={getChargeV1:(query,params={})=>this.http.request({path:"/v1/usage/charge",method:"GET",query:query,format:"json",...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__(5850);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,{position:"top-right",zIndex:400}),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}),setConnectorManagedV1:({id,provider,...query},data,params={})=>this.http.request({path:`/v1/etat-saisie/dossiers/${id}/connectors/${provider}`,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}),setReconciliationMuteV1:(data,params={})=>this.http.request({path:"/v1/etat-saisie/reconciliation-mute",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",query:query,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}),listDealsV1:(query,params={})=>this.http.request({path:"/v1/sales/deals",method:"GET",query:query,format:"json",...params}),listDealStagesV1:(params={})=>this.http.request({path:"/v1/sales/deal-stages",method:"GET",format:"json",...params}),createDealV1:(data,params={})=>this.http.request({path:"/v1/sales/deals",method:"POST",body:data,type:"application/json",format:"json",...params}),updateDealV1:({id,...query},data,params={})=>this.http.request({path:`/v1/sales/deals/${id}`,method:"PATCH",body:data,type:"application/json",format:"json",...params}),deleteDealV1:({id,...query},params={})=>this.http.request({path:`/v1/sales/deals/${id}`,method:"DELETE",format:"json",...params}),exportDealsV1:(params={})=>this.http.request({path:"/v1/sales/deals/export",method:"POST",format:"json",...params})};financeJobs={getStockV1:(query,params={})=>this.http.request({path:"/v1/finance-jobs/stock",method:"GET",query:query,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:(query,params={})=>this.http.request({path:"/v1/gsheet/stock",method:"GET",query:query,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})};connectorToken={getConnectorToken:(params={})=>this.http.request({path:"/internal/connector-token",method:"GET",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}),deleteUserAccessV1:({email,...query},params={})=>this.http.request({path:`/v1/mcp-access/${email}`,method:"DELETE",...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})};usage={getChargeV1:(query,params={})=>this.http.request({path:"/v1/usage/charge",method:"GET",query:query,format:"json",...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__(5850);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,{position:"top-right",zIndex:400}),children]})})})})}}}]);
@@ -0,0 +1,7 @@
1
+ import { DealStagesResponse } from '@/src/apps/pipeline/types.ts';
2
+ /**
3
+ * Toutes les etapes des deux pipelines, y compris celles du pipeline qui n'est
4
+ * pas affiche. Ces donnees ne changent quasiment jamais, on evite donc tout
5
+ * refetch agressif et on les garde fraiches une heure.
6
+ */
7
+ export declare function useSalesDealStages(): import("@tanstack/react-query").UseQueryResult<DealStagesResponse, Error>;
@@ -8,6 +8,19 @@ export type DealStageItem = {
8
8
  deal_count: number;
9
9
  total_value: number;
10
10
  };
11
+ /**
12
+ * Etape telle que la renvoie GET /v1/sales/deal-stages : toutes les etapes des
13
+ * deux pipelines, chacune portant le pipeline auquel elle appartient.
14
+ */
15
+ export type PipelineStageItem = {
16
+ id: number;
17
+ name: string;
18
+ order_nr: number;
19
+ pipeline: SalesPipeline;
20
+ };
21
+ export type DealStagesResponse = {
22
+ stages: PipelineStageItem[];
23
+ };
11
24
  export type DealLead = {
12
25
  id: number;
13
26
  first_name: string | null;
@@ -0,0 +1,3 @@
1
+ export declare function GmailIcon(props: {
2
+ size?: number;
3
+ }): import("react").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare function GoogleSheetsIcon(props: {
2
+ size?: number;
3
+ }): import("react").JSX.Element;
@@ -445,6 +445,9 @@ export interface GetPayfitDashboardResponse {
445
445
  export interface GetRunStatsResponse {
446
446
  currentJobsCounters: UsersRunStatsResponse;
447
447
  }
448
+ export interface GetSalesDealStagesResponse {
449
+ stages: SalesDealStageWithPipelineItem[];
450
+ }
448
451
  export interface GetSalesDealsResponse {
449
452
  deals: SalesDealItem[];
450
453
  stages: SalesDealStageItem[];
@@ -717,6 +720,12 @@ export interface SalesDealStageItem {
717
720
  order_nr: number;
718
721
  total_value: number;
719
722
  }
723
+ export interface SalesDealStageWithPipelineItem {
724
+ id: number;
725
+ name: string;
726
+ order_nr: number;
727
+ pipeline: string;
728
+ }
720
729
  export interface SalesIdentityItem {
721
730
  type: string;
722
731
  value: string;
@@ -1367,6 +1376,20 @@ export declare namespace Sales {
1367
1376
  type RequestHeaders = {};
1368
1377
  type ResponseBody = GetSalesDealsResponse;
1369
1378
  }
1379
+ /**
1380
+ * No description
1381
+ * @tags Sales
1382
+ * @name ListDealStagesV1
1383
+ * @request GET:/v1/sales/deal-stages
1384
+ * @response `200` `GetSalesDealStagesResponse`
1385
+ */
1386
+ namespace ListDealStagesV1 {
1387
+ type RequestParams = {};
1388
+ type RequestQuery = {};
1389
+ type RequestBody = never;
1390
+ type RequestHeaders = {};
1391
+ type ResponseBody = GetSalesDealStagesResponse;
1392
+ }
1370
1393
  /**
1371
1394
  * No description
1372
1395
  * @tags Sales
@@ -2298,6 +2321,15 @@ export declare class TechApi<SecurityDataType extends unknown> {
2298
2321
  * @response `200` `GetSalesDealsResponse`
2299
2322
  */
2300
2323
  listDealsV1: (query: ListDealsV1Params, params?: RequestParams) => Promise<HttpResponse<GetSalesDealsResponse, any>>;
2324
+ /**
2325
+ * No description
2326
+ *
2327
+ * @tags Sales
2328
+ * @name ListDealStagesV1
2329
+ * @request GET:/v1/sales/deal-stages
2330
+ * @response `200` `GetSalesDealStagesResponse`
2331
+ */
2332
+ listDealStagesV1: (params?: RequestParams) => Promise<HttpResponse<GetSalesDealStagesResponse, any>>;
2301
2333
  /**
2302
2334
  * No description
2303
2335
  *
@@ -1,2 +1,2 @@
1
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["6215"],{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}})}},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__(5850);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]})]})}},9781:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{h:()=>QuickBooksIcon});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);function QuickBooksIcon(props){const size=props.size??20;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("svg",{width:size,height:size,viewBox:"0 0 24 24",role:"img","aria-label":"QuickBooks",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("title",{children:"QuickBooks"}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("circle",{cx:"12",cy:"12",r:"12",fill:"#2CA01C"}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("text",{x:"12",y:"16.5",textAnchor:"middle",fontSize:"12",fontWeight:"700",fill:"#ffffff",fontFamily:"Arial, Helvetica, sans-serif",children:"qb"})]})}},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}`}},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 consume_shared_module_default_react_strict_=__webpack_require__(5850);var index_mjs_=__webpack_require__(207);var index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useMcpAccessQuery(){const api=(0,useApi.h)();return(0,index_js_.useQuery)({queryKey:["tech","mcp-access"],queryFn:async()=>(await api.mcpAccess.getAccessV1()).data,refetchOnWindowFocus:true})}function useInvalidate(){const queryClient=(0,index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","mcp-access"]})}function useSetUserAccess(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,index_js_.useMutation)({mutationFn:async({email,access})=>(await api.mcpAccess.setUserAccessV1({email},{access})).data,onSuccess:invalidate})}var PageHeader=__webpack_require__(1354);var BrandLogo=__webpack_require__(3897);var QuickBooksIcon=__webpack_require__(9781);const MCP_DOMAINS={pennylane:"pennylane.com",pipedrive:"pipedrive.com",odoo:"odoo.com","zoho-books":"zoho.com",xero:"xero.com",imessage:"apple.com",whatsapp:"whatsapp.com",gsheet:"google.com",airporting:"airporting.com",gmail:"gmail.com",linkedin:"linkedin.com"};function isRevocation(value){if(null==value||false===value)return true;if(Array.isArray(value)&&0===value.length)return true;return false}function sameValue(left,right){if(Array.isArray(left)&&Array.isArray(right))return left.length===right.length&&left.every((v,i)=>v===right[i]);return left===right}const STICKY_CELL={position:"sticky",left:0,zIndex:2,background:"var(--mantine-color-body)",boxShadow:"2px 0 0 var(--mantine-color-default-border)"};function McpAccessApp(){const query=useMcpAccessQuery();const data=query.data;const setAccess=useSetUserAccess();const accessMap=data?.accessMap??{};const configuredDossiers=data?.configuredDossiers??{};const mcpNames=data?.mcpNames??[];const multiDossierMcps=data?.multiDossierMcps??[];const canEdit=data?.canEdit??false;const activeEmails=new Set((data?.users??[]).map(u=>u.email));const emails=Object.keys(accessMap).filter(email=>0===activeEmails.size||activeEmails.has(email)).sort();const[draft,setDraft]=(0,consume_shared_module_default_react_strict_.useState)({});(0,consume_shared_module_default_react_strict_.useEffect)(()=>{if(data)setDraft({})},[data]);const accessOf=email=>draft[email]??accessMap[email]??{};function updateCell(email,mcp,value){if(!canEdit)return;setDraft(current=>{const next={...current[email]??accessMap[email]??{}};if(isRevocation(value))delete next[mcp];else next[mcp]=value;return{...current,[email]:next}})}const changes=(0,consume_shared_module_default_react_strict_.useMemo)(()=>Object.entries(draft).filter(([email,access])=>{const saved=accessMap[email]??{};const keys=new Set([...Object.keys(saved),...Object.keys(access)]);return[...keys].some(mcp=>!sameValue(saved[mcp],access[mcp]))}),[draft,accessMap]);const revocations=(0,consume_shared_module_default_react_strict_.useMemo)(()=>changes.flatMap(([email,access])=>Object.keys(accessMap[email]??{}).filter(mcp=>isRevocation(access[mcp])).map(mcp=>`${mcp} pour ${email}`)),[changes,accessMap]);const[saving,setSaving]=(0,consume_shared_module_default_react_strict_.useState)(false);async function save(){if(revocations.length>0){const ok=window.confirm(`Retirer ${revocations.length} acc\xe8s ?
2
- ${revocations.join("\n")}`);if(!ok)return}setSaving(true);try{for(const[email,access]of changes)await setAccess.mutateAsync({email,access})}finally{setSaving(false)}}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()}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",mb:"sm",children:[canEdit?/*#__PURE__*/(0,jsx_runtime.jsx)("span",{}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",fz:"sm",children:"Lecture seule (non-admin)"}),canEdit&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",loading:saving,disabled:0===changes.length,onClick:()=>void save(),children:changes.length>0?`Enregistrer (${changes.length})`:"Enregistrer"})]}),data?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ScrollArea,{type:"auto",h:"calc(100vh - 200px)",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{withTableBorder:true,withColumnBorders:true,stickyHeader:true,miw:1200,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,{style:{...STICKY_CELL,zIndex:3},children:"Utilisateur"}),mcpNames.map(mcp=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:["quickbooks"===mcp?/*#__PURE__*/(0,jsx_runtime.jsx)(QuickBooksIcon.h,{size:18}):MCP_DOMAINS[mcp]?/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:MCP_DOMAINS[mcp],alt:mcp,size:18}):null,mcp]})},mcp))]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:emails.map(email=>{const access=accessOf(email);const changed=changes.some(([e])=>e===email);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{style:STICKY_CELL,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fz:"sm",fw:changed?700:400,children:[email,changed?" *":""]})}),mcpNames.map(mcp=>{const entry=access[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:(configuredDossiers[mcp]??[]).map(d=>d.slug),renderOption:({option})=>{const dossier=(configuredDossiers[mcp]??[]).find(d=>d.slug===option.value);return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:dossier?`${dossier.name} (${option.value})`:option.value})},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)(consume_shared_module_default_react_strict_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(McpAccessApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["6215"],{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}})}},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__(5850);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]})]})}},9781:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{h:()=>QuickBooksIcon});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);function QuickBooksIcon(props){const size=props.size??20;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("svg",{width:size,height:size,viewBox:"0 0 24 24",role:"img","aria-label":"QuickBooks",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("title",{children:"QuickBooks"}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("circle",{cx:"12",cy:"12",r:"12",fill:"#2CA01C"}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("text",{x:"12",y:"16.5",textAnchor:"middle",fontSize:"12",fontWeight:"700",fill:"#ffffff",fontFamily:"Arial, Helvetica, sans-serif",children:"qb"})]})}},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}`}},15: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 consume_shared_module_default_react_strict_=__webpack_require__(5850);var index_mjs_=__webpack_require__(207);var index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useMcpAccessQuery(){const api=(0,useApi.h)();return(0,index_js_.useQuery)({queryKey:["tech","mcp-access"],queryFn:async()=>(await api.mcpAccess.getAccessV1()).data,refetchOnWindowFocus:true})}function useInvalidate(){const queryClient=(0,index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","mcp-access"]})}function useSetUserAccess(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,index_js_.useMutation)({mutationFn:async({email,access})=>(await api.mcpAccess.setUserAccessV1({email},{access})).data,onSuccess:invalidate})}var PageHeader=__webpack_require__(1354);var BrandLogo=__webpack_require__(3897);var QuickBooksIcon=__webpack_require__(9781);function GoogleSheetsIcon(props){const size=props.size??20;return/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:size,height:size,viewBox:"0 0 48 64",role:"img","aria-label":"Google Sheets",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("title",{children:"Google Sheets"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"#0F9D58",d:"M29 0H6a6 6 0 0 0-6 6v52a6 6 0 0 0 6 6h36a6 6 0 0 0 6-6V19z"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"#0B8043",d:"M29 0v13a6 6 0 0 0 6 6h13z"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"#F1F1F1",d:"M11 27h26v22H11z"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"#0F9D58",d:"M11 32.5h26v2H11zm0 6h26v2H11zm0 6h26v2H11zM19 27h2v22h-2zm8 0h2v22h-2z"})]})}function GmailIcon(props){const size=props.size??20;return/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:size,height:size,viewBox:"0 0 48 36",role:"img","aria-label":"Gmail",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("title",{children:"Gmail"}),/*#__PURE__*/(0,jsx_runtime.jsx)("rect",{width:"48",height:"36",rx:"3.64",fill:"#FFF"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"#4285F4",d:"M3.64 36h7.27V18.55L0 10.36v22A3.64 3.64 0 0 0 3.64 36z"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"#34A853",d:"M37.09 36h7.27A3.64 3.64 0 0 0 48 32.36v-22l-10.91 8.19z"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"#FBBC04",d:"M37.09 3.64v14.91L48 10.36V5.45c0-3.37-3.85-5.3-6.55-3.27z"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"#C5221F",d:"M0 5.45v4.91l10.91 8.19V3.64L6.55 2.18C3.85.15 0 2.08 0 5.45z"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"#EA4335",d:"M10.91 18.55V3.64L24 13.45 37.09 3.64v14.91L24 28.36z"})]})}const MCP_DOMAINS={pennylane:"pennylane.com",odoo:"odoo.com","zoho-books":"zoho.com",xero:"xero.com",imessage:"apple.com",whatsapp:"whatsapp.com",airporting:"airporting.com",linkedin:"linkedin.com"};const MCP_ICONS={quickbooks:QuickBooksIcon.h,gsheet:GoogleSheetsIcon,gmail:GmailIcon};function isRevocation(value){if(null==value||false===value)return true;if(Array.isArray(value)&&0===value.length)return true;return false}function sameValue(left,right){if(Array.isArray(left)&&Array.isArray(right))return left.length===right.length&&left.every((v,i)=>v===right[i]);return left===right}const STICKY_CELL={position:"sticky",left:0,zIndex:2,background:"var(--mantine-color-body)",boxShadow:"2px 0 0 var(--mantine-color-default-border)"};function McpIcon({mcp}){const Inline=MCP_ICONS[mcp];if(Inline)return/*#__PURE__*/(0,jsx_runtime.jsx)(Inline,{size:18});const domain=MCP_DOMAINS[mcp];return domain?/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:domain,alt:mcp,size:18}):null}function McpAccessApp(){const query=useMcpAccessQuery();const data=query.data;const setAccess=useSetUserAccess();const accessMap=data?.accessMap??{};const configuredDossiers=data?.configuredDossiers??{};const mcpNames=data?.mcpNames??[];const multiDossierMcps=data?.multiDossierMcps??[];const canEdit=data?.canEdit??false;const activeEmails=new Set((data?.users??[]).map(u=>u.email));const emails=Object.keys(accessMap).filter(email=>0===activeEmails.size||activeEmails.has(email)).sort();const[draft,setDraft]=(0,consume_shared_module_default_react_strict_.useState)({});(0,consume_shared_module_default_react_strict_.useEffect)(()=>{if(data)setDraft({})},[data]);const accessOf=email=>draft[email]??accessMap[email]??{};function updateCell(email,mcp,value){if(!canEdit)return;setDraft(current=>{const next={...current[email]??accessMap[email]??{}};if(isRevocation(value))delete next[mcp];else next[mcp]=value;return{...current,[email]:next}})}const changes=(0,consume_shared_module_default_react_strict_.useMemo)(()=>Object.entries(draft).filter(([email,access])=>{const saved=accessMap[email]??{};const keys=new Set([...Object.keys(saved),...Object.keys(access)]);return[...keys].some(mcp=>!sameValue(saved[mcp],access[mcp]))}),[draft,accessMap]);const revocations=(0,consume_shared_module_default_react_strict_.useMemo)(()=>changes.flatMap(([email,access])=>Object.keys(accessMap[email]??{}).filter(mcp=>isRevocation(access[mcp])).map(mcp=>`${mcp} pour ${email}`)),[changes,accessMap]);const[saving,setSaving]=(0,consume_shared_module_default_react_strict_.useState)(false);async function save(){if(revocations.length>0){const ok=window.confirm(`Retirer ${revocations.length} acc\xe8s ?
2
+ ${revocations.join("\n")}`);if(!ok)return}setSaving(true);try{for(const[email,access]of changes)await setAccess.mutateAsync({email,access})}finally{setSaving(false)}}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()}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",mb:"sm",children:[canEdit?/*#__PURE__*/(0,jsx_runtime.jsx)("span",{}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",fz:"sm",children:"Lecture seule (non-admin)"}),canEdit&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",loading:saving,disabled:0===changes.length,onClick:()=>void save(),children:changes.length>0?`Enregistrer (${changes.length})`:"Enregistrer"})]}),data?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ScrollArea,{type:"auto",h:"calc(100vh - 200px)",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{withTableBorder:true,withColumnBorders:true,stickyHeader:true,miw:1200,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,{style:{...STICKY_CELL,zIndex:3},children:"Utilisateur"}),mcpNames.map(mcp=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:6,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(McpIcon,{mcp:mcp}),mcp]})},mcp))]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:emails.map(email=>{const access=accessOf(email);const changed=changes.some(([e])=>e===email);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{style:STICKY_CELL,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fz:"sm",fw:changed?700:400,children:[email,changed?" *":""]})}),mcpNames.map(mcp=>{const entry=access[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:(configuredDossiers[mcp]??[]).map(d=>d.slug),renderOption:({option})=>{const dossier=(configuredDossiers[mcp]??[]).find(d=>d.slug===option.value);return/*#__PURE__*/(0,jsx_runtime.jsx)("span",{children:dossier?`${dossier.name} (${option.value})`:option.value})},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)(consume_shared_module_default_react_strict_.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([["2149"],{1334:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{m:()=>useSalesLeads});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi_ts__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useSalesLeads(status){const api=(0,_useApi_ts__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","sales","leads",status],queryFn:async()=>(await api.sales.listLeadsV1({status})).data,refetchOnWindowFocus:true})}},9328:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{A:()=>NewLeadModal});var jsx_runtime=__webpack_require__(5893);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(9038);var form_esm_index_mjs_=__webpack_require__(5021);var notifications_esm_index_mjs_=__webpack_require__(1455);var index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useCreateLead(){const api=(0,useApi.h)();const queryClient=(0,index_js_.useQueryClient)();return(0,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,onCreated}){const create=useCreateLead();const form=(0,form_esm_index_mjs_.useForm)({initialValues:{first_name:"",last_name:"",company:"",email:"",phone:"",linkedin_url:"",note:"",next_action_due_at:null,request_reconstruction:true}});function submit(values){const hasAny=Boolean(values.first_name)||Boolean(values.last_name)||Boolean(values.company)||Boolean(values.email)||Boolean(values.phone)||Boolean(values.linkedin_url);if(!hasAny)return void notifications_esm_index_mjs_.notifications.show({title:"Lead",message:"Renseignez au moins un nom, une entreprise ou une coordonn\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]:[],linkedin_url:values.linkedin_url||null,note:values.note||null,next_action_due_at:values.next_action_due_at?new Date(values.next_action_due_at).toISOString():null,request_reconstruction:values.request_reconstruction},{onSuccess:data=>{onCreated?.({id:data.id,first_name:values.first_name||null,last_name:values.last_name||null,company:values.company||null});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.jsx)(index_mjs_.TextInput,{label:"URL LinkedIn",placeholder:"https://www.linkedin.com/in/...",...form.getInputProps("linkedin_url")}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Email",...form.getInputProps("email")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"T\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)(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"})]})]})})})}},479:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{P:()=>TEMPERATURE_META,o:()=>TEMPERATURE_ORDER});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"]},3697:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Pipeline});var jsx_runtime=__webpack_require__(5893);var consume_shared_module_default_react_strict_=__webpack_require__(5850);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(3863);var tabler_icons_react_mjs_=__webpack_require__(9632);var index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useSalesDeals(pipeline,status){const api=(0,useApi.h)();return(0,index_js_.useQuery)({queryKey:["tech","sales","deals",pipeline,status],queryFn:async()=>(await api.sales.listDealsV1({pipeline,status})).data,refetchOnWindowFocus:true})}var notifications_esm_index_mjs_=__webpack_require__(1455);function useExportDeals(){const api=(0,useApi.h)();return(0,index_js_.useMutation)({mutationFn:async()=>(await api.sales.exportDealsV1()).data,onSuccess:data=>{notifications_esm_index_mjs_.notifications.show({title:"Export",message:`Export lanc\xe9 : ${data?.rows??0} deal(s) seront \xe9crits dans l'onglet ${data?.worksheet??"de reporting"} dans quelques minutes`,color:"green"})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Export",message:err?.error?.error??err?.message??"\xc9chec de l'export",color:"red"})}})}var dates_esm_index_mjs_=__webpack_require__(9038);function useDeleteDeal(){const api=(0,useApi.h)();const queryClient=(0,index_js_.useQueryClient)();return(0,index_js_.useMutation)({mutationFn:async id=>(await api.sales.deleteDealV1({id})).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Deal supprim\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"\xc9chec de la suppression",color:"red"})}})}function useUpdateDeal(id){const api=(0,useApi.h)();const queryClient=(0,index_js_.useQueryClient)();return(0,index_js_.useMutation)({mutationFn:async payload=>(await api.sales.updateDealV1({id},payload)).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Modifications enregistr\xe9es",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"\xc9chec de la mise \xe0 jour",color:"red"})}})}const eurFormatter=new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR",maximumFractionDigits:0});const dayFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:"Europe/Paris",day:"2-digit",month:"2-digit",year:"numeric"});function formatEur(value){if(Number.isNaN(value))return eurFormatter.format(0);return eurFormatter.format(value)}function formatAmount(value,currency){if("EUR"===currency||""===currency)return formatEur(value);return new Intl.NumberFormat("fr-FR",{style:"currency",currency,maximumFractionDigits:0}).format(value)}function formatDay(iso){if(null===iso)return"";const date=new Date(iso);if(Number.isNaN(date.getTime()))return"";return dayFormatter.format(date)}var temperature=__webpack_require__(479);const STATUS_META={open:{label:"Ouvert",color:"blue"},won:{label:"Gagn\xe9",color:"green"},lost:{label:"Perdu",color:"red"}};function personLabel(deal){const parts=[deal.lead.first_name,deal.lead.last_name].filter(Boolean);return parts.join(" ")}function DealDetailForm({deal,stages,onClose}){const update=useUpdateDeal(deal.id);const remove=useDeleteDeal();const[title,setTitle]=(0,consume_shared_module_default_react_strict_.useState)(deal.title);const[value,setValue]=(0,consume_shared_module_default_react_strict_.useState)(deal.value);const[probability,setProbability]=(0,consume_shared_module_default_react_strict_.useState)(null===deal.probability?"":deal.probability);const[expectedCloseDate,setExpectedCloseDate]=(0,consume_shared_module_default_react_strict_.useState)(deal.expected_close_date??"");const[stageId,setStageId]=(0,consume_shared_module_default_react_strict_.useState)(String(deal.stage_id));const[lostReason,setLostReason]=(0,consume_shared_module_default_react_strict_.useState)(deal.lost_reason??"");const statusMeta=STATUS_META[deal.status];function save(){update.mutate({title,value:""===value?0:Number(value),probability:""===probability?null:Number(probability),expected_close_date:""===expectedCloseDate?null:expectedCloseDate,stage_id:null===stageId?void 0:Number(stageId)})}function markWon(){update.mutate({status:"won"},{onSuccess:onClose})}function markLost(){update.mutate({status:"lost",lost_reason:""===lostReason?null:lostReason},{onSuccess:onClose})}function reopen(){update.mutate({status:"open"},{onSuccess:onClose})}function handleDelete(){remove.mutate(deal.id,{onSuccess:onClose})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[statusMeta?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:statusMeta.color,children:statusMeta.label}):null,"won"===deal.status&&null!==deal.won_at?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:`Gagn\xe9 le ${formatDay(deal.won_at)}`}):null,"lost"===deal.status&&null!==deal.lost_at?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:`Perdu le ${formatDay(deal.lost_at)}`}):null]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:`${temperature.P[deal.lead.temperature]?.emoji??""} ${personLabel(deal)}`.trim()}),deal.lead.company?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:deal.lead.company}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Anchor,{href:"/console/sales",size:"sm",children:"Voir le lead"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Titre",value:title,onChange:e=>setTitle(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Montant",value:value,onChange:setValue,min:0,thousandSeparator:" ",decimalSeparator:",",suffix:` ${deal.currency}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Probabilit\xe9 (%)",value:probability,onChange:setProbability,min:0,max:100})]}),/*#__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:expectedCloseDate?new Date(expectedCloseDate):null,onChange:v=>setExpectedCloseDate(v?new Date(v).toISOString():"")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"\xc9tape",data:stages.map(s=>({value:String(s.id),label:s.name})),value:stageId,onChange:setStageId}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",variant:"light",onClick:handleDelete,children:"Supprimer"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:update.isPending,onClick:save,children:"Enregistrer"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{mt:"md"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,children:"Statut"}),"open"===deal.status?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Raison de la perte (optionnelle)",value:lostReason,onChange:e=>setLostReason(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",variant:"light",loading:update.isPending,onClick:markLost,children:"Perdu"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"green",loading:update.isPending,onClick:markWon,children:"Gagn\xe9"})]})]}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",loading:update.isPending,onClick:reopen,children:"Rouvrir"})})]})}function DealDetailDrawer({deal,stages,onClose}){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Drawer,{opened:null!==deal,onClose:onClose,position:"right",size:"lg",title:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,children:"Deal"}),children:deal?/*#__PURE__*/(0,jsx_runtime.jsx)(DealDetailForm,{deal:deal,stages:stages,onClose:onClose},deal.id):null})}function stageName(stages,stageId){const stage=stages.find(s=>s.id===stageId);if(!stage)return"";return stage.name}function DealsTable({deals,stages,status,onRowClick}){const isLost="lost"===status;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Titre"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Montant"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:isLost?"Perdu le":"Gagn\xe9 le"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"\xc9tape"}),isLost?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Raison"}):null]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:deals.map(deal=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{style:{cursor:"pointer"},onClick:()=>onRowClick(deal.id),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:deal.title}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:deal.lead.company??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:formatAmount(deal.value,deal.currency)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:formatDay(isLost?deal.lost_at:deal.won_at)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:stageName(stages,deal.stage_id)}),isLost?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:deal.lost_reason?void 0:"dimmed",children:deal.lost_reason??"Non renseign\xe9e"})}):null]},deal.id))})]})}function moveDealToStage(current,dealId,stageId){const deal=current.deals.find(d=>d.id===dealId);if(void 0===deal||deal.stage_id===stageId)return current;const fromStageId=deal.stage_id;return{stages:current.stages.map(stage=>{if(stage.id===fromStageId)return{...stage,deal_count:Math.max(0,stage.deal_count-1),total_value:stage.total_value-deal.value};if(stage.id===stageId)return{...stage,deal_count:stage.deal_count+1,total_value:stage.total_value+deal.value};return stage}),deals:current.deals.map(d=>d.id===dealId?{...d,stage_id:stageId}:d)}}function useMoveDealStage(pipeline,status){const api=(0,useApi.h)();const queryClient=(0,index_js_.useQueryClient)();const queryKey=["tech","sales","deals",pipeline,status];return(0,index_js_.useMutation)({mutationFn:async payload=>(await api.sales.updateDealV1({id:payload.id},{stage_id:payload.stage_id})).data,onMutate:async payload=>{await queryClient.cancelQueries({queryKey});const previous=queryClient.getQueryData(queryKey);if(void 0!==previous)queryClient.setQueryData(queryKey,moveDealToStage(previous,payload.id,payload.stage_id));return{previous}},onError:(err,_payload,context)=>{if(context?.previous!==void 0)queryClient.setQueryData(queryKey,context.previous);notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"\xc9chec du changement d'\xe9tape",color:"red"})},onSettled:()=>{queryClient.invalidateQueries({queryKey:["tech","sales"]})}})}function DealCard_personLabel(deal){const parts=[deal.lead.first_name,deal.lead.last_name].filter(Boolean);return parts.join(" ")}function DealCard({deal,stages,isDragging,onOpen,onDragStart,onDragEnd}){const update=useUpdateDeal(deal.id);const index=stages.findIndex(s=>s.id===deal.stage_id);const previous=index>0?stages[index-1]:null;const next=index>=0&&index<stages.length-1?stages[index+1]:null;function move(target){if(null===target)return;update.mutate({stage_id:target.id})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,padding:"sm",radius:"md",draggable:true,style:{cursor:isDragging?"grabbing":"grab",opacity:isDragging?.4:1,transition:"opacity 120ms ease"},onClick:()=>onOpen(deal.id),onDragStart:e=>{e.dataTransfer.effectAllowed="move";e.dataTransfer.setData("text/plain",String(deal.id));onDragStart(deal.id)},onDragEnd:onDragEnd,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:6,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",align:"flex-start",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:4,wrap:"nowrap",align:"flex-start",style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconGripVertical,{size:16,"aria-hidden":true,style:{flexShrink:0,marginTop:2,color:"var(--mantine-color-dimmed)"}}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:500,size:"sm",lineClamp:2,children:deal.title})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"blue",children:formatAmount(deal.value,deal.currency)})]}),deal.lead.company?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:deal.lead.company}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:`${temperature.P[deal.lead.temperature]?.emoji??""} ${DealCard_personLabel(deal)}`.trim()}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[null!==deal.probability?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"gray",size:"sm",children:`${deal.probability} %`}):null,null!==deal.expected_close_date?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"gray",size:"sm",children:`\xc9ch\xe9ance : ${formatDay(deal.expected_close_date)}`}):null]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",size:"sm","aria-label":"\xc9tape pr\xe9c\xe9dente",disabled:null===previous||update.isPending,onClick:e=>{e.stopPropagation();move(previous)},children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronLeft,{size:16})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",size:"sm","aria-label":"\xc9tape suivante",disabled:null===next||update.isPending,onClick:e=>{e.stopPropagation();move(next)},children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronRight,{size:16})})]})]})})}function KanbanBoard({pipeline,status,stages,deals,onOpen}){const move=useMoveDealStage(pipeline,status);const[draggedId,setDraggedId]=(0,consume_shared_module_default_react_strict_.useState)(null);const[hoveredStageId,setHoveredStageId]=(0,consume_shared_module_default_react_strict_.useState)(null);const draggedDeal=null===draggedId?null:deals.find(d=>d.id===draggedId)??null;function resetDrag(){setDraggedId(null);setHoveredStageId(null)}function handleDrop(e,stage){e.preventDefault();const raw=Number(e.dataTransfer.getData("text/plain"));const dealId=Number.isFinite(raw)&&raw>0?raw:draggedId;resetDrag();if(null===dealId)return;const deal=deals.find(d=>d.id===dealId);if(void 0===deal||deal.stage_id===stage.id)return;move.mutate({id:deal.id,stage_id:stage.id})}if(0===stages.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:"Aucune \xe9tape configur\xe9e pour ce pipeline"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Box,{style:{display:"flex",gap:"var(--mantine-spacing-md)",alignItems:"flex-start",overflowX:"auto",paddingBottom:"var(--mantine-spacing-sm)"},children:stages.map(stage=>{const stageDeals=deals.filter(d=>d.stage_id===stage.id);const isDropTarget=hoveredStageId===stage.id&&null!==draggedDeal&&draggedDeal.stage_id!==stage.id;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"sm",style:{flex:"0 0 300px",width:300,backgroundColor:isDropTarget?"var(--mantine-color-blue-light)":void 0,outline:isDropTarget?"2px solid var(--mantine-color-blue-filled)":void 0,outlineOffset:2,transition:"background-color 120ms ease"},onDragOver:e=>{if(null===draggedId)return;e.preventDefault();e.dataTransfer.dropEffect="move";if(hoveredStageId!==stage.id)setHoveredStageId(stage.id)},onDragLeave:e=>{if(e.currentTarget.contains(e.relatedTarget))return;if(hoveredStageId===stage.id)setHoveredStageId(null)},onDrop:e=>handleDrop(e,stage),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",mih:140,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,size:"sm",children:stage.name}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"gray",children:stage.deal_count})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:formatEur(stage.total_value)})]}),0===stageDeals.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:isDropTarget?"D\xe9poser ici":"Aucun deal"}):null,stageDeals.map(deal=>/*#__PURE__*/(0,jsx_runtime.jsx)(DealCard,{deal:deal,stages:stages,isDragging:draggedId===deal.id,onOpen:onOpen,onDragStart:setDraggedId,onDragEnd:resetDrag},deal.id))]})},stage.id)})})}function useCreateDeal(){const api=(0,useApi.h)();const queryClient=(0,index_js_.useQueryClient)();return(0,index_js_.useMutation)({mutationFn:async payload=>(await api.sales.createDealV1(payload)).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Deal cr\xe9\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"\xc9chec de la cr\xe9ation",color:"red"})}})}var leadsQuery=__webpack_require__(1334);var NewLeadModal=__webpack_require__(9328);function leadLabel(lead){const name=[lead.first_name,lead.last_name].filter(Boolean).join(" ");if(lead.company&&name)return`${name} (${lead.company})`;if(lead.company)return lead.company;if(name)return name;return`Lead ${lead.id}`}function NewDealForm({onClose,stages}){const leads=(0,leadsQuery.m)("active");const create=useCreateDeal();const[leadId,setLeadId]=(0,consume_shared_module_default_react_strict_.useState)(null);const[newLeadOpened,setNewLeadOpened]=(0,consume_shared_module_default_react_strict_.useState)(false);const[createdLead,setCreatedLead]=(0,consume_shared_module_default_react_strict_.useState)(null);const[title,setTitle]=(0,consume_shared_module_default_react_strict_.useState)("");const[value,setValue]=(0,consume_shared_module_default_react_strict_.useState)("");const[stageId,setStageId]=(0,consume_shared_module_default_react_strict_.useState)(stages.length>0?String(stages[0].id):null);const leadOptions=(leads.data?.leads??[]).map(lead=>({value:String(lead.id),label:leadLabel(lead)}));if(createdLead&&!leadOptions.some(option=>option.value===String(createdLead.id)))leadOptions.push({value:String(createdLead.id),label:leadLabel(createdLead)});function submit(){if(null===leadId||null===stageId||""===title.trim())return void notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Renseignez un lead, un titre et une \xe9tape",color:"orange"});create.mutate({lead_id:Number(leadId),stage_id:Number(stageId),title:title.trim(),value:""===value?0:Number(value),currency:"EUR"},{onSuccess:onClose})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Lead",placeholder:"Rechercher un lead",searchable:true,nothingFoundMessage:"Aucun lead",data:leadOptions,value:leadId,onChange:setLeadId}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",size:"compact-sm",style:{alignSelf:"flex-start"},onClick:()=>setNewLeadOpened(true),children:"+ Cr\xe9er un nouveau lead"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Titre",value:title,onChange:e=>setTitle(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Montant (EUR)",value:value,onChange:setValue,min:0,thousandSeparator:" ",decimalSeparator:","}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"\xc9tape",data:stages.map(s=>({value:String(s.id),label:s.name})),value:stageId,onChange:setStageId}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:onClose,children:"Annuler"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:create.isPending,onClick:submit,children:"Cr\xe9er"})]}),newLeadOpened?/*#__PURE__*/(0,jsx_runtime.jsx)(NewLeadModal.A,{opened:true,onClose:()=>setNewLeadOpened(false),onCreated:lead=>{setCreatedLead(lead);setLeadId(String(lead.id))}}):null]})}function NewDealModal({opened,onClose,stages}){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:opened,onClose:onClose,title:"Nouveau deal",children:opened?/*#__PURE__*/(0,jsx_runtime.jsx)(NewDealForm,{onClose:onClose,stages:stages}):null})}function PipelineApp(){const[pipeline,setPipeline]=(0,consume_shared_module_default_react_strict_.useState)("new_business");const[status,setStatus]=(0,consume_shared_module_default_react_strict_.useState)("open");const[selectedId,setSelectedId]=(0,consume_shared_module_default_react_strict_.useState)(null);const[newDealOpened,newDeal]=(0,esm_index_mjs_.useDisclosure)(false);const deals=useSalesDeals(pipeline,status);const exportDeals=useExportDeals();const stages=deals.data?.stages??[];const rows=deals.data?.deals??[];const selected=(0,consume_shared_module_default_react_strict_.useMemo)(()=>{if(null===selectedId)return null;return rows.find(d=>d.id===selectedId)??null},[rows,selectedId]);const total=rows.reduce((acc,d)=>acc+d.value,0);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{fluid:true,my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",mb:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Pipeline"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"blue",children:`${rows.length} deal(s) : ${formatEur(total)}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:newDeal.open,disabled:0===stages.length,children:"+ Nouveau deal"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTableExport,{size:16}),loading:exportDeals.isPending,disabled:exportDeals.isPending,onClick:()=>exportDeals.mutate(),children:"Exporter vers le reporting"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",mb:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:pipeline,onChange:setPipeline,data:[{label:"New Business",value:"new_business"},{label:"Upsell / Cross-sell",value:"upsell"}]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:status,onChange:setStatus,data:[{label:"Ouverts",value:"open"},{label:"Gagn\xe9s",value:"won"},{label:"Perdus",value:"lost"}]})]}),deals.isLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Loader,{}):null,deals.data&&"open"===status?/*#__PURE__*/(0,jsx_runtime.jsx)(KanbanBoard,{pipeline:pipeline,status:status,stages:stages,deals:rows,onOpen:setSelectedId}):null,deals.data&&"open"!==status?/*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:0===rows.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:"Aucun deal"}):/*#__PURE__*/(0,jsx_runtime.jsx)(DealsTable,{deals:rows,stages:stages,status:status,onRowClick:setSelectedId})}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(NewDealModal,{opened:newDealOpened,onClose:newDeal.close,stages:stages}),/*#__PURE__*/(0,jsx_runtime.jsx)(DealDetailDrawer,{deal:selected,stages:stages,onClose:()=>setSelectedId(null)})]})}function Pipeline(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(consume_shared_module_default_react_strict_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(PipelineApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["2149"],{1334:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{m:()=>useSalesLeads});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi_ts__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useSalesLeads(status){const api=(0,_useApi_ts__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","sales","leads",status],queryFn:async()=>(await api.sales.listLeadsV1({status})).data,refetchOnWindowFocus:true})}},9328:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{A:()=>NewLeadModal});var jsx_runtime=__webpack_require__(5893);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(9038);var form_esm_index_mjs_=__webpack_require__(5021);var notifications_esm_index_mjs_=__webpack_require__(1455);var index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useCreateLead(){const api=(0,useApi.h)();const queryClient=(0,index_js_.useQueryClient)();return(0,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,onCreated}){const create=useCreateLead();const form=(0,form_esm_index_mjs_.useForm)({initialValues:{first_name:"",last_name:"",company:"",email:"",phone:"",linkedin_url:"",note:"",next_action_due_at:null,request_reconstruction:true}});function submit(values){const hasAny=Boolean(values.first_name)||Boolean(values.last_name)||Boolean(values.company)||Boolean(values.email)||Boolean(values.phone)||Boolean(values.linkedin_url);if(!hasAny)return void notifications_esm_index_mjs_.notifications.show({title:"Lead",message:"Renseignez au moins un nom, une entreprise ou une coordonn\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]:[],linkedin_url:values.linkedin_url||null,note:values.note||null,next_action_due_at:values.next_action_due_at?new Date(values.next_action_due_at).toISOString():null,request_reconstruction:values.request_reconstruction},{onSuccess:data=>{onCreated?.({id:data.id,first_name:values.first_name||null,last_name:values.last_name||null,company:values.company||null});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.jsx)(index_mjs_.TextInput,{label:"URL LinkedIn",placeholder:"https://www.linkedin.com/in/...",...form.getInputProps("linkedin_url")}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Email",...form.getInputProps("email")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"T\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)(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"})]})]})})})}},479:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{P:()=>TEMPERATURE_META,o:()=>TEMPERATURE_ORDER});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"]},1717:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Pipeline});var jsx_runtime=__webpack_require__(5893);var consume_shared_module_default_react_strict_=__webpack_require__(5850);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(3863);var tabler_icons_react_mjs_=__webpack_require__(9632);var index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useSalesDeals(pipeline,status){const api=(0,useApi.h)();return(0,index_js_.useQuery)({queryKey:["tech","sales","deals",pipeline,status],queryFn:async()=>(await api.sales.listDealsV1({pipeline,status})).data,refetchOnWindowFocus:true})}var notifications_esm_index_mjs_=__webpack_require__(1455);function useExportDeals(){const api=(0,useApi.h)();return(0,index_js_.useMutation)({mutationFn:async()=>(await api.sales.exportDealsV1()).data,onSuccess:data=>{notifications_esm_index_mjs_.notifications.show({title:"Export",message:`Export lanc\xe9 : ${data?.rows??0} deal(s) seront \xe9crits dans l'onglet ${data?.worksheet??"de reporting"} dans quelques minutes`,color:"green"})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Export",message:err?.error?.error??err?.message??"\xc9chec de l'export",color:"red"})}})}var dates_esm_index_mjs_=__webpack_require__(9038);function useSalesDealStages(){const api=(0,useApi.h)();return(0,index_js_.useQuery)({queryKey:["tech","sales","deal-stages"],queryFn:async()=>(await api.sales.listDealStagesV1()).data,staleTime:36e5,refetchOnWindowFocus:false})}function useDeleteDeal(){const api=(0,useApi.h)();const queryClient=(0,index_js_.useQueryClient)();return(0,index_js_.useMutation)({mutationFn:async id=>(await api.sales.deleteDealV1({id})).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Deal supprim\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"\xc9chec de la suppression",color:"red"})}})}function useUpdateDeal(id){const api=(0,useApi.h)();const queryClient=(0,index_js_.useQueryClient)();return(0,index_js_.useMutation)({mutationFn:async payload=>(await api.sales.updateDealV1({id},payload)).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Modifications enregistr\xe9es",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"\xc9chec de la mise \xe0 jour",color:"red"})}})}const eurFormatter=new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR",maximumFractionDigits:0});const dayFormatter=new Intl.DateTimeFormat("fr-FR",{timeZone:"Europe/Paris",day:"2-digit",month:"2-digit",year:"numeric"});function formatEur(value){if(Number.isNaN(value))return eurFormatter.format(0);return eurFormatter.format(value)}function formatAmount(value,currency){if("EUR"===currency||""===currency)return formatEur(value);return new Intl.NumberFormat("fr-FR",{style:"currency",currency,maximumFractionDigits:0}).format(value)}function formatDay(iso){if(null===iso)return"";const date=new Date(iso);if(Number.isNaN(date.getTime()))return"";return dayFormatter.format(date)}var temperature=__webpack_require__(479);const STATUS_META={open:{label:"Ouvert",color:"blue"},won:{label:"Gagn\xe9",color:"green"},lost:{label:"Perdu",color:"red"}};const PIPELINE_LABEL={new_business:"New Business",upsell:"Upsell / Cross-sell"};const PIPELINE_OPTIONS=[{value:"new_business",label:PIPELINE_LABEL.new_business},{value:"upsell",label:PIPELINE_LABEL.upsell}];function personLabel(deal){const parts=[deal.lead.first_name,deal.lead.last_name].filter(Boolean);return parts.join(" ")}function stagesOfPipeline(allStages,pipeline){return allStages.filter(s=>s.pipeline===pipeline).sort((a,b)=>a.order_nr-b.order_nr)}function pipelineOfStage(allStages,stageId){const current=allStages.find(s=>s.id===stageId);if(void 0===current)return"new_business";return current.pipeline}function DealDetailForm({deal,stages,allStages,onClose}){const update=useUpdateDeal(deal.id);const remove=useDeleteDeal();const initialPipeline=(0,consume_shared_module_default_react_strict_.useMemo)(()=>pipelineOfStage(allStages,deal.stage_id),[allStages,deal.stage_id]);const[title,setTitle]=(0,consume_shared_module_default_react_strict_.useState)(deal.title);const[value,setValue]=(0,consume_shared_module_default_react_strict_.useState)(deal.value);const[probability,setProbability]=(0,consume_shared_module_default_react_strict_.useState)(null===deal.probability?"":deal.probability);const[expectedCloseDate,setExpectedCloseDate]=(0,consume_shared_module_default_react_strict_.useState)(deal.expected_close_date??"");const[pipeline,setPipeline]=(0,consume_shared_module_default_react_strict_.useState)(initialPipeline);const[stageId,setStageId]=(0,consume_shared_module_default_react_strict_.useState)(String(deal.stage_id));const[lostReason,setLostReason]=(0,consume_shared_module_default_react_strict_.useState)(deal.lost_reason??"");const statusMeta=STATUS_META[deal.status];const stageOptions=(0,consume_shared_module_default_react_strict_.useMemo)(()=>{if(0===allStages.length)return[...stages].sort((a,b)=>a.order_nr-b.order_nr).map(s=>({value:String(s.id),label:s.name}));return stagesOfPipeline(allStages,pipeline).map(s=>({value:String(s.id),label:s.name}))},[allStages,stages,pipeline]);function changePipeline(next){if(null===next)return;const target=next;setPipeline(target);const first=stagesOfPipeline(allStages,target)[0];setStageId(void 0===first?null:String(first.id))}function save(){const moved=pipeline!==initialPipeline;update.mutate({title,value:""===value?0:Number(value),probability:""===probability?null:Number(probability),expected_close_date:""===expectedCloseDate?null:expectedCloseDate,stage_id:null===stageId?void 0:Number(stageId)},moved?{onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Pipeline",message:`Deal d\xe9plac\xe9 vers ${PIPELINE_LABEL[pipeline]}`,color:"green"});onClose()}}:void 0)}function markWon(){update.mutate({status:"won"},{onSuccess:onClose})}function markLost(){update.mutate({status:"lost",lost_reason:""===lostReason?null:lostReason},{onSuccess:onClose})}function reopen(){update.mutate({status:"open"},{onSuccess:onClose})}function handleDelete(){remove.mutate(deal.id,{onSuccess:onClose})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[statusMeta?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:statusMeta.color,children:statusMeta.label}):null,"won"===deal.status&&null!==deal.won_at?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:`Gagn\xe9 le ${formatDay(deal.won_at)}`}):null,"lost"===deal.status&&null!==deal.lost_at?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:`Perdu le ${formatDay(deal.lost_at)}`}):null]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:`${temperature.P[deal.lead.temperature]?.emoji??""} ${personLabel(deal)}`.trim()}),deal.lead.company?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:deal.lead.company}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Anchor,{href:"/console/sales",size:"sm",children:"Voir le lead"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Titre",value:title,onChange:e=>setTitle(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Montant",value:value,onChange:setValue,min:0,thousandSeparator:" ",decimalSeparator:",",suffix:` ${deal.currency}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Probabilit\xe9 (%)",value:probability,onChange:setProbability,min:0,max:100})]}),/*#__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:expectedCloseDate?new Date(expectedCloseDate):null,onChange:v=>setExpectedCloseDate(v?new Date(v).toISOString():"")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Pipeline",description:0===allStages.length?"Liste des \xe9tapes indisponible, le d\xe9placement n'est pas possible":void 0,data:PIPELINE_OPTIONS,value:pipeline,onChange:changePipeline,disabled:0===allStages.length}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"\xc9tape",data:stageOptions,value:stageId,onChange:setStageId}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",variant:"light",onClick:handleDelete,children:"Supprimer"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:update.isPending,onClick:save,children:"Enregistrer"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{mt:"md"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,children:"Statut"}),"open"===deal.status?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Raison de la perte (optionnelle)",value:lostReason,onChange:e=>setLostReason(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",variant:"light",loading:update.isPending,onClick:markLost,children:"Perdu"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"green",loading:update.isPending,onClick:markWon,children:"Gagn\xe9"})]})]}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",loading:update.isPending,onClick:reopen,children:"Rouvrir"})})]})}function DealDetailDrawer({deal,stages,onClose}){const dealStages=useSalesDealStages();return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Drawer,{opened:null!==deal,onClose:onClose,position:"right",size:"lg",title:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,children:"Deal"}),children:null===deal?null:dealStages.isPending?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Loader,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(DealDetailForm,{deal:deal,stages:stages,allStages:dealStages.data?.stages??[],onClose:onClose},deal.id)})}function stageName(stages,stageId){const stage=stages.find(s=>s.id===stageId);if(!stage)return"";return stage.name}function DealsTable({deals,stages,status,onRowClick}){const isLost="lost"===status;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Titre"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Montant"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:isLost?"Perdu le":"Gagn\xe9 le"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"\xc9tape"}),isLost?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Raison"}):null]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:deals.map(deal=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{style:{cursor:"pointer"},onClick:()=>onRowClick(deal.id),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:deal.title}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:deal.lead.company??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:formatAmount(deal.value,deal.currency)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:formatDay(isLost?deal.lost_at:deal.won_at)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:stageName(stages,deal.stage_id)}),isLost?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:deal.lost_reason?void 0:"dimmed",children:deal.lost_reason??"Non renseign\xe9e"})}):null]},deal.id))})]})}function moveDealToStage(current,dealId,stageId){const deal=current.deals.find(d=>d.id===dealId);if(void 0===deal||deal.stage_id===stageId)return current;const fromStageId=deal.stage_id;return{stages:current.stages.map(stage=>{if(stage.id===fromStageId)return{...stage,deal_count:Math.max(0,stage.deal_count-1),total_value:stage.total_value-deal.value};if(stage.id===stageId)return{...stage,deal_count:stage.deal_count+1,total_value:stage.total_value+deal.value};return stage}),deals:current.deals.map(d=>d.id===dealId?{...d,stage_id:stageId}:d)}}function useMoveDealStage(pipeline,status){const api=(0,useApi.h)();const queryClient=(0,index_js_.useQueryClient)();const queryKey=["tech","sales","deals",pipeline,status];return(0,index_js_.useMutation)({mutationFn:async payload=>(await api.sales.updateDealV1({id:payload.id},{stage_id:payload.stage_id})).data,onMutate:async payload=>{await queryClient.cancelQueries({queryKey});const previous=queryClient.getQueryData(queryKey);if(void 0!==previous)queryClient.setQueryData(queryKey,moveDealToStage(previous,payload.id,payload.stage_id));return{previous}},onError:(err,_payload,context)=>{if(context?.previous!==void 0)queryClient.setQueryData(queryKey,context.previous);notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"\xc9chec du changement d'\xe9tape",color:"red"})},onSettled:()=>{queryClient.invalidateQueries({queryKey:["tech","sales"]})}})}function DealCard_personLabel(deal){const parts=[deal.lead.first_name,deal.lead.last_name].filter(Boolean);return parts.join(" ")}function DealCard({deal,stages,isDragging,onOpen,onDragStart,onDragEnd}){const update=useUpdateDeal(deal.id);const index=stages.findIndex(s=>s.id===deal.stage_id);const previous=index>0?stages[index-1]:null;const next=index>=0&&index<stages.length-1?stages[index+1]:null;function move(target){if(null===target)return;update.mutate({stage_id:target.id})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Card,{withBorder:true,padding:"sm",radius:"md",draggable:true,style:{cursor:isDragging?"grabbing":"grab",opacity:isDragging?.4:1,transition:"opacity 120ms ease"},onClick:()=>onOpen(deal.id),onDragStart:e=>{e.dataTransfer.effectAllowed="move";e.dataTransfer.setData("text/plain",String(deal.id));onDragStart(deal.id)},onDragEnd:onDragEnd,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:6,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",align:"flex-start",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:4,wrap:"nowrap",align:"flex-start",style:{minWidth:0},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconGripVertical,{size:16,"aria-hidden":true,style:{flexShrink:0,marginTop:2,color:"var(--mantine-color-dimmed)"}}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:500,size:"sm",lineClamp:2,children:deal.title})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"blue",children:formatAmount(deal.value,deal.currency)})]}),deal.lead.company?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:deal.lead.company}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:`${temperature.P[deal.lead.temperature]?.emoji??""} ${DealCard_personLabel(deal)}`.trim()}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[null!==deal.probability?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"gray",size:"sm",children:`${deal.probability} %`}):null,null!==deal.expected_close_date?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"gray",size:"sm",children:`\xc9ch\xe9ance : ${formatDay(deal.expected_close_date)}`}):null]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",size:"sm","aria-label":"\xc9tape pr\xe9c\xe9dente",disabled:null===previous||update.isPending,onClick:e=>{e.stopPropagation();move(previous)},children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronLeft,{size:16})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",size:"sm","aria-label":"\xc9tape suivante",disabled:null===next||update.isPending,onClick:e=>{e.stopPropagation();move(next)},children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconChevronRight,{size:16})})]})]})})}function KanbanBoard({pipeline,status,stages,deals,onOpen}){const move=useMoveDealStage(pipeline,status);const[draggedId,setDraggedId]=(0,consume_shared_module_default_react_strict_.useState)(null);const[hoveredStageId,setHoveredStageId]=(0,consume_shared_module_default_react_strict_.useState)(null);const draggedDeal=null===draggedId?null:deals.find(d=>d.id===draggedId)??null;function resetDrag(){setDraggedId(null);setHoveredStageId(null)}function handleDrop(e,stage){e.preventDefault();const raw=Number(e.dataTransfer.getData("text/plain"));const dealId=Number.isFinite(raw)&&raw>0?raw:draggedId;resetDrag();if(null===dealId)return;const deal=deals.find(d=>d.id===dealId);if(void 0===deal||deal.stage_id===stage.id)return;move.mutate({id:deal.id,stage_id:stage.id})}if(0===stages.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:"Aucune \xe9tape configur\xe9e pour ce pipeline"});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Box,{style:{display:"flex",gap:"var(--mantine-spacing-md)",alignItems:"flex-start",overflowX:"auto",paddingBottom:"var(--mantine-spacing-sm)"},children:stages.map(stage=>{const stageDeals=deals.filter(d=>d.stage_id===stage.id);const isDropTarget=hoveredStageId===stage.id&&null!==draggedDeal&&draggedDeal.stage_id!==stage.id;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{withBorder:true,radius:"md",p:"sm",style:{flex:"0 0 300px",width:300,backgroundColor:isDropTarget?"var(--mantine-color-blue-light)":void 0,outline:isDropTarget?"2px solid var(--mantine-color-blue-filled)":void 0,outlineOffset:2,transition:"background-color 120ms ease"},onDragOver:e=>{if(null===draggedId)return;e.preventDefault();e.dataTransfer.dropEffect="move";if(hoveredStageId!==stage.id)setHoveredStageId(stage.id)},onDragLeave:e=>{if(e.currentTarget.contains(e.relatedTarget))return;if(hoveredStageId===stage.id)setHoveredStageId(null)},onDrop:e=>handleDrop(e,stage),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",mih:140,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,size:"sm",children:stage.name}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"gray",children:stage.deal_count})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:formatEur(stage.total_value)})]}),0===stageDeals.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:isDropTarget?"D\xe9poser ici":"Aucun deal"}):null,stageDeals.map(deal=>/*#__PURE__*/(0,jsx_runtime.jsx)(DealCard,{deal:deal,stages:stages,isDragging:draggedId===deal.id,onOpen:onOpen,onDragStart:setDraggedId,onDragEnd:resetDrag},deal.id))]})},stage.id)})})}function useCreateDeal(){const api=(0,useApi.h)();const queryClient=(0,index_js_.useQueryClient)();return(0,index_js_.useMutation)({mutationFn:async payload=>(await api.sales.createDealV1(payload)).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Deal cr\xe9\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Deal",message:err?.error?.error??err?.message??"\xc9chec de la cr\xe9ation",color:"red"})}})}var leadsQuery=__webpack_require__(1334);var NewLeadModal=__webpack_require__(9328);function leadLabel(lead){const name=[lead.first_name,lead.last_name].filter(Boolean).join(" ");if(lead.company&&name)return`${name} (${lead.company})`;if(lead.company)return lead.company;if(name)return name;return`Lead ${lead.id}`}function NewDealForm({onClose,stages}){const leads=(0,leadsQuery.m)("active");const create=useCreateDeal();const[leadId,setLeadId]=(0,consume_shared_module_default_react_strict_.useState)(null);const[newLeadOpened,setNewLeadOpened]=(0,consume_shared_module_default_react_strict_.useState)(false);const[createdLead,setCreatedLead]=(0,consume_shared_module_default_react_strict_.useState)(null);const[title,setTitle]=(0,consume_shared_module_default_react_strict_.useState)("");const[value,setValue]=(0,consume_shared_module_default_react_strict_.useState)("");const[stageId,setStageId]=(0,consume_shared_module_default_react_strict_.useState)(stages.length>0?String(stages[0].id):null);const leadOptions=(leads.data?.leads??[]).map(lead=>({value:String(lead.id),label:leadLabel(lead)}));if(createdLead&&!leadOptions.some(option=>option.value===String(createdLead.id)))leadOptions.push({value:String(createdLead.id),label:leadLabel(createdLead)});function submit(){if(null===leadId||null===stageId||""===title.trim())return void notifications_esm_index_mjs_.notifications.show({title:"Deal",message:"Renseignez un lead, un titre et une \xe9tape",color:"orange"});create.mutate({lead_id:Number(leadId),stage_id:Number(stageId),title:title.trim(),value:""===value?0:Number(value),currency:"EUR"},{onSuccess:onClose})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Lead",placeholder:"Rechercher un lead",searchable:true,nothingFoundMessage:"Aucun lead",data:leadOptions,value:leadId,onChange:setLeadId}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"subtle",size:"compact-sm",style:{alignSelf:"flex-start"},onClick:()=>setNewLeadOpened(true),children:"+ Cr\xe9er un nouveau lead"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Titre",value:title,onChange:e=>setTitle(e.currentTarget.value)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{label:"Montant (EUR)",value:value,onChange:setValue,min:0,thousandSeparator:" ",decimalSeparator:","}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"\xc9tape",data:stages.map(s=>({value:String(s.id),label:s.name})),value:stageId,onChange:setStageId}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:onClose,children:"Annuler"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:create.isPending,onClick:submit,children:"Cr\xe9er"})]}),newLeadOpened?/*#__PURE__*/(0,jsx_runtime.jsx)(NewLeadModal.A,{opened:true,onClose:()=>setNewLeadOpened(false),onCreated:lead=>{setCreatedLead(lead);setLeadId(String(lead.id))}}):null]})}function NewDealModal({opened,onClose,stages}){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:opened,onClose:onClose,title:"Nouveau deal",children:opened?/*#__PURE__*/(0,jsx_runtime.jsx)(NewDealForm,{onClose:onClose,stages:stages}):null})}function PipelineApp(){const[pipeline,setPipeline]=(0,consume_shared_module_default_react_strict_.useState)("new_business");const[status,setStatus]=(0,consume_shared_module_default_react_strict_.useState)("open");const[selectedId,setSelectedId]=(0,consume_shared_module_default_react_strict_.useState)(null);const[newDealOpened,newDeal]=(0,esm_index_mjs_.useDisclosure)(false);const deals=useSalesDeals(pipeline,status);const exportDeals=useExportDeals();const stages=deals.data?.stages??[];const rows=deals.data?.deals??[];const selected=(0,consume_shared_module_default_react_strict_.useMemo)(()=>{if(null===selectedId)return null;return rows.find(d=>d.id===selectedId)??null},[rows,selectedId]);const total=rows.reduce((acc,d)=>acc+d.value,0);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{fluid:true,my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",mb:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Pipeline"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{variant:"light",color:"blue",children:`${rows.length} deal(s) : ${formatEur(total)}`}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:newDeal.open,disabled:0===stages.length,children:"+ Nouveau deal"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"light",leftSection:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTableExport,{size:16}),loading:exportDeals.isPending,disabled:exportDeals.isPending,onClick:()=>exportDeals.mutate(),children:"Exporter vers le reporting"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",mb:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:pipeline,onChange:setPipeline,data:[{label:"New Business",value:"new_business"},{label:"Upsell / Cross-sell",value:"upsell"}]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{value:status,onChange:setStatus,data:[{label:"Ouverts",value:"open"},{label:"Gagn\xe9s",value:"won"},{label:"Perdus",value:"lost"}]})]}),deals.isLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Loader,{}):null,deals.data&&"open"===status?/*#__PURE__*/(0,jsx_runtime.jsx)(KanbanBoard,{pipeline:pipeline,status:status,stages:stages,deals:rows,onOpen:setSelectedId}):null,deals.data&&"open"!==status?/*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:0===rows.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",children:"Aucun deal"}):/*#__PURE__*/(0,jsx_runtime.jsx)(DealsTable,{deals:rows,stages:stages,status:status,onRowClick:setSelectedId})}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(NewDealModal,{opened:newDealOpened,onClose:newDeal.close,stages:stages}),/*#__PURE__*/(0,jsx_runtime.jsx)(DealDetailDrawer,{deal:selected,stages:stages,onClose:()=>setSelectedId(null)})]})}function Pipeline(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(consume_shared_module_default_react_strict_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(PipelineApp,{})})})}}}]);