@airporting/tech-app 0.0.42 → 0.0.44

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});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})};financeJobs={getStockV1:(params={})=>this.http.request({path:"/v1/finance-jobs/stock",method:"GET",format:"json",...params}),listTasksV1:(query,params={})=>this.http.request({path:"/v1/finance-jobs/tasks",method:"GET",query:query,format:"json",...params}),unstickV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/unstick`,method:"POST",format:"json",...params}),retryV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/retry`,method:"POST",format:"json",...params}),discardV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/discard`,method:"POST",format:"json",...params}),setOwnerV1:({id,...query},data,params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/owner`,method:"PUT",body:data,type:"application/json",format:"json",...params}),deleteRedisLockV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/redis-lock`,method:"DELETE",format:"json",...params})};github={getJobsRunnersV1:(params={})=>this.http.request({path:"/v1/github/jobs/runners",method:"GET",format:"json",...params}),getLabelsV1:({host,...query},params={})=>this.http.request({path:`/v1/github/labels/${host}`,method:"GET",format:"json",...params}),getJobLogsV1:(query,params={})=>this.http.request({path:"/v1/github/job-logs",method:"GET",query:query,format:"json",...params})};gsheet={getStockV1:(params={})=>this.http.request({path:"/v1/gsheet/stock",method:"GET",format:"json",...params}),listTasksV1:(query,params={})=>this.http.request({path:"/v1/gsheet/tasks",method:"GET",query:query,format:"json",...params}),unstickV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/unstick`,method:"POST",format:"json",...params}),discardV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/discard`,method:"POST",format:"json",...params}),setOwnerV1:({id,...query},data,params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/owner`,method:"PUT",body:data,type:"application/json",format:"json",...params}),deleteRedisLockV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/redis-lock`,method:"DELETE",format:"json",...params})};notion={getKikouV1:(params={})=>this.http.request({path:"/v1/notion/kikou",method:"GET",format:"json",...params})};payfit={getChartV1:(query,params={})=>this.http.request({path:"/v1/payfit/chart",method:"GET",query:query,...params})};sobank={getExportsV1:(query,params={})=>this.http.request({path:"/v1/sobank/exports",method:"GET",query:query,format:"json",...params})};synchro={getRunStatsV1:(params={})=>this.http.request({path:"/v1/synchro/run/stats",method:"GET",format:"json",...params}),getTasksV1:(query,params={})=>this.http.request({path:"/v1/synchro/tasks",method:"GET",query:query,format:"json",...params}),getJobsDefaultsV1:(params={})=>this.http.request({path:"/v1/synchro/jobs/defaults",method:"GET",format:"json",...params}),putStopTaskV1:({id,...query},params={})=>this.http.request({path:`/v1/synchro/tasks/stop/${id}`,method:"PUT",...params}),resetOwnerStatsV1:({owner,value,...query},params={})=>this.http.request({path:`/v1/synchro/run/stats/${owner}/${value}`,method:"PUT",...params})}}},7936:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{$:()=>AppConfigProvider,M:()=>useAppConfig});var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(3106);const AppConfigCtx=(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(null);const AppConfigProvider=AppConfigCtx.Provider;function useAppConfig(){const config=(0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(AppConfigCtx);if(!config)throw new Error("Called `useAppConfig` outside a `<AppConfigProvider />`");return config}},7034:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{C:()=>Providers});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _airporting_app_front__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1380);var _mantine_core__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(207);var _mantine_modals__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4142);var _mantine_notifications__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(1455);var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(6197);var radash__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9877);var _hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(7936);const theme=(0,_mantine_core__WEBPACK_IMPORTED_MODULE_2__.createTheme)((0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.theme,{components:{}}));const cssVarResolver=x=>(0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.cssVarResolver(x),{dark:{},light:{},variables:{}});function Providers(props){const{children,config,mantine,tanstack}=props;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__.$,{value:config,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClientProvider,{client:tanstack?.queryClient??new _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClient,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_2__.MantineProvider,{theme:theme,cssVariablesResolver:cssVarResolver,defaultColorScheme:mantine?.defaultColorScheme,forceColorScheme:mantine?.forceColorScheme,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_modals__WEBPACK_IMPORTED_MODULE_3__.ModalsProvider,{children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_notifications__WEBPACK_IMPORTED_MODULE_4__.Notifications,{}),children]})})})})}}}]);
10
+ */var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element"),REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");function jsxProd(type,config,maybeKey){var key=null;void 0!==maybeKey&&(key=""+maybeKey);void 0!==config.key&&(key=""+config.key);if("key"in config){maybeKey={};for(var propName in config)"key"!==propName&&(maybeKey[propName]=config[propName])}else maybeKey=config;config=maybeKey.ref;return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:key,ref:void 0!==config?config:null,props:maybeKey}}exports.Fragment=REACT_FRAGMENT_TYPE;exports.jsx=jsxProd;exports.jsxs=jsxProd},5893:function(module,__unused_webpack_exports,__webpack_require__){module.exports=__webpack_require__(631)},4148:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{h:()=>useApi});var _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(9056);var _src_hooks_useAppConfig_ts__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(7936);function useApi(){const config=(0,_src_hooks_useAppConfig_ts__WEBPACK_IMPORTED_MODULE_0__.M)();const client=new _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__.eN({baseUrl:config.api.replace(/\/$/,""),baseApiParams:{headers:{Authorization:config.token?`Bearer ${config.token}`:"",From:config.owner}}});return new _src_gen_TechApi_index_ts__WEBPACK_IMPORTED_MODULE_1__.eT(client)}},9056:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{eN:()=>HttpClient,eT:()=>TechApi});class HttpClient{baseUrl="";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...fetchParams)=>fetch(...fetchParams);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(apiConfig={}){Object.assign(this,apiConfig)}setSecurityData=data=>{this.securityData=data};encodeQueryParam(key,value){const encodedKey=encodeURIComponent(key);return`${encodedKey}=${encodeURIComponent("number"==typeof value?value:`${value}`)}`}addQueryParam(query,key){return this.encodeQueryParam(key,query[key])}addArrayQueryParam(query,key){const value=query[key];return value.map(v=>this.encodeQueryParam(key,v)).join("&")}toQueryString(rawQuery){const query=rawQuery||{};const keys=Object.keys(query).filter(key=>void 0!==query[key]);return keys.map(key=>Array.isArray(query[key])?this.addArrayQueryParam(query,key):this.addQueryParam(query,key)).join("&")}addQueryParams(rawQuery){const queryString=this.toQueryString(rawQuery);return queryString?`?${queryString}`:""}contentFormatters={["application/json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["application/vnd.api+json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["text/plain"]:input=>null!==input&&"string"!=typeof input?JSON.stringify(input):input,["multipart/form-data"]:input=>{if(input instanceof FormData)return input;return Object.keys(input||{}).reduce((formData,key)=>{const property=input[key];formData.append(key,property instanceof Blob?property:"object"==typeof property&&null!==property?JSON.stringify(property):`${property}`);return formData},new FormData)},["application/x-www-form-urlencoded"]:input=>this.toQueryString(input)};mergeRequestParams(params1,params2){return{...this.baseApiParams,...params1,...params2||{},headers:{...this.baseApiParams.headers||{},...params1.headers||{},...params2&&params2.headers||{}}}}createAbortSignal=cancelToken=>{if(this.abortControllers.has(cancelToken)){const abortController=this.abortControllers.get(cancelToken);if(abortController)return abortController.signal;return}const abortController=new AbortController;this.abortControllers.set(cancelToken,abortController);return abortController.signal};abortRequest=cancelToken=>{const abortController=this.abortControllers.get(cancelToken);if(abortController){abortController.abort();this.abortControllers.delete(cancelToken)}};request=async({body,secure,path,type,query,format,baseUrl,cancelToken,...params})=>{const secureParams=("boolean"==typeof secure?secure:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{};const requestParams=this.mergeRequestParams(params,secureParams);const queryString=query&&this.toQueryString(query);const payloadFormatter=this.contentFormatters[type||"application/json"];const responseFormat=format||requestParams.format;return this.customFetch(`${baseUrl||this.baseUrl||""}${path}${queryString?`?${queryString}`:""}`,{...requestParams,headers:{...requestParams.headers||{},...type&&"multipart/form-data"!==type?{"Content-Type":type}:{}},signal:(cancelToken?this.createAbortSignal(cancelToken):requestParams.signal)||null,body:null==body?null:payloadFormatter(body)}).then(async response=>{const r=response;r.data=null;r.error=null;const responseToParse=responseFormat?response.clone():response;const data=responseFormat?await responseToParse[responseFormat]().then(data=>{if(r.ok)r.data=data;else r.error=data;return r}).catch(e=>{r.error=e;return r}):r;if(cancelToken)this.abortControllers.delete(cancelToken);if(!response.ok)throw data;return data})}}class TechApi{http;constructor(http){this.http=http}status=(params={})=>this.http.request({path:"/status",method:"GET",...params});getDashboard=(params={})=>this.http.request({path:"/dashboard",method:"GET",format:"json",...params});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}),recomputeV1:(params={})=>this.http.request({path:"/v1/etat-saisie/recompute",method:"POST",format:"json",...params})};financeJobs={getStockV1:(params={})=>this.http.request({path:"/v1/finance-jobs/stock",method:"GET",format:"json",...params}),listTasksV1:(query,params={})=>this.http.request({path:"/v1/finance-jobs/tasks",method:"GET",query:query,format:"json",...params}),unstickV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/unstick`,method:"POST",format:"json",...params}),retryV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/retry`,method:"POST",format:"json",...params}),discardV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/discard`,method:"POST",format:"json",...params}),setOwnerV1:({id,...query},data,params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/owner`,method:"PUT",body:data,type:"application/json",format:"json",...params}),deleteRedisLockV1:({id,...query},params={})=>this.http.request({path:`/v1/finance-jobs/tasks/${id}/redis-lock`,method:"DELETE",format:"json",...params}),runRecipeV1:(data,params={})=>this.http.request({path:"/v1/finance-jobs/run-recipe",method:"POST",body:data,type:"application/json",format:"json",...params}),getRunnersV1:(params={})=>this.http.request({path:"/v1/finance-jobs/runners",method:"GET",format:"json",...params})};github={getJobsRunnersV1:(params={})=>this.http.request({path:"/v1/github/jobs/runners",method:"GET",format:"json",...params}),getLabelsV1:({host,...query},params={})=>this.http.request({path:`/v1/github/labels/${host}`,method:"GET",format:"json",...params}),getJobLogsV1:(query,params={})=>this.http.request({path:"/v1/github/job-logs",method:"GET",query:query,format:"json",...params})};gsheet={getStockV1:(params={})=>this.http.request({path:"/v1/gsheet/stock",method:"GET",format:"json",...params}),listTasksV1:(query,params={})=>this.http.request({path:"/v1/gsheet/tasks",method:"GET",query:query,format:"json",...params}),unstickV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/unstick`,method:"POST",format:"json",...params}),discardV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/discard`,method:"POST",format:"json",...params}),setOwnerV1:({id,...query},data,params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/owner`,method:"PUT",body:data,type:"application/json",format:"json",...params}),deleteRedisLockV1:({id,...query},params={})=>this.http.request({path:`/v1/gsheet/tasks/${id}/redis-lock`,method:"DELETE",format:"json",...params})};notion={getKikouV1:(params={})=>this.http.request({path:"/v1/notion/kikou",method:"GET",format:"json",...params})};payfit={getChartV1:(query,params={})=>this.http.request({path:"/v1/payfit/chart",method:"GET",query:query,...params})};sobank={getExportsV1:(query,params={})=>this.http.request({path:"/v1/sobank/exports",method:"GET",query:query,format:"json",...params})};synchro={getRunStatsV1:(params={})=>this.http.request({path:"/v1/synchro/run/stats",method:"GET",format:"json",...params}),getTasksV1:(query,params={})=>this.http.request({path:"/v1/synchro/tasks",method:"GET",query:query,format:"json",...params}),getJobsDefaultsV1:(params={})=>this.http.request({path:"/v1/synchro/jobs/defaults",method:"GET",format:"json",...params}),putStopTaskV1:({id,...query},params={})=>this.http.request({path:`/v1/synchro/tasks/stop/${id}`,method:"PUT",...params}),resetOwnerStatsV1:({owner,value,...query},params={})=>this.http.request({path:`/v1/synchro/run/stats/${owner}/${value}`,method:"PUT",...params})}}},7936:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{$:()=>AppConfigProvider,M:()=>useAppConfig});var react__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(3106);const AppConfigCtx=(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(null);const AppConfigProvider=AppConfigCtx.Provider;function useAppConfig(){const config=(0,react__WEBPACK_IMPORTED_MODULE_0__.useContext)(AppConfigCtx);if(!config)throw new Error("Called `useAppConfig` outside a `<AppConfigProvider />`");return config}},7034:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{C:()=>Providers});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _airporting_app_front__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1380);var _mantine_core__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(207);var _mantine_modals__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4142);var _mantine_notifications__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(1455);var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(6197);var radash__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9877);var _hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(7936);const theme=(0,_mantine_core__WEBPACK_IMPORTED_MODULE_2__.createTheme)((0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.theme,{components:{}}));const cssVarResolver=x=>(0,radash__WEBPACK_IMPORTED_MODULE_6__.assign)(_airporting_app_front__WEBPACK_IMPORTED_MODULE_1__.cssVarResolver(x),{dark:{},light:{},variables:{}});function Providers(props){const{children,config,mantine,tanstack}=props;return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_hooks_useAppConfig__WEBPACK_IMPORTED_MODULE_7__.$,{value:config,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClientProvider,{client:tanstack?.queryClient??new _tanstack_react_query__WEBPACK_IMPORTED_MODULE_5__.QueryClient,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_2__.MantineProvider,{theme:theme,cssVariablesResolver:cssVarResolver,defaultColorScheme:mantine?.defaultColorScheme,forceColorScheme:mantine?.forceColorScheme,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_modals__WEBPACK_IMPORTED_MODULE_3__.ModalsProvider,{children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_notifications__WEBPACK_IMPORTED_MODULE_4__.Notifications,{}),children]})})})})}}}]);
@@ -0,0 +1 @@
1
+ export declare function useEtatSaisieLatest(): import("@tanstack/react-query").UseQueryResult<import("../../../gen/TechApi/index.ts").GetEtatSaisieLatestResponse, Error>;
@@ -0,0 +1 @@
1
+ export declare function useEtatSaisieRecompute(): import("@tanstack/react-query").UseMutationResult<import("../../../gen/TechApi/index.ts").RecomputeEtatSaisieResponse, Error, void, unknown>;
@@ -0,0 +1,4 @@
1
+ export declare function useRunRecipe(): import("@tanstack/react-query").UseMutationResult<{
2
+ dispatched: number;
3
+ message?: string;
4
+ }, any, number, unknown>;
@@ -0,0 +1 @@
1
+ export declare function useFinanceRunners(): import("@tanstack/react-query").UseQueryResult<any, Error>;
@@ -0,0 +1,9 @@
1
+ export type Column<T> = {
2
+ key: keyof T & string;
3
+ label: string;
4
+ numeric?: boolean;
5
+ };
6
+ export declare function DetailTable<T>(props: {
7
+ columns: Column<T>[];
8
+ rows: T[];
9
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function EtatSaisieApp(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function RunRecipeButton(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function RunnerBadge(): import("react/jsx-runtime").JSX.Element;
@@ -24,6 +24,83 @@ export interface DiscardV1Params {
24
24
  export interface DiscardV1Params2 {
25
25
  id: number;
26
26
  }
27
+ export interface EtatSaisieCustomerRow {
28
+ client: string;
29
+ devise: string;
30
+ dossier: string;
31
+ nb_ecritures: number;
32
+ solde_crediteur_eur: number;
33
+ source: string;
34
+ }
35
+ export interface EtatSaisieDossierLine {
36
+ dossier: string;
37
+ gla_active: boolean;
38
+ last_entry_date: string | null;
39
+ solde_attente_eur: number;
40
+ source: string;
41
+ status: string;
42
+ total_clients_eur: number;
43
+ total_fournisseurs_eur: number;
44
+ }
45
+ export interface EtatSaisieSummary {
46
+ top_5_customer_creditors: EtatSaisieTopCustomerItem[];
47
+ top_5_supplier_debtors: EtatSaisieTopSupplierItem[];
48
+ top_5_suspense: EtatSaisieTopSuspenseItem[];
49
+ companies_clean: number;
50
+ companies_in_error: number;
51
+ companies_scanned: number;
52
+ companies_with_anomalies: number;
53
+ }
54
+ export interface EtatSaisieSupplierRow {
55
+ devise: string;
56
+ dossier: string;
57
+ fournisseur: string;
58
+ nb_ecritures: number;
59
+ solde_debiteur_eur: number;
60
+ source: string;
61
+ }
62
+ export interface EtatSaisieSuspenseRow {
63
+ credit: number;
64
+ date: string;
65
+ debit: number;
66
+ devise: string;
67
+ dossier: string;
68
+ journal: string | null;
69
+ lettre: boolean;
70
+ libelle_compte: string | null;
71
+ libelle_ecriture: string | null;
72
+ numero_compte: string | null;
73
+ numero_piece: string | null;
74
+ solde_net: number;
75
+ source: string;
76
+ }
77
+ export interface EtatSaisieTopCustomerItem {
78
+ dossier: string;
79
+ nb_clients: number;
80
+ rank: number;
81
+ source: string;
82
+ top_montant: number | null;
83
+ top_nom: string | null;
84
+ total_eur: number;
85
+ }
86
+ export interface EtatSaisieTopSupplierItem {
87
+ dossier: string;
88
+ nb_fournisseurs: number;
89
+ rank: number;
90
+ source: string;
91
+ top_montant: number | null;
92
+ top_nom: string | null;
93
+ total_eur: number;
94
+ }
95
+ export interface EtatSaisieTopSuspenseItem {
96
+ dossier: string;
97
+ nb_ecritures: number;
98
+ rank: number;
99
+ solde_eur: number;
100
+ source: string;
101
+ top_libelle: string | null;
102
+ top_montant: number | null;
103
+ }
27
104
  export interface FinanceJobsActionResponse {
28
105
  message?: string;
29
106
  ok: boolean;
@@ -111,6 +188,19 @@ export interface GetDashboardResponse {
111
188
  pennylane: GetDashboardPennylaneResponse;
112
189
  synchro: GetSynchroDashboardResponse;
113
190
  }
191
+ export interface GetEtatSaisieLatestResponse {
192
+ as_of: string | null;
193
+ available: boolean;
194
+ computed_at: string | null;
195
+ customer_rows: EtatSaisieCustomerRow[];
196
+ no_data: EtatSaisieDossierLine[];
197
+ not_managed: EtatSaisieDossierLine[];
198
+ scan_duration_seconds: number | null;
199
+ status: string | null;
200
+ summary: EtatSaisieSummary | null;
201
+ supplier_rows: EtatSaisieSupplierRow[];
202
+ suspense_rows: EtatSaisieSuspenseRow[];
203
+ }
114
204
  export interface GetExportsQuery {
115
205
  balanceDateAfter?: string;
116
206
  balanceDateBefore?: string;
@@ -142,6 +232,10 @@ export interface GetFinanceJobsStockResponse {
142
232
  running: number;
143
233
  stuck: number;
144
234
  }
235
+ export interface GetFinanceRunnersResponse {
236
+ inProgress: number;
237
+ queued: number;
238
+ }
145
239
  export interface GetGithubHostLabelsResponse {
146
240
  runners: {
147
241
  labels: string[];
@@ -314,6 +408,10 @@ export interface PostSmsWebhookParams {
314
408
  export interface PutStopTaskV1Params {
315
409
  id: number;
316
410
  }
411
+ export interface RecomputeEtatSaisieResponse {
412
+ message: string;
413
+ ok: boolean;
414
+ }
317
415
  export interface ResetOwnerStatsV1Params {
318
416
  owner: string;
319
417
  value: string;
@@ -321,6 +419,14 @@ export interface ResetOwnerStatsV1Params {
321
419
  export interface RetryV1Params {
322
420
  id: number;
323
421
  }
422
+ export interface RunRecipeBody {
423
+ count: number;
424
+ }
425
+ export interface RunRecipeResponse {
426
+ dispatched: number;
427
+ message?: string;
428
+ ok: boolean;
429
+ }
324
430
  export interface SetFinanceJobsOwnerBody {
325
431
  owner: string;
326
432
  }
@@ -380,7 +486,7 @@ export interface UserItemRunStats {
380
486
  redis: number;
381
487
  }
382
488
  export interface UsersRunStatsResponse {
383
- "mathieu.kim-robin": UserItemRunStats;
489
+ 'mathieu.kim-robin': UserItemRunStats;
384
490
  comptabilite: UserItemRunStats;
385
491
  marwa: UserItemRunStats;
386
492
  mathieu: UserItemRunStats;
@@ -424,6 +530,36 @@ export declare namespace Amex {
424
530
  type ResponseBody = void;
425
531
  }
426
532
  }
533
+ export declare namespace EtatSaisie {
534
+ /**
535
+ * No description
536
+ * @tags EtatSaisie
537
+ * @name GetLatestV1
538
+ * @request GET:/v1/etat-saisie/latest
539
+ * @response `200` `GetEtatSaisieLatestResponse`
540
+ */
541
+ namespace GetLatestV1 {
542
+ type RequestParams = {};
543
+ type RequestQuery = {};
544
+ type RequestBody = never;
545
+ type RequestHeaders = {};
546
+ type ResponseBody = GetEtatSaisieLatestResponse;
547
+ }
548
+ /**
549
+ * No description
550
+ * @tags EtatSaisie
551
+ * @name RecomputeV1
552
+ * @request POST:/v1/etat-saisie/recompute
553
+ * @response `201` `RecomputeEtatSaisieResponse`
554
+ */
555
+ namespace RecomputeV1 {
556
+ type RequestParams = {};
557
+ type RequestQuery = {};
558
+ type RequestBody = never;
559
+ type RequestHeaders = {};
560
+ type ResponseBody = RecomputeEtatSaisieResponse;
561
+ }
562
+ }
427
563
  export declare namespace FinanceJobs {
428
564
  /**
429
565
  * No description
@@ -541,6 +677,34 @@ export declare namespace FinanceJobs {
541
677
  type RequestHeaders = {};
542
678
  type ResponseBody = DeleteFinanceJobsRedisLockResponse;
543
679
  }
680
+ /**
681
+ * No description
682
+ * @tags FinanceJobs
683
+ * @name RunRecipeV1
684
+ * @request POST:/v1/finance-jobs/run-recipe
685
+ * @response `201` `RunRecipeResponse`
686
+ */
687
+ namespace RunRecipeV1 {
688
+ type RequestParams = {};
689
+ type RequestQuery = {};
690
+ type RequestBody = RunRecipeBody;
691
+ type RequestHeaders = {};
692
+ type ResponseBody = RunRecipeResponse;
693
+ }
694
+ /**
695
+ * No description
696
+ * @tags FinanceJobs
697
+ * @name GetRunnersV1
698
+ * @request GET:/v1/finance-jobs/runners
699
+ * @response `200` `GetFinanceRunnersResponse`
700
+ */
701
+ namespace GetRunnersV1 {
702
+ type RequestParams = {};
703
+ type RequestQuery = {};
704
+ type RequestBody = never;
705
+ type RequestHeaders = {};
706
+ type ResponseBody = GetFinanceRunnersResponse;
707
+ }
544
708
  }
545
709
  export declare namespace Github {
546
710
  /**
@@ -834,8 +998,8 @@ export declare namespace Synchro {
834
998
  }
835
999
  }
836
1000
  export type QueryParamsType = Record<string | number, any>;
837
- export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
838
- export interface FullRequestParams extends Omit<RequestInit, "body"> {
1001
+ export type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>;
1002
+ export interface FullRequestParams extends Omit<RequestInit, 'body'> {
839
1003
  /** set parameter to `true` for call `securityWorker` for this request */
840
1004
  secure?: boolean;
841
1005
  /** request path */
@@ -853,10 +1017,10 @@ export interface FullRequestParams extends Omit<RequestInit, "body"> {
853
1017
  /** request cancellation token */
854
1018
  cancelToken?: CancelToken;
855
1019
  }
856
- export type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path">;
1020
+ export type RequestParams = Omit<FullRequestParams, 'body' | 'method' | 'query' | 'path'>;
857
1021
  export interface ApiConfig<SecurityDataType = unknown> {
858
1022
  baseUrl?: string;
859
- baseApiParams?: Omit<RequestParams, "baseUrl" | "cancelToken" | "signal">;
1023
+ baseApiParams?: Omit<RequestParams, 'baseUrl' | 'cancelToken' | 'signal'>;
860
1024
  securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
861
1025
  customFetch?: typeof fetch;
862
1026
  }
@@ -951,6 +1115,26 @@ export declare class TechApi<SecurityDataType extends unknown> {
951
1115
  */
952
1116
  getTransactionsV1: (query: GetTransactionsV1Params, params?: RequestParams) => Promise<HttpResponse<void, any>>;
953
1117
  };
1118
+ etatSaisie: {
1119
+ /**
1120
+ * No description
1121
+ *
1122
+ * @tags EtatSaisie
1123
+ * @name GetLatestV1
1124
+ * @request GET:/v1/etat-saisie/latest
1125
+ * @response `200` `GetEtatSaisieLatestResponse`
1126
+ */
1127
+ getLatestV1: (params?: RequestParams) => Promise<HttpResponse<GetEtatSaisieLatestResponse, any>>;
1128
+ /**
1129
+ * No description
1130
+ *
1131
+ * @tags EtatSaisie
1132
+ * @name RecomputeV1
1133
+ * @request POST:/v1/etat-saisie/recompute
1134
+ * @response `201` `RecomputeEtatSaisieResponse`
1135
+ */
1136
+ recomputeV1: (params?: RequestParams) => Promise<HttpResponse<RecomputeEtatSaisieResponse, any>>;
1137
+ };
954
1138
  financeJobs: {
955
1139
  /**
956
1140
  * No description
@@ -1015,6 +1199,24 @@ export declare class TechApi<SecurityDataType extends unknown> {
1015
1199
  * @response `200` `DeleteFinanceJobsRedisLockResponse`
1016
1200
  */
1017
1201
  deleteRedisLockV1: ({ id, ...query }: DeleteRedisLockV1Params, params?: RequestParams) => Promise<HttpResponse<DeleteFinanceJobsRedisLockResponse, any>>;
1202
+ /**
1203
+ * No description
1204
+ *
1205
+ * @tags FinanceJobs
1206
+ * @name RunRecipeV1
1207
+ * @request POST:/v1/finance-jobs/run-recipe
1208
+ * @response `201` `RunRecipeResponse`
1209
+ */
1210
+ runRecipeV1: (data: RunRecipeBody, params?: RequestParams) => Promise<HttpResponse<RunRecipeResponse, any>>;
1211
+ /**
1212
+ * No description
1213
+ *
1214
+ * @tags FinanceJobs
1215
+ * @name GetRunnersV1
1216
+ * @request GET:/v1/finance-jobs/runners
1217
+ * @response `200` `GetFinanceRunnersResponse`
1218
+ */
1219
+ getRunnersV1: (params?: RequestParams) => Promise<HttpResponse<GetFinanceRunnersResponse, any>>;
1018
1220
  };
1019
1221
  github: {
1020
1222
  /**
@@ -0,0 +1,2 @@
1
+ import { ProvidersProps } from '../providers.tsx';
2
+ export default function EtatSaisie(props: ProvidersProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './compiled-types/tabs/etat-saisie';
2
+ export { default } from './compiled-types/tabs/etat-saisie';
@@ -1,3 +1,3 @@
1
1
 
2
- export type RemoteKeys = 'REMOTE_ALIAS_IDENTIFIER/amex' | 'REMOTE_ALIAS_IDENTIFIER/bnpp' | 'REMOTE_ALIAS_IDENTIFIER/credmut' | 'REMOTE_ALIAS_IDENTIFIER/dashboard' | 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' | 'REMOTE_ALIAS_IDENTIFIER/github' | 'REMOTE_ALIAS_IDENTIFIER/payfit' | 'REMOTE_ALIAS_IDENTIFIER/sobank' | 'REMOTE_ALIAS_IDENTIFIER/spendesk' | 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' | 'REMOTE_ALIAS_IDENTIFIER/synchro' | 'REMOTE_ALIAS_IDENTIFIER/wise';
3
- type PackageType<T> = T extends 'REMOTE_ALIAS_IDENTIFIER/wise' ? typeof import('REMOTE_ALIAS_IDENTIFIER/wise') :T extends 'REMOTE_ALIAS_IDENTIFIER/synchro' ? typeof import('REMOTE_ALIAS_IDENTIFIER/synchro') :T extends 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spreadsheet') :T extends 'REMOTE_ALIAS_IDENTIFIER/spendesk' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spendesk') :T extends 'REMOTE_ALIAS_IDENTIFIER/sobank' ? typeof import('REMOTE_ALIAS_IDENTIFIER/sobank') :T extends 'REMOTE_ALIAS_IDENTIFIER/payfit' ? typeof import('REMOTE_ALIAS_IDENTIFIER/payfit') :T extends 'REMOTE_ALIAS_IDENTIFIER/github' ? typeof import('REMOTE_ALIAS_IDENTIFIER/github') :T extends 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' ? typeof import('REMOTE_ALIAS_IDENTIFIER/finance-jobs') :T extends 'REMOTE_ALIAS_IDENTIFIER/dashboard' ? typeof import('REMOTE_ALIAS_IDENTIFIER/dashboard') :T extends 'REMOTE_ALIAS_IDENTIFIER/credmut' ? typeof import('REMOTE_ALIAS_IDENTIFIER/credmut') :T extends 'REMOTE_ALIAS_IDENTIFIER/bnpp' ? typeof import('REMOTE_ALIAS_IDENTIFIER/bnpp') :T extends 'REMOTE_ALIAS_IDENTIFIER/amex' ? typeof import('REMOTE_ALIAS_IDENTIFIER/amex') :any;
2
+ export type RemoteKeys = 'REMOTE_ALIAS_IDENTIFIER/amex' | 'REMOTE_ALIAS_IDENTIFIER/bnpp' | 'REMOTE_ALIAS_IDENTIFIER/credmut' | 'REMOTE_ALIAS_IDENTIFIER/dashboard' | 'REMOTE_ALIAS_IDENTIFIER/etat-saisie' | 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' | 'REMOTE_ALIAS_IDENTIFIER/github' | 'REMOTE_ALIAS_IDENTIFIER/payfit' | 'REMOTE_ALIAS_IDENTIFIER/sobank' | 'REMOTE_ALIAS_IDENTIFIER/spendesk' | 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' | 'REMOTE_ALIAS_IDENTIFIER/synchro' | 'REMOTE_ALIAS_IDENTIFIER/wise';
3
+ type PackageType<T> = T extends 'REMOTE_ALIAS_IDENTIFIER/wise' ? typeof import('REMOTE_ALIAS_IDENTIFIER/wise') :T extends 'REMOTE_ALIAS_IDENTIFIER/synchro' ? typeof import('REMOTE_ALIAS_IDENTIFIER/synchro') :T extends 'REMOTE_ALIAS_IDENTIFIER/spreadsheet' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spreadsheet') :T extends 'REMOTE_ALIAS_IDENTIFIER/spendesk' ? typeof import('REMOTE_ALIAS_IDENTIFIER/spendesk') :T extends 'REMOTE_ALIAS_IDENTIFIER/sobank' ? typeof import('REMOTE_ALIAS_IDENTIFIER/sobank') :T extends 'REMOTE_ALIAS_IDENTIFIER/payfit' ? typeof import('REMOTE_ALIAS_IDENTIFIER/payfit') :T extends 'REMOTE_ALIAS_IDENTIFIER/github' ? typeof import('REMOTE_ALIAS_IDENTIFIER/github') :T extends 'REMOTE_ALIAS_IDENTIFIER/finance-jobs' ? typeof import('REMOTE_ALIAS_IDENTIFIER/finance-jobs') :T extends 'REMOTE_ALIAS_IDENTIFIER/etat-saisie' ? typeof import('REMOTE_ALIAS_IDENTIFIER/etat-saisie') :T extends 'REMOTE_ALIAS_IDENTIFIER/dashboard' ? typeof import('REMOTE_ALIAS_IDENTIFIER/dashboard') :T extends 'REMOTE_ALIAS_IDENTIFIER/credmut' ? typeof import('REMOTE_ALIAS_IDENTIFIER/credmut') :T extends 'REMOTE_ALIAS_IDENTIFIER/bnpp' ? typeof import('REMOTE_ALIAS_IDENTIFIER/bnpp') :T extends 'REMOTE_ALIAS_IDENTIFIER/amex' ? typeof import('REMOTE_ALIAS_IDENTIFIER/amex') :any;
Binary file
@@ -0,0 +1 @@
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["7915"],{7497:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>EtatSaisie});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useEtatSaisieLatest(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","etat-saisie","latest"],queryFn:async()=>(await api.etatSaisie.getLatestV1()).data,refetchOnWindowFocus:true})}function useEtatSaisieRecompute(){const api=(0,useApi.h)();const qc=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async()=>(await api.etatSaisie.recomputeV1()).data,onSuccess:()=>qc.invalidateQueries({queryKey:["tech","etat-saisie","latest"]})})}function DetailTable(props){const{columns,rows}=props;const[sortKey,setSortKey]=(0,index_js_.useState)(null);const[asc,setAsc]=(0,index_js_.useState)(false);const sorted=[...rows].sort((a,b)=>{if(!sortKey)return 0;const av=a[sortKey];const bv=b[sortKey];if("number"==typeof av&&"number"==typeof bv)return asc?av-bv:bv-av;return asc?String(av).localeCompare(String(bv)):String(bv).localeCompare(String(av))});const toggle=k=>{if(sortKey===k)setAsc(v=>!v);else{setSortKey(k);setAsc(false)}};const fmt=(v,numeric)=>{if(numeric&&"number"==typeof v)return v.toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2});if("boolean"==typeof v)return v?"✓":"";return null==v?"—":String(v)};return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{striped:true,highlightOnHover:true,withTableBorder:true,stickyHeader:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{children:columns.map(c=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Th,{onClick:()=>toggle(c.key),style:{cursor:"pointer"},children:[c.label,sortKey===c.key?asc?" ▲":" ▼":""]},c.key))})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:0===sorted.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{colSpan:columns.length,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",ta:"center",children:"Aucune ligne"})})}):sorted.map((row,i)=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tr,{children:columns.map(c=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{style:c.numeric?{textAlign:"right",fontVariantNumeric:"tabular-nums"}:void 0,children:fmt(row[c.key],c.numeric)},c.key))},i))})]})}function parisDate(iso){if(!iso)return"—";return new Date(iso).toLocaleString("fr-FR",{timeZone:"Europe/Paris"})}function EtatSaisieApp(){const latest=useEtatSaisieLatest();const recompute=useEtatSaisieRecompute();const[tab,setTab]=(0,index_js_.useState)("resume");const d=latest.data;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:"Etat saisie"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:["Derni\xe8re mise \xe0 jour : ",parisDate(d?.computed_at??null)]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:recompute.isPending,onClick:()=>recompute.mutate(),variant:"light",children:"Recalculer"})]})]}),d&&!d.available?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Aucun snapshot disponible — lancez \xab Recalculer \xbb ou attendez le run nocturne."}):/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Tabs,{value:tab,onChange:setTab,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Tabs.List,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Tab,{value:"resume",children:"R\xe9sum\xe9"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Tab,{value:"s471",children:"D\xe9tail 471"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Tab,{value:"s401",children:"Fournisseurs d\xe9biteurs (401)"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Tab,{value:"s411",children:"Clients cr\xe9diteurs (411)"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Tabs.Panel,{value:"resume",pt:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:4,mb:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:"Scann\xe9s"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"xl",children:d?.summary?.companies_scanned??0})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:"Propres"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"xl",c:"green",children:d?.summary?.companies_clean??0})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:"En anomalie"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"xl",c:"orange",children:d?.summary?.companies_with_anomalies??0})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:"En erreur"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,size:"xl",c:"red",children:d?.summary?.companies_in_error??0})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mt:"md",children:"Top 5 comptes d'attente (471)"}),/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:TOP_SUSPENSE_COLS,rows:d?.summary?.top_5_suspense??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mt:"md",children:"Top 5 fournisseurs d\xe9biteurs (401)"}),/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:TOP_SUPPLIER_COLS,rows:d?.summary?.top_5_supplier_debtors??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mt:"md",children:"Top 5 clients cr\xe9diteurs (411)"}),/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:TOP_CUSTOMER_COLS,rows:d?.summary?.top_5_customer_creditors??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mt:"md",children:"Dossiers \xe0 relancer (no_data)"}),/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:DOSSIER_COLS,rows:d?.no_data??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mt:"md",children:"Dossiers non manag\xe9s (hors agr\xe9gats)"}),/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:DOSSIER_COLS,rows:d?.not_managed??[]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s471",pt:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:SUSPENSE_COLS,rows:d?.suspense_rows??[]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s401",pt:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:SUPPLIER_COLS,rows:d?.supplier_rows??[]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tabs.Panel,{value:"s411",pt:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(DetailTable,{columns:CUSTOMER_COLS,rows:d?.customer_rows??[]})})]}),latest.isError?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",mt:"md",children:"Erreur de chargement."}):null]})}const TOP_SUSPENSE_COLS=[{key:"rank",label:"#",numeric:true},{key:"source",label:"Source"},{key:"dossier",label:"Dossier"},{key:"solde_eur",label:"Solde 471 (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr.",numeric:true},{key:"top_libelle",label:"Top \xe9criture"},{key:"top_montant",label:"Montant",numeric:true}];const TOP_SUPPLIER_COLS=[{key:"rank",label:"#",numeric:true},{key:"source",label:"Source"},{key:"dossier",label:"Dossier"},{key:"total_eur",label:"Total d\xe9biteur (€)",numeric:true},{key:"nb_fournisseurs",label:"Nb fourn.",numeric:true},{key:"top_nom",label:"Top fournisseur"},{key:"top_montant",label:"Montant",numeric:true}];const TOP_CUSTOMER_COLS=[{key:"rank",label:"#",numeric:true},{key:"source",label:"Source"},{key:"dossier",label:"Dossier"},{key:"total_eur",label:"Total cr\xe9diteur (€)",numeric:true},{key:"nb_clients",label:"Nb clients",numeric:true},{key:"top_nom",label:"Top client"},{key:"top_montant",label:"Montant",numeric:true}];const DOSSIER_COLS=[{key:"source",label:"Source"},{key:"dossier",label:"Dossier"},{key:"status",label:"Statut"},{key:"solde_attente_eur",label:"Solde attente (€)",numeric:true},{key:"total_fournisseurs_eur",label:"Total fourn. (€)",numeric:true},{key:"total_clients_eur",label:"Total clients (€)",numeric:true},{key:"last_entry_date",label:"Derni\xe8re \xe9criture"}];const SUSPENSE_COLS=[{key:"source",label:"Source"},{key:"dossier",label:"Dossier"},{key:"date",label:"Date"},{key:"numero_compte",label:"N\xb0 Compte"},{key:"libelle_compte",label:"Libell\xe9 compte"},{key:"libelle_ecriture",label:"Libell\xe9 \xe9criture"},{key:"journal",label:"Journal"},{key:"numero_piece",label:"N\xb0 Pi\xe8ce"},{key:"debit",label:"D\xe9bit",numeric:true},{key:"credit",label:"Cr\xe9dit",numeric:true},{key:"solde_net",label:"Solde net",numeric:true},{key:"lettre",label:"Lettr\xe9"},{key:"devise",label:"Devise"}];const SUPPLIER_COLS=[{key:"source",label:"Source"},{key:"dossier",label:"Dossier"},{key:"fournisseur",label:"Fournisseur"},{key:"solde_debiteur_eur",label:"Solde d\xe9biteur (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr. non lettr\xe9es",numeric:true},{key:"devise",label:"Devise"}];const CUSTOMER_COLS=[{key:"source",label:"Source"},{key:"dossier",label:"Dossier"},{key:"client",label:"Client"},{key:"solde_crediteur_eur",label:"Solde cr\xe9diteur (€)",numeric:true},{key:"nb_ecritures",label:"Nb \xe9cr. non lettr\xe9es",numeric:true},{key:"devise",label:"Devise"}];function EtatSaisie(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(EtatSaisieApp,{})})})}}}]);
@@ -1 +1 @@
1
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["7825"],{620:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{o:()=>JobLogsDrawer});var jsx_runtime=__webpack_require__(5893);var index_mjs_=__webpack_require__(207);var index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useJobLogs(githubJob){const api=(0,useApi.h)();return(0,index_js_.useQuery)({queryKey:["tech","github","job-logs",githubJob],queryFn:async()=>(await api.github.getJobLogsV1({githubJob:githubJob})).data,enabled:!!githubJob,refetchOnWindowFocus:false,retry:false})}function fallbackUrl(githubJob){const parts=githubJob.split("/");if(parts.length<3)return null;const runId=parts[parts.length-1];const repo=parts[parts.length-2];const owner=parts.slice(0,-2).join("/");return`https://github.com/${owner}/${repo}/actions/runs/${runId}`}function JobLogsDrawer({githubJob,opened,onClose}){const query=useJobLogs(opened?githubJob:null);const ghLink=githubJob?fallbackUrl(githubJob):null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Drawer,{opened:opened,onClose:onClose,position:"right",size:"60%",title:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,children:"Workflow logs"}),query.data?.conclusion&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"success"===query.data.conclusion?"green":"red",children:query.data.conclusion})]}),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[ghLink&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{component:"a",href:ghLink,target:"_blank",variant:"default",size:"xs",children:"Open in GitHub"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",onClick:()=>query.refetch(),children:"Refresh logs"})]}),query.isLoading&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:400}),query.isError&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{color:"red",title:"Failed to load logs",children:query.error?.message??"Unknown error"}),query.data?.jobs.map((j,i)=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,children:j.name}),j.conclusion&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"success"===j.conclusion?"green":"red",children:j.conclusion})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Code,{block:true,style:{maxHeight:400,overflow:"auto",whiteSpace:"pre"},children:j.logs||"(empty)"})]},i)),query.data&&0===query.data.jobs.length&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No jobs found."})]})})}},1226:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>FinanceJobs});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useFinanceJobsStock(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","stock"],queryFn:async()=>(await api.financeJobs.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}function useFinanceJobsTasks(filters){const api=(0,useApi.h)();const query={...filters.job_name&&{job_name:filters.job_name},...filters.owner&&{owner:filters.owner},...filters.company_slug&&{company_slug:filters.company_slug},...filters.state&&{state:filters.state},...filters.beta&&{beta:filters.beta},...void 0!==filters.take&&{take:String(filters.take)},...void 0!==filters.skip&&{skip:String(filters.skip)}};return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","tasks",filters],queryFn:async()=>(await api.financeJobs.listTasksV1(query)).data,refetchOnWindowFocus:false})}var JobLogsDrawer=__webpack_require__(620);function Tile({label,value,color}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:label}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,c:color,children:value})]})}function KpiCards({stock,isLoading,isError}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:6,children:[0,1,2,3,4,5].map(i=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:88},i))});if(isError||!stock)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",children:"Failed to load stock"})});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:6,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Pending",value:stock.pending}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Running",value:stock.running,color:"blue"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Stuck",value:stock.stuck,color:"orange"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Errored",value:stock.errored,color:"red"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Done today",value:stock.done_today,color:"green"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Oldest pending",value:stock.oldest?`${stock.oldest.ageHours}h`:"—"})]})}var esm_index_mjs_=__webpack_require__(7183);function Panel({title,data,limit=12}){const sliced=data.slice(0,limit);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:title}),0===sliced.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No data"}):/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:220,data:sliced.map(d=>({name:d.key,count:d.count})),dataKey:"name",series:[{name:"count",color:"teal.6"}],withTooltip:true})]})}function Breakdowns({byJobName,byOwner,byCompany}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:3,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By job",data:byJobName??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By owner",data:byOwner??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By company",data:byCompany??[]})]})}const STATES=["pending","running","stuck","errored","done","all"];const BETA_OPTIONS=[{value:"false",label:"Prod"},{value:"true",label:"Beta"},{value:"all",label:"All"}];function TasksFilters({jobName,owner,company,state,beta,jobNames,owners,companies,onJobName,onOwner,onCompany,onState,onBeta,onRefresh}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Job",placeholder:"All",data:jobNames,value:jobName,onChange:onJobName,searchable:true,clearable:true,w:240}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Owner",placeholder:"All",data:owners,value:owner,onChange:onOwner,searchable:true,clearable:true,w:240}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Company",placeholder:"All",data:companies,value:company,onChange:onCompany,searchable:true,clearable:true,w:220}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"State",data:STATES.map(s=>({value:s,label:s})),value:state,onChange:v=>onState(v??"pending"),w:140}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Beta",data:BETA_OPTIONS,value:beta,onChange:v=>onBeta(v??"false"),w:120}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default",onClick:onRefresh,"aria-label":"Refresh",mt:22,children:"↻"})]})}const STATE_COLORS={pending:"gray",running:"blue",stuck:"orange",errored:"red",done:"green"};const STATE_LABELS={pending:"Pending",running:"Running",stuck:"Stuck",errored:"Errored",done:"Done"};var tabler_icons_react_mjs_=__webpack_require__(9632);var notifications_esm_index_mjs_=__webpack_require__(1455);function useInvalidate(){const queryClient=(0,modern_index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","finance-jobs"]})}function useUnstickFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.unstickV1({id:String(id)})).data,onSuccess:invalidate})}function useRetryFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.retryV1({id:String(id)})).data,onSuccess:invalidate})}function useDiscardFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.discardV1({id:String(id)})).data,onSuccess:invalidate})}function useSetFinanceTaskOwner(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async({id,owner})=>(await api.financeJobs.setOwnerV1({id:String(id)},{owner})).data,onSuccess:invalidate})}function useDeleteFinanceRedisLock(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.deleteRedisLockV1({id:String(id)})).data,onSuccess:invalidate})}function notify(title,message,color){notifications_esm_index_mjs_.notifications.show({title,message,color})}function RowActions({taskId,jobName,companyLabel,currentOwner,githubJob,onShowLogs}){const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerModalOpen,setOwnerModalOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)(currentOwner??"");const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();const runUnstick=()=>unstick.mutate(taskId,{onSuccess:()=>notify("Unstuck",`Task #${taskId} reset`,"green"),onError:e=>notify("Failed",e?.message??"Unstick failed","red")});const runRetry=()=>{setConfirm(null);retry.mutate(taskId,{onSuccess:()=>notify("Retry queued",`Task #${taskId} will rerun`,"green"),onError:e=>notify("Failed",e?.message??"Retry failed","red")})};const runDiscard=()=>{setConfirm(null);discard.mutate(taskId,{onSuccess:()=>notify("Discarded",`Task #${taskId} marked done`,"green"),onError:e=>notify("Failed",e?.message??"Discard failed","red")})};const runSetOwner=()=>{setOwnerModalOpen(false);setOwner.mutate({id:taskId,owner:ownerInput},{onSuccess:()=>notify("Owner updated",`Task #${taskId} \u{2192} ${ownerInput}`,"green"),onError:e=>notify("Failed",e?.message??"Set owner failed","red")})};const runDeleteLock=()=>{setConfirm(null);deleteLock.mutate(taskId,{onSuccess:data=>notify("Redis lock",data.existed?`Deleted ${data.key}`:`No lock found (${data.key})`,"green"),onError:e=>notify("Failed",e?.message??"Redis delete failed","red")})};return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[githubJob&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Voir les logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",onClick:()=>onShowLogs(githubJob),"aria-label":"Voir les logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTerminal,{size:16})})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu,{position:"bottom-end",withArrow:true,shadow:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Target,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default","aria-label":"Actions",children:"⋮"})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu.Dropdown,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>setConfirm("retry"),children:"Retry"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>{setOwnerInput(currentOwner??"");setOwnerModalOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{color:"red",onClick:()=>setConfirm("discard"),children:"Discard"})]})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"retry"===confirm,onClose:()=>setConfirm(null),title:"Retry task",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Reset task #",taskId," (",jobName," — ",companyLabel,") so the runner picks it up again. This clears ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"finished"}),","," ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"startedAt"}),", ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"error"})," and the Redis lock."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:runRetry,loading:retry.isPending,children:"Retry"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:"Discard task",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Mark task #",taskId," (",jobName," — ",companyLabel,") as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"finished"})," ","with error=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". The runner will skip it."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",onClick:runDiscard,loading:discard.isPending,children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:"Delete Redis lock",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Delete ",/*#__PURE__*/(0,jsx_runtime.jsxs)("code",{children:["fm-task-node-",taskId]}),". The runner will be able to pick this task up again on the next iteration."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,loading:deleteLock.isPending,children:"Delete lock"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerModalOpen,onClose:()=>setOwnerModalOpen(false),title:`Set owner for task #${taskId}`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Owner email",value:ownerInput,onChange:e=>setOwnerInput(e.currentTarget.value),placeholder:"bob@airporting.com"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setOwnerModalOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:runSetOwner,loading:setOwner.isPending,disabled:!ownerInput.trim(),children:"Save"})]})]})})]})}function fmt(d){return d?new Date(d).toLocaleString("fr-FR"):"—"}function fmtDuration(ms){if(null==ms)return"—";if(ms<1e3)return`${ms}ms`;const s=Math.floor(ms/1e3);if(s<60)return`${s}s`;const m=Math.floor(s/60);const rem=s%60;return`${m}m${rem}s`}function TasksTable({items,total,isLoading,onShowLogs,selectedIds,onToggleId,onToggleAll}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:300});if(!items||0===items.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No tasks for current filters."});const visibleIds=items.map(i=>i.id);const allSelected=visibleIds.every(id=>selectedIds.has(id));const someSelected=!allSelected&&visibleIds.some(id=>selectedIds.has(id));return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.ScrollArea,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",mb:"xs",children:[total," task(s)"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{miw:1300,verticalSpacing:"xs",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,{w:40,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:allSelected,indeterminate:someSelected,onChange:e=>onToggleAll(visibleIds,e.currentTarget.checked),"aria-label":"Select all"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Job"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Company"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Owner"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"State"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Created"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Started"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Duration"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Result / Error"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Actions"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:items.map(t=>{const companyLabel=t.company_display_name??t.company_slug??`#${t.company_id}`;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{bg:selectedIds.has(t.id)?"var(--mantine-color-dark-6)":void 0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:selectedIds.has(t.id),onChange:()=>onToggleId(t.id),"aria-label":`Select task ${t.id}`})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:t.id}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.job_name}),t.beta&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"violet",variant:"light",children:"beta"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:companyLabel})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.owner})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.created)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.startedAt)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmtDuration(t.runDuration)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{style:{maxWidth:320},children:t.error?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:t.error,multiline:true,w:420,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Code,{c:"red",style:{display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.error})}):null!=t.trace_count?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:[t.trace_count," ",t.trace_label??""]}):"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:t.id,jobName:t.job_name,companyLabel:companyLabel,currentOwner:t.owner,githubJob:t.github_job,onShowLogs:onShowLogs})})]},t.id)})})]})]})}function BulkActionBar_notify(title,message,color){notifications_esm_index_mjs_.notifications.show({title,message,color})}async function runBulk(ids,fn){const results=await Promise.allSettled(ids.map(fn));const ok=results.filter(r=>"fulfilled"===r.status).length;return{ok,failed:results.length-ok}}function BulkActionBar({selectedIds,onClear}){const count=selectedIds.length;const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerOpen,setOwnerOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)("");const[pending,setPending]=(0,index_js_.useState)(false);const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();const finalize=(label,res)=>{setPending(false);onClear();BulkActionBar_notify(label,`${res.ok} succeeded${res.failed?`, ${res.failed} failed`:""}`,res.failed?"red":"green")};const runUnstick=async()=>{setPending(true);const res=await runBulk(selectedIds,id=>unstick.mutateAsync(id));finalize("Bulk unstick",res)};const runRetry=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>retry.mutateAsync(id));finalize("Bulk retry",res)};const runDiscard=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>discard.mutateAsync(id));finalize("Bulk discard",res)};const runDeleteLock=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>deleteLock.mutateAsync(id));finalize("Bulk Redis lock delete",res)};const runSetOwner=async()=>{setOwnerOpen(false);const owner=ownerInput.trim();if(!owner)return;setPending(true);const res=await runBulk(selectedIds,id=>setOwner.mutateAsync({id,owner}));finalize(`Bulk set owner \u{2192} ${owner}`,res)};if(0===count)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{p:"sm",radius:"md",withBorder:true,style:{position:"sticky",bottom:16,zIndex:5,backgroundColor:"var(--mantine-color-dark-7)"},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",fw:600,children:[count," selected"]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"subtle",onClick:onClear,children:"Clear"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:()=>setConfirm("retry"),children:"Retry"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:()=>{setOwnerInput("");setOwnerOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",color:"orange",loading:pending,onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",color:"red",loading:pending,onClick:()=>setConfirm("discard"),children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"retry"===confirm,onClose:()=>setConfirm(null),title:`Retry ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Reset ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s) so the runner picks them up again."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{onClick:runRetry,children:["Retry ",count]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:`Discard ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Mark ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s) as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"finished"})," with error=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". They will not be processed."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{color:"red",onClick:runDiscard,children:["Discard ",count]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:`Delete Redis lock for ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Delete ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"fm-task-node-<id>"})," for ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," ","task(s)."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,children:["Delete ",count," lock(s)"]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerOpen,onClose:()=>setOwnerOpen(false),title:`Set owner for ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Owner email",value:ownerInput,onChange:e=>setOwnerInput(e.currentTarget.value),placeholder:"bob@airporting.com"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setOwnerOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{onClick:runSetOwner,disabled:!ownerInput.trim(),children:["Apply to ",count]})]})]})})]})}function FinanceJobsApp(){const stock=useFinanceJobsStock();const[jobName,setJobName]=(0,index_js_.useState)(null);const[owner,setOwner]=(0,index_js_.useState)(null);const[company,setCompany]=(0,index_js_.useState)(null);const[state,setState]=(0,index_js_.useState)("pending");const[beta,setBeta]=(0,index_js_.useState)("false");const tasks=useFinanceJobsTasks({job_name:jobName??void 0,owner:owner??void 0,company_slug:company??void 0,state,beta,take:50});const[openJob,setOpenJob]=(0,index_js_.useState)(null);const[selectedIds,setSelectedIds]=(0,index_js_.useState)(new Set);const toggleId=(0,index_js_.useCallback)(id=>{setSelectedIds(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next})},[]);const toggleAll=(0,index_js_.useCallback)((ids,select)=>{setSelectedIds(prev=>{const next=new Set(prev);for(const id of ids)if(select)next.add(id);else next.delete(id);return next})},[]);const clearSelection=(0,index_js_.useCallback)(()=>setSelectedIds(new Set),[]);const jobNames=(0,index_js_.useMemo)(()=>(stock.data?.byJobName??[]).map(e=>e.key),[stock.data]);const owners=(0,index_js_.useMemo)(()=>(stock.data?.byOwner??[]).map(e=>e.key),[stock.data]);const companies=(0,index_js_.useMemo)(()=>(stock.data?.byCompany??[]).map(e=>e.key),[stock.data]);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Finance Jobs Tasks"}),stock.dataUpdatedAt&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{c:"dimmed",size:"xs",children:["Updated"," ",new Date(stock.dataUpdatedAt).toLocaleTimeString("fr-FR")]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",size:"sm",loading:stock.isFetching||tasks.isFetching,onClick:()=>{stock.refetch();tasks.refetch()},children:"↻ Refresh"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(KpiCards,{stock:stock.data,isLoading:stock.isLoading,isError:stock.isError}),/*#__PURE__*/(0,jsx_runtime.jsx)(Breakdowns,{byJobName:stock.data?.byJobName,byOwner:stock.data?.byOwner,byCompany:stock.data?.byCompany}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksFilters,{jobName:jobName,owner:owner,company:company,state:state,beta:beta,jobNames:jobNames,owners:owners,companies:companies,onJobName:setJobName,onOwner:setOwner,onCompany:setCompany,onState:setState,onBeta:setBeta,onRefresh:()=>tasks.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksTable,{items:tasks.data?.items,total:tasks.data?.total??0,isLoading:tasks.isLoading,onShowLogs:setOpenJob,selectedIds:selectedIds,onToggleId:toggleId,onToggleAll:toggleAll}),/*#__PURE__*/(0,jsx_runtime.jsx)(BulkActionBar,{selectedIds:[...selectedIds],onClear:clearSelection}),/*#__PURE__*/(0,jsx_runtime.jsx)(JobLogsDrawer.o,{githubJob:openJob,opened:!!openJob,onClose:()=>setOpenJob(null)})]})})}function FinanceJobs(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(FinanceJobsApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["7825"],{620:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{o:()=>JobLogsDrawer});var jsx_runtime=__webpack_require__(5893);var index_mjs_=__webpack_require__(207);var index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useJobLogs(githubJob){const api=(0,useApi.h)();return(0,index_js_.useQuery)({queryKey:["tech","github","job-logs",githubJob],queryFn:async()=>(await api.github.getJobLogsV1({githubJob:githubJob})).data,enabled:!!githubJob,refetchOnWindowFocus:false,retry:false})}function fallbackUrl(githubJob){const parts=githubJob.split("/");if(parts.length<3)return null;const runId=parts[parts.length-1];const repo=parts[parts.length-2];const owner=parts.slice(0,-2).join("/");return`https://github.com/${owner}/${repo}/actions/runs/${runId}`}function JobLogsDrawer({githubJob,opened,onClose}){const query=useJobLogs(opened?githubJob:null);const ghLink=githubJob?fallbackUrl(githubJob):null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Drawer,{opened:opened,onClose:onClose,position:"right",size:"60%",title:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,children:"Workflow logs"}),query.data?.conclusion&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"success"===query.data.conclusion?"green":"red",children:query.data.conclusion})]}),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[ghLink&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{component:"a",href:ghLink,target:"_blank",variant:"default",size:"xs",children:"Open in GitHub"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",onClick:()=>query.refetch(),children:"Refresh logs"})]}),query.isLoading&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:400}),query.isError&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Alert,{color:"red",title:"Failed to load logs",children:query.error?.message??"Unknown error"}),query.data?.jobs.map((j,i)=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,children:j.name}),j.conclusion&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"success"===j.conclusion?"green":"red",children:j.conclusion})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Code,{block:true,style:{maxHeight:400,overflow:"auto",whiteSpace:"pre"},children:j.logs||"(empty)"})]},i)),query.data&&0===query.data.jobs.length&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No jobs found."})]})})}},7208:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>FinanceJobs});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useFinanceJobsStock(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","stock"],queryFn:async()=>(await api.financeJobs.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}function useFinanceJobsTasks(filters){const api=(0,useApi.h)();const query={...filters.job_name&&{job_name:filters.job_name},...filters.owner&&{owner:filters.owner},...filters.company_slug&&{company_slug:filters.company_slug},...filters.state&&{state:filters.state},...filters.beta&&{beta:filters.beta},...void 0!==filters.take&&{take:String(filters.take)},...void 0!==filters.skip&&{skip:String(filters.skip)}};return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","tasks",filters],queryFn:async()=>(await api.financeJobs.listTasksV1(query)).data,refetchOnWindowFocus:false})}var JobLogsDrawer=__webpack_require__(620);function Tile({label,value,color}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:label}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,c:color,children:value})]})}function KpiCards({stock,isLoading,isError}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:6,children:[0,1,2,3,4,5].map(i=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:88},i))});if(isError||!stock)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"red",children:"Failed to load stock"})});return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:6,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Pending",value:stock.pending}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Running",value:stock.running,color:"blue"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Stuck",value:stock.stuck,color:"orange"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Errored",value:stock.errored,color:"red"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Done today",value:stock.done_today,color:"green"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Tile,{label:"Oldest pending",value:stock.oldest?`${stock.oldest.ageHours}h`:"—"})]})}var esm_index_mjs_=__webpack_require__(7183);function Panel({title,data,limit=12}){const sliced=data.slice(0,limit);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{padding:"md",radius:"md",withBorder:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,mb:"sm",children:title}),0===sliced.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No data"}):/*#__PURE__*/(0,jsx_runtime.jsx)(esm_index_mjs_.BarChart,{h:220,data:sliced.map(d=>({name:d.key,count:d.count})),dataKey:"name",series:[{name:"count",color:"teal.6"}],withTooltip:true})]})}function Breakdowns({byJobName,byOwner,byCompany}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:3,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By job",data:byJobName??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By owner",data:byOwner??[]}),/*#__PURE__*/(0,jsx_runtime.jsx)(Panel,{title:"By company",data:byCompany??[]})]})}const STATES=["pending","running","stuck","errored","done","all"];const BETA_OPTIONS=[{value:"false",label:"Prod"},{value:"true",label:"Beta"},{value:"all",label:"All"}];function TasksFilters({jobName,owner,company,state,beta,jobNames,owners,companies,onJobName,onOwner,onCompany,onState,onBeta,onRefresh}){return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Job",placeholder:"All",data:jobNames,value:jobName,onChange:onJobName,searchable:true,clearable:true,w:240}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Owner",placeholder:"All",data:owners,value:owner,onChange:onOwner,searchable:true,clearable:true,w:240}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Company",placeholder:"All",data:companies,value:company,onChange:onCompany,searchable:true,clearable:true,w:220}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"State",data:STATES.map(s=>({value:s,label:s})),value:state,onChange:v=>onState(v??"pending"),w:140}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Beta",data:BETA_OPTIONS,value:beta,onChange:v=>onBeta(v??"false"),w:120}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default",onClick:onRefresh,"aria-label":"Refresh",mt:22,children:"↻"})]})}const STATE_COLORS={pending:"gray",running:"blue",stuck:"orange",errored:"red",done:"green"};const STATE_LABELS={pending:"Pending",running:"Running",stuck:"Stuck",errored:"Errored",done:"Done"};var tabler_icons_react_mjs_=__webpack_require__(9632);var notifications_esm_index_mjs_=__webpack_require__(1455);function useInvalidate(){const queryClient=(0,modern_index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","finance-jobs"]})}function useUnstickFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.unstickV1({id:String(id)})).data,onSuccess:invalidate})}function useRetryFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.retryV1({id:String(id)})).data,onSuccess:invalidate})}function useDiscardFinanceTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.discardV1({id:String(id)})).data,onSuccess:invalidate})}function useSetFinanceTaskOwner(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async({id,owner})=>(await api.financeJobs.setOwnerV1({id:String(id)},{owner})).data,onSuccess:invalidate})}function useDeleteFinanceRedisLock(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.financeJobs.deleteRedisLockV1({id:String(id)})).data,onSuccess:invalidate})}function notify(title,message,color){notifications_esm_index_mjs_.notifications.show({title,message,color})}function RowActions({taskId,jobName,companyLabel,currentOwner,githubJob,onShowLogs}){const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerModalOpen,setOwnerModalOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)(currentOwner??"");const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();const runUnstick=()=>unstick.mutate(taskId,{onSuccess:()=>notify("Unstuck",`Task #${taskId} reset`,"green"),onError:e=>notify("Failed",e?.message??"Unstick failed","red")});const runRetry=()=>{setConfirm(null);retry.mutate(taskId,{onSuccess:()=>notify("Retry queued",`Task #${taskId} will rerun`,"green"),onError:e=>notify("Failed",e?.message??"Retry failed","red")})};const runDiscard=()=>{setConfirm(null);discard.mutate(taskId,{onSuccess:()=>notify("Discarded",`Task #${taskId} marked done`,"green"),onError:e=>notify("Failed",e?.message??"Discard failed","red")})};const runSetOwner=()=>{setOwnerModalOpen(false);setOwner.mutate({id:taskId,owner:ownerInput},{onSuccess:()=>notify("Owner updated",`Task #${taskId} \u{2192} ${ownerInput}`,"green"),onError:e=>notify("Failed",e?.message??"Set owner failed","red")})};const runDeleteLock=()=>{setConfirm(null);deleteLock.mutate(taskId,{onSuccess:data=>notify("Redis lock",data.existed?`Deleted ${data.key}`:`No lock found (${data.key})`,"green"),onError:e=>notify("Failed",e?.message??"Redis delete failed","red")})};return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[githubJob&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Voir les logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",onClick:()=>onShowLogs(githubJob),"aria-label":"Voir les logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTerminal,{size:16})})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu,{position:"bottom-end",withArrow:true,shadow:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Target,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"default","aria-label":"Actions",children:"⋮"})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Menu.Dropdown,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>setConfirm("retry"),children:"Retry"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>{setOwnerInput(currentOwner??"");setOwnerModalOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Menu.Item,{color:"red",onClick:()=>setConfirm("discard"),children:"Discard"})]})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"retry"===confirm,onClose:()=>setConfirm(null),title:"Retry task",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Reset task #",taskId," (",jobName," — ",companyLabel,") so the runner picks it up again. This clears ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"finished"}),","," ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"startedAt"}),", ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"error"})," and the Redis lock."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:runRetry,loading:retry.isPending,children:"Retry"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:"Discard task",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Mark task #",taskId," (",jobName," — ",companyLabel,") as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"finished"})," ","with error=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". The runner will skip it."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",onClick:runDiscard,loading:discard.isPending,children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:"Delete Redis lock",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:["Delete ",/*#__PURE__*/(0,jsx_runtime.jsxs)("code",{children:["fm-task-node-",taskId]}),". The runner will be able to pick this task up again on the next iteration."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,loading:deleteLock.isPending,children:"Delete lock"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerModalOpen,onClose:()=>setOwnerModalOpen(false),title:`Set owner for task #${taskId}`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Owner email",value:ownerInput,onChange:e=>setOwnerInput(e.currentTarget.value),placeholder:"bob@airporting.com"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setOwnerModalOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:runSetOwner,loading:setOwner.isPending,disabled:!ownerInput.trim(),children:"Save"})]})]})})]})}function fmt(d){return d?new Date(d).toLocaleString("fr-FR"):"—"}function fmtDuration(ms){if(null==ms)return"—";if(ms<1e3)return`${ms}ms`;const s=Math.floor(ms/1e3);if(s<60)return`${s}s`;const m=Math.floor(s/60);const rem=s%60;return`${m}m${rem}s`}function TasksTable({items,total,isLoading,onShowLogs,selectedIds,onToggleId,onToggleAll}){if(isLoading)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:300});if(!items||0===items.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"No tasks for current filters."});const visibleIds=items.map(i=>i.id);const allSelected=visibleIds.every(id=>selectedIds.has(id));const someSelected=!allSelected&&visibleIds.some(id=>selectedIds.has(id));return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.ScrollArea,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"xs",c:"dimmed",mb:"xs",children:[total," task(s)"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{miw:1300,verticalSpacing:"xs",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,{w:40,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:allSelected,indeterminate:someSelected,onChange:e=>onToggleAll(visibleIds,e.currentTarget.checked),"aria-label":"Select all"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"#"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Job"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Company"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Owner"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"State"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Created"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Started"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Duration"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Result / Error"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Actions"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:items.map(t=>{const companyLabel=t.company_display_name??t.company_slug??`#${t.company_id}`;return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{bg:selectedIds.has(t.id)?"var(--mantine-color-dark-6)":void 0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{checked:selectedIds.has(t.id),onChange:()=>onToggleId(t.id),"aria-label":`Select task ${t.id}`})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:t.id}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.job_name}),t.beta&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",color:"violet",variant:"light",children:"beta"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:companyLabel})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.owner})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.created)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmt(t.startedAt)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:fmtDuration(t.runDuration)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{style:{maxWidth:320},children:t.error?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:t.error,multiline:true,w:420,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Code,{c:"red",style:{display:"block",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.error})}):null!=t.trace_count?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",c:"dimmed",children:[t.trace_count," ",t.trace_label??""]}):"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:t.id,jobName:t.job_name,companyLabel:companyLabel,currentOwner:t.owner,githubJob:t.github_job,onShowLogs:onShowLogs})})]},t.id)})})]})]})}function BulkActionBar_notify(title,message,color){notifications_esm_index_mjs_.notifications.show({title,message,color})}async function runBulk(ids,fn){const results=await Promise.allSettled(ids.map(fn));const ok=results.filter(r=>"fulfilled"===r.status).length;return{ok,failed:results.length-ok}}function BulkActionBar({selectedIds,onClear}){const count=selectedIds.length;const[confirm,setConfirm]=(0,index_js_.useState)(null);const[ownerOpen,setOwnerOpen]=(0,index_js_.useState)(false);const[ownerInput,setOwnerInput]=(0,index_js_.useState)("");const[pending,setPending]=(0,index_js_.useState)(false);const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();const finalize=(label,res)=>{setPending(false);onClear();BulkActionBar_notify(label,`${res.ok} succeeded${res.failed?`, ${res.failed} failed`:""}`,res.failed?"red":"green")};const runUnstick=async()=>{setPending(true);const res=await runBulk(selectedIds,id=>unstick.mutateAsync(id));finalize("Bulk unstick",res)};const runRetry=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>retry.mutateAsync(id));finalize("Bulk retry",res)};const runDiscard=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>discard.mutateAsync(id));finalize("Bulk discard",res)};const runDeleteLock=async()=>{setConfirm(null);setPending(true);const res=await runBulk(selectedIds,id=>deleteLock.mutateAsync(id));finalize("Bulk Redis lock delete",res)};const runSetOwner=async()=>{setOwnerOpen(false);const owner=ownerInput.trim();if(!owner)return;setPending(true);const res=await runBulk(selectedIds,id=>setOwner.mutateAsync({id,owner}));finalize(`Bulk set owner \u{2192} ${owner}`,res)};if(0===count)return null;return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{p:"sm",radius:"md",withBorder:true,style:{position:"sticky",bottom:16,zIndex:5,backgroundColor:"var(--mantine-color-dark-7)"},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",fw:600,children:[count," selected"]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"subtle",onClick:onClear,children:"Clear"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:runUnstick,children:"Unstick"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:()=>setConfirm("retry"),children:"Retry"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",loading:pending,onClick:()=>{setOwnerInput("");setOwnerOpen(true)},children:"Set owner…"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",variant:"default",color:"orange",loading:pending,onClick:()=>setConfirm("redis"),children:"Delete Redis lock"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"xs",color:"red",loading:pending,onClick:()=>setConfirm("discard"),children:"Discard"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"retry"===confirm,onClose:()=>setConfirm(null),title:`Retry ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Reset ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s) so the runner picks them up again."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{onClick:runRetry,children:["Retry ",count]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"discard"===confirm,onClose:()=>setConfirm(null),title:`Discard ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Mark ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," task(s) as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"finished"})," with error=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". They will not be processed."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{color:"red",onClick:runDiscard,children:["Discard ",count]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:"redis"===confirm,onClose:()=>setConfirm(null),title:`Delete Redis lock for ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",children:["Delete ",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"fm-task-node-<id>"})," for ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:count})," ","task(s)."]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setConfirm(null),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{color:"orange",onClick:runDeleteLock,children:["Delete ",count," lock(s)"]})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:ownerOpen,onClose:()=>setOwnerOpen(false),title:`Set owner for ${count} task(s)`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Owner email",value:ownerInput,onChange:e=>setOwnerInput(e.currentTarget.value),placeholder:"bob@airporting.com"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:()=>setOwnerOpen(false),children:"Cancel"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Button,{onClick:runSetOwner,disabled:!ownerInput.trim(),children:["Apply to ",count]})]})]})})]})}function useFinanceRunners(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","finance-jobs","runners"],queryFn:async()=>(await api.financeJobs.getRunnersV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}function RunnerBadge(){const runners=useFinanceRunners();if(runners.isError)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"gray",variant:"light",children:"runners —"});if(!runners.data)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:"gray",variant:"light",children:"runners …"});const inProgress=runners.data.inProgress??0;const queued=runners.data.queued??0;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:`${inProgress} run(s) en cours \xb7 ${queued} en file`,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Badge,{color:inProgress>0?"green":"gray",variant:inProgress>0?"filled":"light",children:["▶ ",inProgress," en cours",queued>0?` \xb7 ${queued} en file`:""]})})}function useRunRecipe(){const api=(0,useApi.h)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async count=>(await api.financeJobs.runRecipeV1({count})).data,onSuccess:data=>{notifications_esm_index_mjs_.notifications.show({title:"Run recipe",message:data?.message??`${data?.dispatched??0} run(s) lanc\xe9(s)`,color:"green"});queryClient.invalidateQueries({queryKey:["tech","finance-jobs","runners"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Run recipe",message:err?.error?.error??err?.message??"\xc9chec du dispatch",color:"red"})}})}function RunRecipeButton(){const[count,setCount]=(0,index_js_.useState)(1);const run=useRunRecipe();return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.NumberInput,{size:"sm",w:70,min:1,max:3,value:count,onChange:v=>setCount("number"==typeof v?v:1),clampBehavior:"strict"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{size:"sm",color:"green",loading:run.isPending,onClick:()=>run.mutate(count),children:"▶ Run recipe"})]})}function FinanceJobsApp(){const stock=useFinanceJobsStock();const[jobName,setJobName]=(0,index_js_.useState)(null);const[owner,setOwner]=(0,index_js_.useState)(null);const[company,setCompany]=(0,index_js_.useState)(null);const[state,setState]=(0,index_js_.useState)("pending");const[beta,setBeta]=(0,index_js_.useState)("false");const tasks=useFinanceJobsTasks({job_name:jobName??void 0,owner:owner??void 0,company_slug:company??void 0,state,beta,take:50});const[openJob,setOpenJob]=(0,index_js_.useState)(null);const[selectedIds,setSelectedIds]=(0,index_js_.useState)(new Set);const toggleId=(0,index_js_.useCallback)(id=>{setSelectedIds(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next})},[]);const toggleAll=(0,index_js_.useCallback)((ids,select)=>{setSelectedIds(prev=>{const next=new Set(prev);for(const id of ids)if(select)next.add(id);else next.delete(id);return next})},[]);const clearSelection=(0,index_js_.useCallback)(()=>setSelectedIds(new Set),[]);const jobNames=(0,index_js_.useMemo)(()=>(stock.data?.byJobName??[]).map(e=>e.key),[stock.data]);const owners=(0,index_js_.useMemo)(()=>(stock.data?.byOwner??[]).map(e=>e.key),[stock.data]);const companies=(0,index_js_.useMemo)(()=>(stock.data?.byCompany??[]).map(e=>e.key),[stock.data]);return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Finance Jobs Tasks"}),/*#__PURE__*/(0,jsx_runtime.jsx)(RunnerBadge,{}),stock.dataUpdatedAt&&/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{c:"dimmed",size:"xs",children:["Updated"," ",new Date(stock.dataUpdatedAt).toLocaleTimeString("fr-FR")]})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(RunRecipeButton,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",size:"sm",loading:stock.isFetching||tasks.isFetching,onClick:()=>{stock.refetch();tasks.refetch()},children:"↻ Refresh"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(KpiCards,{stock:stock.data,isLoading:stock.isLoading,isError:stock.isError}),/*#__PURE__*/(0,jsx_runtime.jsx)(Breakdowns,{byJobName:stock.data?.byJobName,byOwner:stock.data?.byOwner,byCompany:stock.data?.byCompany}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksFilters,{jobName:jobName,owner:owner,company:company,state:state,beta:beta,jobNames:jobNames,owners:owners,companies:companies,onJobName:setJobName,onOwner:setOwner,onCompany:setCompany,onState:setState,onBeta:setBeta,onRefresh:()=>tasks.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsx)(TasksTable,{items:tasks.data?.items,total:tasks.data?.total??0,isLoading:tasks.isLoading,onShowLogs:setOpenJob,selectedIds:selectedIds,onToggleId:toggleId,onToggleAll:toggleAll}),/*#__PURE__*/(0,jsx_runtime.jsx)(BulkActionBar,{selectedIds:[...selectedIds],onClear:clearSelection}),/*#__PURE__*/(0,jsx_runtime.jsx)(JobLogsDrawer.o,{githubJob:openJob,opened:!!openJob,onClose:()=>setOpenJob(null)})]})})}function FinanceJobs(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(FinanceJobsApp,{})})})}}}]);