@airporting/tech-app 0.0.63 → 0.0.65

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.
@@ -1 +1 @@
1
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["9777"],{2268:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{g:()=>useFinanceJobsStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useFinanceJobsStock(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","finance-jobs","stock"],queryFn:async()=>(await api.financeJobs.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},3139:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{V:()=>useGithubQuery});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useGithubQuery(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();const query=(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","github"],queryFn:async()=>await api.github.getJobsRunnersV1().then(x=>x.data),refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true});return query}},466:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>useGsheetStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useGsheetStock(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","gsheet","stock"],queryFn:async()=>(await api.gsheet.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},3897:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{O:()=>BrandLogo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(243);function BrandLogo({domain,alt,size=24}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Image,{src:(0,_src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__.j)(domain),alt:alt,title:alt,w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}},1354:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{m:()=>PageHeader});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(9632);var react__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3106);function formatRelative(now,then){const seconds=Math.max(0,Math.floor((now-then)/1e3));if(seconds<5)return"\xe0 l’instant";if(seconds<60)return`il y a ${seconds}s`;const minutes=Math.floor(seconds/60);if(minutes<60)return`il y a ${minutes} min`;const hours=Math.floor(minutes/60);return`il y a ${hours} h`}function PageHeader({title,leading,badge,updatedAt,isFetching,isError,onRefresh,actions}){const[now,setNow]=(0,react__WEBPACK_IMPORTED_MODULE_3__.useState)(()=>Date.now());(0,react__WEBPACK_IMPORTED_MODULE_3__.useEffect)(()=>{if(!updatedAt)return;const id=window.setInterval(()=>setNow(Date.now()),1e3);return()=>window.clearInterval(id)},[updatedAt]);const relative=updatedAt?formatRelative(now,updatedAt):null;const color=isError?"orange":isFetching?"teal":"dimmed";return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{justify:"space-between",align:"center",mih:48,mb:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[leading,/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Title,{order:2,children:title}),badge]}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[relative&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Text,{size:"xs",c:color,fw:isFetching?600:400,"data-testid":"page-header-freshness",children:isError?"\xe9chec maj":isFetching?"maj…":relative}),onRefresh&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Tooltip,{label:"Rafra\xeechir",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.ActionIcon,{variant:"default",size:"md",onClick:onRefresh,loading:isFetching,"aria-label":"Refresh",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__.IconRefresh,{size:16})})}),actions]})]})}},5068:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>IconGithub});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);function IconGithub({color="currentColor",size=20,marker,...props}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("svg",{width:size,height:size,viewBox:"0 0 24 24",fill:color,xmlns:"http://www.w3.org/2000/svg",...props,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("path",{d:"M12 0.297C5.373 0.297 0 5.67 0 12.297c0 5.292 3.438 9.787 8.205 11.387.6.111.82-.261.82-.58 0-.287-.011-1.244-.016-2.255-3.338.726-4.042-1.609-4.042-1.609-.546-1.389-1.333-1.759-1.333-1.759-1.089-.745.083-.73.083-.73 1.205.085 1.84 1.236 1.84 1.236 1.07 1.834 2.807 1.304 3.492.997.107-.775.419-1.305.762-1.605-2.665-.304-5.466-1.332-5.466-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.536-1.524.116-3.176 0 0 1.008-.322 3.301 1.23a11.51 11.51 0 0 1 3.004-.404 c1.019.005 2.047.138 3.004.404 2.291-1.552 3.297-1.23 3.297-1.23.655 1.652.243 2.873.119 3.176.77.84 1.235 1.91 1.235 3.221 0 4.61-2.805 5.624-5.476 5.921.43.372.823 1.104.823 2.223 0 1.606-.015 2.896-.015 3.293 0 .321.216.697.825.578C20.565 22.08 24 17.585 24 12.297 24 5.67 18.627.297 12 .297z"})})}},243:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{j:()=>logoDevUrl});const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}},4551:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Dashboard});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useDashboardQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","dashboard"],queryFn:async()=>await api.getDashboard().then(x=>x.data),refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true});return query}var IconGithub=__webpack_require__(5068);function IconBraintree({color="currentColor",size=20,...props}){return/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:size,height:size,viewBox:"0 0 24 24",fill:color,xmlns:"http://www.w3.org/2000/svg",...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M8.276 20.482h4.717c3.641 0 5.462-1.2 5.462-3.517 0-2.275-1.945-3.517-5.752-3.517H8.276Zm0-16.965v6.538h4.138c3.103 0 4.717-1.159 4.717-3.269 0-2.152-1.655-3.269-4.759-3.269zM1.696 24v-3.518H4.47V3.517H1.697V0h11.089c5.09 0 8.193 2.358 8.193 6.455 0 2.69-1.572 4.345-3.558 5.131 2.855.787 4.882 2.814 4.882 5.586 0 4.386-3.393 6.828-8.938 6.828H1.697"})})}function IconHealthCross({color="#2CA01C",size=20,...props}){return/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:size,height:size,viewBox:"0 0 24 24",fill:color,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Sant\xe9",...props,children:[/*#__PURE__*/(0,jsx_runtime.jsx)("title",{children:"Sant\xe9"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M9 2h6a1 1 0 0 1 1 1v5h5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-5v5a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1v-5H3a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h5V3a1 1 0 0 1 1-1Z"})]})}var dist_index_js_=__webpack_require__(1380);var PageHeader=__webpack_require__(1354);var BrandLogo=__webpack_require__(3897);var financeJobsStockQuery=__webpack_require__(2268);var gsheetStockQuery=__webpack_require__(466);var githubQuery=__webpack_require__(3139);function toneColor(tone){if("bad"===tone)return"red";if("warn"===tone)return"orange";return"green"}function toneLabel(tone){if("bad"===tone)return"ALERT";if("warn"===tone)return"WARN";return"OK"}function SystemHealthStrip(){const finance=(0,financeJobsStockQuery.g)();const gsheet=(0,gsheetStockQuery.U)();const github=(0,githubQuery.V)();const loading=finance.isLoading||gsheet.isLoading||github.isLoading;if(loading)return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:3,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:80}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:80}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:80})]});const tiles=[];if(finance.data){const d=finance.data;const errored=d.errored??0;const stuck=d.stuck??0;tiles.push({key:"finance",title:"Finance jobs",detail:`${d.pending??0} pending \xb7 ${errored} errored`,tone:errored>0?"bad":stuck>0?"warn":"ok"})}if(gsheet.data){const d=gsheet.data;const errored=d.errored??0;const stuck=d.stuck??0;tiles.push({key:"gsheet",title:"Worksheet",detail:`${d.pending??0} pending \xb7 ${errored} errored`,tone:errored>0?"bad":stuck>0?"warn":"ok"})}if(github.data){const list=github.data.list??[];const repos=list.length;tiles.push({key:"runners",title:"Runners GitHub",detail:`${repos} repos surveill\xe9s`,tone:0===repos?"bad":"ok"})}if(0===tiles.length)return null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:Math.min(tiles.length,3),children:tiles.map(t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,children:t.title}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:toneColor(t.tone),variant:"light",children:toneLabel(t.tone)})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",mt:4,children:t.detail})]},t.key))})}function App(){const dashboardResult=useDashboardQuery();const dashboard=dashboardResult.data;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(PageHeader.m,{title:"Sant\xe9",leading:/*#__PURE__*/(0,jsx_runtime.jsx)(IconHealthCross,{size:26}),updatedAt:dashboardResult.dataUpdatedAt,isFetching:dashboardResult.isFetching,isError:dashboardResult.isError,onRefresh:()=>dashboardResult.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,mb:"sm",children:"Sant\xe9 Syst\xe8me"}),/*#__PURE__*/(0,jsx_runtime.jsx)(SystemHealthStrip,{})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,mb:"sm",children:"Int\xe9grations Produit"}),dashboard?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",children:[dashboard.amex.purchaseProblem?/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.IconCross,{size:20,color:"red"}):/*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:"americanexpress.com",alt:"American Express"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:"Amex Purchase"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,c:dashboard.amex.purchaseProblem?"red":"green",children:[dashboard.amex.purchaseTodayBalances," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{children:"cash balances"}),/*#__PURE__*/(0,jsx_runtime.jsx)("br",{}),dashboard.amex.purchasePendingTransactions,"/",dashboard.amex.purchaseTodayTransactions," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{children:"transactions en attente"})]})},"amex_purchase")})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",children:[dashboard.amex.merchantProblem?/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.IconCross,{size:20,color:"red"}):/*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{}),/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:"americanexpress.com",alt:"American Express"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:"Amex Merchant"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,c:dashboard.amex.merchantProblem?"red":"green",children:[dashboard.amex.merchantPendingTransactions,"/",dashboard.amex.merchantTodayTransactions," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{children:"transactions en attente"}),/*#__PURE__*/(0,jsx_runtime.jsx)("br",{}),dashboard.amex.merchantPendingChargebacks,"/",dashboard.amex.merchantTodayChargesbacks," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{children:"remboursements en attente"}),/*#__PURE__*/(0,jsx_runtime.jsx)("br",{}),dashboard.amex.merchantPendingAdjustments,"/",dashboard.amex.merchantTodayAdjustments," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{children:"ajustements en attente"}),/*#__PURE__*/(0,jsx_runtime.jsx)("br",{})]})},"amex_merchant")})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:3,ml:dashboard.gsheet.globalProblem?-30:0,children:[dashboard.gsheet.globalProblem?/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.IconCross,{size:24,color:"red"}):/*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{}),"Worksheet"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Grid,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"apart",children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"T\xe2ches non termin\xe9es"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,c:dashboard.gsheet.pending>50?"red":dashboard.gsheet.pending>30?"orange":"green",children:[dashboard.gsheet.pending," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,children:"onglets"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:700,fz:"sm",mt:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{span:true,c:"dimmed",children:["Le plus ancien date du :"," "]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,fw:"bold",c:dashboard.gsheet.isPendingTooOld?"red":"green",children:dashboard.gsheet.oldest})]})]},"gsheet_pending")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"apart",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"T\xe2ches en cours"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,children:[dashboard.gsheet.running," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,children:"onglets"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:"https://github.com/airporting/gsheet_runner/actions",children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconGithub.U,{size:20})})]})},"gsheet_running")})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:"payfit.com",alt:"Payfit"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:"Payfit"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Grid,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"apart",children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"Exports du jour"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,children:[dashboard.payfit.today.sum," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,children:"exports"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:700,fz:"sm",mt:"md",children:[dashboard.payfit.today.siretsCount," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"dimmed",children:"SIRETs concern\xe9s"})]})]},"payfit_today")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"apart",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"Exports en attente"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,children:[dashboard.payfit.pending.sum," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,children:"exports"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:700,fz:"sm",mt:"md",children:[dashboard.payfit.pending.siretsCount," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"dimmed",children:"SIRETs concern\xe9s"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:"https://github.com/airporting/payfit-scraper/actions/workflows/scrap.yml",children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconGithub.U,{size:20})})]})},"payfit_pending")})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:"pennylane.com",alt:"Pennylane"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:"Pennylane"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"apart",children:/*#__PURE__*/(0,jsx_runtime.jsx)("div",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"\uD83C\uDF6A Cookie"})})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fz:"sm",mt:"md",children:["Dernier refresh \xe0"," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,span:true,c:dashboard.pennylane.isTooOld?"red":"green",children:dashboard.pennylane.lastTime})]})]},"pennylane_cookie")})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:"Synchro"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Grid,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"apart",children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"T\xe2ches"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,c:"green",children:[dashboard.synchro.askedToday," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"initial",children:"aujourd'hui"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{c:"dimmed",fz:"sm",mt:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,fw:700,c:"red",children:dashboard.synchro.errorsToday})," ","en erreur (~",((dashboard.synchro.errorsToday??0)*100/(dashboard.synchro.askedToday??1)).toFixed(2),"%)"]})]},"synchro_today")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"apart",children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"Actuellement"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,children:[dashboard.synchro.running," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"initial",children:"en cours"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"apart",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{c:"dimmed",fz:"sm",mt:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,fw:700,children:dashboard.synchro.waiting})," ","en attente"]}),/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:"https://github.com/airporting/jobs_recipes_runner/actions/workflows/run-recipe.yml",children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconGithub.U,{size:20})})]})]},"synchro_running")})]}),dashboard.braintree&&/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",align:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconBraintree,{size:20}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:"Braintree"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid,{children:0===dashboard.braintree.connectors.length?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:12},children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",fz:"sm",children:"Aucune donn\xe9e Braintree"})}):dashboard.braintree.connectors.map(connector=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:connector.merchant}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fz:"sm",mt:"md",children:["Derni\xe8re transaction le"," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,span:true,c:connector.isTooOld?"red":"green",children:connector.lastTime})]})]})},connector.merchant))})]})]}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Chargement…"})]})]})})}var providers=__webpack_require__(7034);function Dashboard(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)(App,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["9777"],{2268:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{g:()=>useFinanceJobsStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useFinanceJobsStock(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","finance-jobs","stock"],queryFn:async()=>(await api.financeJobs.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},3139:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{V:()=>useGithubQuery});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useGithubQuery(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();const query=(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","github"],queryFn:async()=>await api.github.getJobsRunnersV1().then(x=>x.data),refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true});return query}},466:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>useGsheetStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useGsheetStock(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","gsheet","stock"],queryFn:async()=>(await api.gsheet.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},1354:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{m:()=>PageHeader});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(9632);var react__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3106);function formatRelative(now,then){const seconds=Math.max(0,Math.floor((now-then)/1e3));if(seconds<5)return"\xe0 l’instant";if(seconds<60)return`il y a ${seconds}s`;const minutes=Math.floor(seconds/60);if(minutes<60)return`il y a ${minutes} min`;const hours=Math.floor(minutes/60);return`il y a ${hours} h`}function PageHeader({title,leading,badge,updatedAt,isFetching,isError,onRefresh,actions}){const[now,setNow]=(0,react__WEBPACK_IMPORTED_MODULE_3__.useState)(()=>Date.now());(0,react__WEBPACK_IMPORTED_MODULE_3__.useEffect)(()=>{if(!updatedAt)return;const id=window.setInterval(()=>setNow(Date.now()),1e3);return()=>window.clearInterval(id)},[updatedAt]);const relative=updatedAt?formatRelative(now,updatedAt):null;const color=isError?"orange":isFetching?"teal":"dimmed";return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{justify:"space-between",align:"center",mih:48,mb:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[leading,/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Title,{order:2,children:title}),badge]}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[relative&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Text,{size:"xs",c:color,fw:isFetching?600:400,"data-testid":"page-header-freshness",children:isError?"\xe9chec maj":isFetching?"maj…":relative}),onRefresh&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Tooltip,{label:"Rafra\xeechir",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.ActionIcon,{variant:"default",size:"md",onClick:onRefresh,loading:isFetching,"aria-label":"Refresh",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__.IconRefresh,{size:16})})}),actions]})]})}},5068:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>IconGithub});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);function IconGithub({color="currentColor",size=20,marker,...props}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("svg",{width:size,height:size,viewBox:"0 0 24 24",fill:color,xmlns:"http://www.w3.org/2000/svg",...props,children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("path",{d:"M12 0.297C5.373 0.297 0 5.67 0 12.297c0 5.292 3.438 9.787 8.205 11.387.6.111.82-.261.82-.58 0-.287-.011-1.244-.016-2.255-3.338.726-4.042-1.609-4.042-1.609-.546-1.389-1.333-1.759-1.333-1.759-1.089-.745.083-.73.083-.73 1.205.085 1.84 1.236 1.84 1.236 1.07 1.834 2.807 1.304 3.492.997.107-.775.419-1.305.762-1.605-2.665-.304-5.466-1.332-5.466-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.536-1.524.116-3.176 0 0 1.008-.322 3.301 1.23a11.51 11.51 0 0 1 3.004-.404 c1.019.005 2.047.138 3.004.404 2.291-1.552 3.297-1.23 3.297-1.23.655 1.652.243 2.873.119 3.176.77.84 1.235 1.91 1.235 3.221 0 4.61-2.805 5.624-5.476 5.921.43.372.823 1.104.823 2.223 0 1.606-.015 2.896-.015 3.293 0 .321.216.697.825.578C20.565 22.08 24 17.585 24 12.297 24 5.67 18.627.297 12 .297z"})})}},1394:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Dashboard});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useDashboardQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","dashboard"],queryFn:async()=>await api.getDashboard().then(x=>x.data),refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true});return query}var IconGithub=__webpack_require__(5068);function IconHealthCross({color="#2CA01C",size=20,...props}){return/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:size,height:size,viewBox:"0 0 24 24",fill:color,xmlns:"http://www.w3.org/2000/svg",role:"img","aria-label":"Sant\xe9",...props,children:[/*#__PURE__*/(0,jsx_runtime.jsx)("title",{children:"Sant\xe9"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M9 2h6a1 1 0 0 1 1 1v5h5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-5v5a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1v-5H3a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1h5V3a1 1 0 0 1 1-1Z"})]})}var dist_index_js_=__webpack_require__(1380);var PageHeader=__webpack_require__(1354);var financeJobsStockQuery=__webpack_require__(2268);var gsheetStockQuery=__webpack_require__(466);var githubQuery=__webpack_require__(3139);function toneColor(tone){if("bad"===tone)return"red";if("warn"===tone)return"orange";return"green"}function toneLabel(tone){if("bad"===tone)return"ALERT";if("warn"===tone)return"WARN";return"OK"}function SystemHealthStrip(){const finance=(0,financeJobsStockQuery.g)();const gsheet=(0,gsheetStockQuery.U)();const github=(0,githubQuery.V)();const loading=finance.isLoading||gsheet.isLoading||github.isLoading;if(loading)return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.SimpleGrid,{cols:3,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:80}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:80}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Skeleton,{height:80})]});const tiles=[];if(finance.data){const d=finance.data;const errored=d.errored??0;const stuck=d.stuck??0;tiles.push({key:"finance",title:"Finance jobs",detail:`${d.pending??0} pending \xb7 ${errored} errored`,tone:errored>0?"bad":stuck>0?"warn":"ok"})}if(gsheet.data){const d=gsheet.data;const errored=d.errored??0;const stuck=d.stuck??0;tiles.push({key:"gsheet",title:"Worksheet",detail:`${d.pending??0} pending \xb7 ${errored} errored`,tone:errored>0?"bad":stuck>0?"warn":"ok"})}if(github.data){const list=github.data.list??[];const repos=list.length;tiles.push({key:"runners",title:"Runners GitHub",detail:`${repos} repos surveill\xe9s`,tone:0===repos?"bad":"ok"})}if(0===tiles.length)return null;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:Math.min(tiles.length,3),children:tiles.map(t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",align:"flex-start",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:600,children:t.title}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:toneColor(t.tone),variant:"light",children:toneLabel(t.tone)})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:"dimmed",mt:4,children:t.detail})]},t.key))})}function App(){const dashboardResult=useDashboardQuery();const dashboard=dashboardResult.data;return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Container,{fluid:true,my:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(PageHeader.m,{title:"Sant\xe9",leading:/*#__PURE__*/(0,jsx_runtime.jsx)(IconHealthCross,{size:26}),updatedAt:dashboardResult.dataUpdatedAt,isFetching:dashboardResult.isFetching,isError:dashboardResult.isError,onRefresh:()=>dashboardResult.refetch()}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,mb:"sm",children:"Sant\xe9 Syst\xe8me"}),/*#__PURE__*/(0,jsx_runtime.jsx)(SystemHealthStrip,{})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Divider,{}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,mb:"sm",children:"Int\xe9grations Produit"}),dashboard?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:3,ml:dashboard.gsheet.globalProblem?-30:0,children:[dashboard.gsheet.globalProblem?/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.IconCross,{size:24,color:"red"}):/*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{}),"Worksheet"]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Grid,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"apart",children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"T\xe2ches non termin\xe9es"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,c:dashboard.gsheet.pending>50?"red":dashboard.gsheet.pending>30?"orange":"green",children:[dashboard.gsheet.pending," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,children:"onglets"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fw:700,fz:"sm",mt:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{span:true,c:"dimmed",children:["Le plus ancien date du :"," "]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,fw:"bold",c:dashboard.gsheet.isPendingTooOld?"red":"green",children:dashboard.gsheet.oldest})]})]},"gsheet_pending")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"apart",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"T\xe2ches en cours"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,children:[dashboard.gsheet.running," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,children:"onglets"})]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:"https://github.com/airporting/gsheet_runner/actions",children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconGithub.U,{size:20})})]})},"gsheet_running")})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:"Synchro"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Grid,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"apart",children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"T\xe2ches"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,c:"green",children:[dashboard.synchro.askedToday," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"initial",children:"aujourd'hui"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{c:"dimmed",fz:"sm",mt:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,fw:700,c:"red",children:dashboard.synchro.errorsToday})," ","en erreur (~",((dashboard.synchro.errorsToday??0)*100/(dashboard.synchro.askedToday??1)).toFixed(2),"%)"]})]},"synchro_today")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Grid.Col,{span:{base:6},children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Paper,{withBorder:true,p:"md",radius:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{justify:"apart",children:/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",tt:"uppercase",fw:700,fz:"xs",children:"Actuellement"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Title,{order:4,children:[dashboard.synchro.running," ",/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,c:"initial",children:"en cours"})]})]})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"apart",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{c:"dimmed",fz:"sm",mt:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{span:true,fw:700,children:dashboard.synchro.waiting})," ","en attente"]}),/*#__PURE__*/(0,jsx_runtime.jsx)(dist_index_js_.AirButton,{variant:"subtle",color:"gray",href:"https://github.com/airporting/jobs_recipes_runner/actions/workflows/run-recipe.yml",children:/*#__PURE__*/(0,jsx_runtime.jsx)(IconGithub.U,{size:20})})]})]},"synchro_running")})]})]}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Chargement…"})]})]})})}var providers=__webpack_require__(7034);function Dashboard(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)(App,{})})})}}}]);
@@ -1 +1 @@
1
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["7825"],{2268:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{g:()=>useFinanceJobsStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useFinanceJobsStock(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","finance-jobs","stock"],queryFn:async()=>(await api.financeJobs.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},1486: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 QueueDashboard=__webpack_require__(2663);var index_mjs_=__webpack_require__(207);var financeJobsStockQuery=__webpack_require__(2268);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);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},...filters.period&&{period:filters.period},...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})}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})}var jobLogsContext=__webpack_require__(6845);var tabler_icons_react_mjs_=__webpack_require__(9632);var esm_index_mjs_=__webpack_require__(1455);function notify(title,message,color){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 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=>{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=>{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:"▶ Ajouter des runners"})]})}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"};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);return`${m}m${s%60}s`}function ageBadge(created){const h=(Date.now()-new Date(created).getTime())/36e5;if(h<1)return null;const label=h>=24?`${Math.floor(h/24)}j`:`${Math.floor(h)}h`;const color=h>=24?"red":h>=4?"orange":"gray";return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{ml:6,size:"xs",color:color,variant:"light",children:label})}function FinanceRowActions({item}){const openLogs=(0,jobLogsContext.j)();const companyLabel=item.company_display_name??item.company_slug??`#${item.company_id}`;return/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:item.id,jobName:item.job_name,companyLabel:companyLabel,currentOwner:item.owner,githubJob:item.github_job,onShowLogs:openLogs})}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 useFinanceJobsConfig(){const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();return(0,index_js_.useMemo)(()=>({title:"Finance jobs",source:{useStock:financeJobsStockQuery.g,useTasks:({job_name,owner,company_slug,state,beta,period})=>useFinanceJobsTasks({job_name:job_name??void 0,owner:owner??void 0,company_slug:company_slug??void 0,state,beta,period,take:50})},initialFilters:{job_name:null,owner:null,company_slug:null,state:"pending",beta:"false",period:"all",search:""},kpis:[{key:"pending",label:"Pending",value:s=>s?.pending??0,filter:{state:"pending",beta:"all",period:"all"}},{key:"running",label:"Running",value:s=>s?.running??0,filter:{state:"running",beta:"all",period:"all"}},{key:"stuck",label:"Stuck",value:s=>s?.stuck??0,tone:s=>(s?.stuck??0)>0?"warn":"neutral",filter:{state:"stuck",beta:"all",period:"all"}},{key:"errored_today",label:"Erreurs du jour",value:s=>s?.errored_today??0,tone:s=>(s?.errored_today??0)>0?"bad":"neutral",filter:{state:"errored",beta:"all",period:"today"}},{key:"done_today",label:"Done today",value:s=>s?.done_today??0,filter:{state:"done",beta:"all",period:"today"}},{key:"oldest",label:"Oldest pending",value:s=>s?.oldest?`${s.oldest.ageHours}h`:"—"}],filters:[{kind:"select",key:"job_name",label:"Job",options:s=>(s?.byJobName??[]).map(e=>e.key),width:240},{kind:"select",key:"owner",label:"Owner",options:s=>(s?.byOwner??[]).map(e=>e.key),width:240},{kind:"select",key:"company_slug",label:"Company",options:s=>(s?.byCompany??[]).map(e=>e.key),width:220},{kind:"select",key:"state",label:"State",options:()=>["pending","running","stuck","errored","done","all"],clearable:false,width:140},{kind:"select",key:"beta",label:"Beta",options:()=>[{value:"false",label:"Prod"},{value:"true",label:"Beta"},{value:"all",label:"All"}],clearable:false,width:120},{kind:"select",key:"period",label:"P\xe9riode",options:()=>[{value:"all",label:"Tout"},{value:"today",label:"Aujourd'hui"}],clearable:false,width:140},{kind:"search",key:"search",label:"Recherche",placeholder:"id, owner, company, erreur…",width:240}],columns:[{key:"job",label:"Job",render:t=>/*#__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"})]})},{key:"company",label:"Company",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.company_display_name??t.company_slug??`#${t.company_id}`})},{key:"owner",label:"Owner",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.owner})},{key:"state",label:"State",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]})},{key:"created",label:"Created",render:t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:4,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.created)}),ageBadge(t.created)]})},{key:"duration",label:"Duration",render:t=>fmtDuration(t.runDuration)},{key:"error",label:"Result / Error",render:t=>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",maxWidth:320},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??""]}):"—"}],rowActions:[{key:"actions",render:item=>/*#__PURE__*/(0,jsx_runtime.jsx)(FinanceRowActions,{item:item})}],bulkActions:[{key:"unstick",label:"Unstick",run:ids=>runBulk(ids,id=>unstick.mutateAsync(id))},{key:"retry",label:"Retry",confirm:{title:"Retry {count} task(s)",body:"Reset les t\xe2ches pour que le runner les reprenne."},run:ids=>runBulk(ids,id=>retry.mutateAsync(id))},{key:"set-owner",label:"Set owner…",prompt:{label:"Owner email",placeholder:"bob@airporting.com"},run:(ids,owner)=>{if(!owner)return Promise.resolve({ok:0,failed:ids.length});return runBulk(ids,id=>setOwner.mutateAsync({id,owner}))}},{key:"delete-lock",label:"Delete Redis lock",color:"orange",confirm:{title:"Delete Redis lock for {count} task(s)",body:"Suppression du verrou Redis fm-task-node-<id>."},run:ids=>runBulk(ids,id=>deleteLock.mutateAsync(id))},{key:"discard",label:"Discard",color:"red",confirm:{title:"Discard {count} task(s)",body:"Les t\xe2ches seront marqu\xe9es comme finished avec error=discarded."},run:ids=>runBulk(ids,id=>discard.mutateAsync(id))}],topErrors:{extract:t=>t.error},headerBadge:/*#__PURE__*/(0,jsx_runtime.jsx)(RunnerBadge,{}),headerActions:/*#__PURE__*/(0,jsx_runtime.jsx)(RunRecipeButton,{}),getRowId:t=>t.id,searchMatches:(t,q)=>String(t.id).includes(q)||(t.owner??"").toLowerCase().includes(q)||(t.company_slug??"").toLowerCase().includes(q)||(t.company_display_name??"").toLowerCase().includes(q)||(t.job_name??"").toLowerCase().includes(q)||(t.error??"").toLowerCase().includes(q)}),[unstick,retry,discard,setOwner,deleteLock])}function FinanceJobsApp(){const config=useFinanceJobsConfig();return/*#__PURE__*/(0,jsx_runtime.jsx)(QueueDashboard.r,{config:config})}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"],{2268:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{g:()=>useFinanceJobsStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useFinanceJobsStock(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","finance-jobs","stock"],queryFn:async()=>(await api.financeJobs.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},1486: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 QueueDashboard=__webpack_require__(2663);var index_mjs_=__webpack_require__(207);var financeJobsStockQuery=__webpack_require__(2268);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);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},...filters.period&&{period:filters.period},...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})}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})}var jobLogsContext=__webpack_require__(4302);var tabler_icons_react_mjs_=__webpack_require__(9632);var esm_index_mjs_=__webpack_require__(1455);function notify(title,message,color){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 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=>{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=>{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:"▶ Ajouter des runners"})]})}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"};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);return`${m}m${s%60}s`}function ageBadge(created){const h=(Date.now()-new Date(created).getTime())/36e5;if(h<1)return null;const label=h>=24?`${Math.floor(h/24)}j`:`${Math.floor(h)}h`;const color=h>=24?"red":h>=4?"orange":"gray";return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{ml:6,size:"xs",color:color,variant:"light",children:label})}function FinanceRowActions({item}){const openLogs=(0,jobLogsContext.j)();const companyLabel=item.company_display_name??item.company_slug??`#${item.company_id}`;return/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:item.id,jobName:item.job_name,companyLabel:companyLabel,currentOwner:item.owner,githubJob:item.github_job,onShowLogs:openLogs})}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 useFinanceJobsConfig(){const unstick=useUnstickFinanceTask();const retry=useRetryFinanceTask();const discard=useDiscardFinanceTask();const setOwner=useSetFinanceTaskOwner();const deleteLock=useDeleteFinanceRedisLock();return(0,index_js_.useMemo)(()=>({title:"Finance jobs",source:{useStock:financeJobsStockQuery.g,useTasks:({job_name,owner,company_slug,state,beta,period})=>useFinanceJobsTasks({job_name:job_name??void 0,owner:owner??void 0,company_slug:company_slug??void 0,state,beta,period,take:50})},initialFilters:{job_name:null,owner:null,company_slug:null,state:"pending",beta:"false",period:"all",search:""},kpis:[{key:"pending",label:"Pending",value:s=>s?.pending??0,filter:{state:"pending",beta:"all",period:"all"}},{key:"running",label:"Running",value:s=>s?.running??0,filter:{state:"running",beta:"all",period:"all"}},{key:"stuck",label:"Stuck",value:s=>s?.stuck??0,tone:s=>(s?.stuck??0)>0?"warn":"neutral",filter:{state:"stuck",beta:"all",period:"all"}},{key:"errored_today",label:"Erreurs du jour",value:s=>s?.errored_today??0,tone:s=>(s?.errored_today??0)>0?"bad":"neutral",filter:{state:"errored",beta:"all",period:"today"}},{key:"done_today",label:"Done today",value:s=>s?.done_today??0,filter:{state:"done",beta:"all",period:"today"}},{key:"oldest",label:"Oldest pending",value:s=>s?.oldest?`${s.oldest.ageHours}h`:"—"}],filters:[{kind:"select",key:"job_name",label:"Job",options:s=>(s?.byJobName??[]).map(e=>e.key),width:240},{kind:"select",key:"owner",label:"Owner",options:s=>(s?.byOwner??[]).map(e=>e.key),width:240},{kind:"select",key:"company_slug",label:"Company",options:s=>(s?.byCompany??[]).map(e=>e.key),width:220},{kind:"select",key:"state",label:"State",options:()=>["pending","running","stuck","errored","done","all"],clearable:false,width:140},{kind:"select",key:"beta",label:"Beta",options:()=>[{value:"false",label:"Prod"},{value:"true",label:"Beta"},{value:"all",label:"All"}],clearable:false,width:120},{kind:"select",key:"period",label:"P\xe9riode",options:()=>[{value:"all",label:"Tout"},{value:"today",label:"Aujourd'hui"}],clearable:false,width:140},{kind:"search",key:"search",label:"Recherche",placeholder:"id, owner, company, erreur…",width:240}],columns:[{key:"job",label:"Job",render:t=>/*#__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"})]})},{key:"company",label:"Company",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.company_display_name??t.company_slug??`#${t.company_id}`})},{key:"owner",label:"Owner",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.owner})},{key:"state",label:"State",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]})},{key:"created",label:"Created",render:t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:4,wrap:"nowrap",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.created)}),ageBadge(t.created)]})},{key:"duration",label:"Duration",render:t=>fmtDuration(t.runDuration)},{key:"error",label:"Result / Error",render:t=>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",maxWidth:320},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??""]}):"—"}],rowActions:[{key:"actions",render:item=>/*#__PURE__*/(0,jsx_runtime.jsx)(FinanceRowActions,{item:item})}],bulkActions:[{key:"unstick",label:"Unstick",run:ids=>runBulk(ids,id=>unstick.mutateAsync(id))},{key:"retry",label:"Retry",confirm:{title:"Retry {count} task(s)",body:"Reset les t\xe2ches pour que le runner les reprenne."},run:ids=>runBulk(ids,id=>retry.mutateAsync(id))},{key:"set-owner",label:"Set owner…",prompt:{label:"Owner email",placeholder:"bob@airporting.com"},run:(ids,owner)=>{if(!owner)return Promise.resolve({ok:0,failed:ids.length});return runBulk(ids,id=>setOwner.mutateAsync({id,owner}))}},{key:"delete-lock",label:"Delete Redis lock",color:"orange",confirm:{title:"Delete Redis lock for {count} task(s)",body:"Suppression du verrou Redis fm-task-node-<id>."},run:ids=>runBulk(ids,id=>deleteLock.mutateAsync(id))},{key:"discard",label:"Discard",color:"red",confirm:{title:"Discard {count} task(s)",body:"Les t\xe2ches seront marqu\xe9es comme finished avec error=discarded."},run:ids=>runBulk(ids,id=>discard.mutateAsync(id))}],topErrors:{extract:t=>t.error},headerBadge:/*#__PURE__*/(0,jsx_runtime.jsx)(RunnerBadge,{}),headerActions:/*#__PURE__*/(0,jsx_runtime.jsx)(RunRecipeButton,{}),getRowId:t=>t.id,searchMatches:(t,q)=>String(t.id).includes(q)||(t.owner??"").toLowerCase().includes(q)||(t.company_slug??"").toLowerCase().includes(q)||(t.company_display_name??"").toLowerCase().includes(q)||(t.job_name??"").toLowerCase().includes(q)||(t.error??"").toLowerCase().includes(q)}),[unstick,retry,discard,setOwner,deleteLock])}function FinanceJobsApp(){const config=useFinanceJobsConfig();return/*#__PURE__*/(0,jsx_runtime.jsx)(QueueDashboard.r,{config:config})}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 +1 @@
1
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["610"],{3897:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{O:()=>BrandLogo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(243);function BrandLogo({domain,alt,size=24}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Image,{src:(0,_src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__.j)(domain),alt:alt,title:alt,w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}},243:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{j:()=>logoDevUrl});const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}},2792:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Sales});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useSalesLeads(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sales","leads"],queryFn:async()=>(await api.sales.listLeadsV1()).data,refetchOnWindowFocus:true})}var esm_index_mjs_=__webpack_require__(1455);function useSalesRescan(){const api=(0,useApi.h)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async()=>(await api.sales.rescanV1()).data,onSuccess:data=>{esm_index_mjs_.notifications.show({title:"Re-scan",message:data?.message??"Re-scan lanc\xe9",color:data?.ok?"green":"orange"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{esm_index_mjs_.notifications.show({title:"Re-scan",message:err?.error?.error??err?.message??"\xc9chec du re-scan",color:"red"})}})}const TEMPERATURE_META={burning:{emoji:"\uD83D\uDD25\uD83D\uDD25",label:"Br\xfblant",order:5},hot:{emoji:"\uD83D\uDD25",label:"Chaud",order:4},warm:{emoji:"\uD83C\uDF21️",label:"Ti\xe8de",order:3},cold:{emoji:"❄️",label:"Froid",order:2},frozen:{emoji:"\uD83E\uDDCA",label:"Gel\xe9",order:1}};const TEMPERATURE_ORDER=["burning","hot","warm","cold","frozen"];function dueLabel(value){if(!value)return"Pas de date fix\xe9e";return new Date(value).toLocaleDateString("fr-FR",{timeZone:"Europe/Paris"})}function compare(a,b,key,desc){let av;let bv;if("temperature"===key){av=TEMPERATURE_META[a.temperature].order;bv=TEMPERATURE_META[b.temperature].order}else{av=a[key]?new Date(a[key]).getTime():0;bv=b[key]?new Date(b[key]).getTime():0}if(desc)return bv-av;return av-bv}function LeadsTable({leads,temperatureFilter,onRowClick}){const[sortKey,setSortKey]=(0,index_js_.useState)("last_contact_at");const[desc,setDesc]=(0,index_js_.useState)(true);function toggleSort(key){if(key===sortKey)setDesc(d=>!d);else{setSortKey(key);setDesc(true)}}const rows=(0,index_js_.useMemo)(()=>{const filtered=temperatureFilter?leads.filter(l=>l.temperature===temperatureFilter):leads;return[...filtered].sort((a,b)=>compare(a,b,sortKey,desc))},[leads,temperatureFilter,sortKey,desc]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>toggleSort("temperature"),children:"Temp\xe9rature"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Pr\xe9nom"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Nom"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>toggleSort("last_contact_at"),children:"Dernier contact"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Prochaine action"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>toggleSort("next_action_due_at"),children:"\xc9ch\xe9ance"})})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map(l=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{style:{cursor:"pointer"},onClick:()=>onRowClick(l.id),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:TEMPERATURE_META[l.temperature].emoji}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.first_name??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.last_name??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.company??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.last_contact_at?new Date(l.last_contact_at).toLocaleDateString("fr-FR",{timeZone:"Europe/Paris"}):"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.next_action??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:l.next_action_due_at?void 0:"dimmed",children:dueLabel(l.next_action_due_at)})})]},l.id))})]})}function useSalesLead(id){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sales","lead",id],enabled:null!==id,queryFn:async()=>(await api.sales.getLeadV1({id})).data})}function useUpdateLead(id){const api=(0,useApi.h)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async payload=>(await api.sales.updateLeadV1({id},payload)).data,onSuccess:()=>{esm_index_mjs_.notifications.show({title:"Lead",message:"Modifications enregistr\xe9es",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la mise \xe0 jour",color:"red"})}})}function useDeleteLead(){const api=(0,useApi.h)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.sales.deleteLeadV1({id})).data,onSuccess:()=>{esm_index_mjs_.notifications.show({title:"Lead",message:"Lead supprim\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la suppression",color:"red"})}})}var BrandLogo=__webpack_require__(3897);const SOURCE_DOMAIN={pipedrive:"pipedrive.com",gmail:"google.com",claap:"claap.io",granola:"granola.ai",lemlist:"lemlist.com",linkedin:"linkedin.com",imessage:"apple.com",whatsapp:"whatsapp.com",slack:"slack.com",calendar:"google.com",pennylane:"pennylane.com",yousign:"yousign.com",notion:"notion.so"};function SourceLogo({source,size=18}){const domain=SOURCE_DOMAIN[source];if(!domain)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:"light",color:"gray",title:source,children:source.slice(0,2).toUpperCase()});return/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:domain,alt:source,size:size})}function directionLabel(direction){if("inbound"===direction)return"↘ Entrant";return"↗ Sortant"}function LeadTimeline({items}){if(0===items.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Aucun \xe9change."});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Timeline,{active:items.length,bulletSize:14,lineWidth:2,children:items.map(it=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Timeline.Item,{title:it.summary??"(sans r\xe9sum\xe9)",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",mb:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SourceLogo,{source:it.source}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",fw:500,tt:"capitalize",children:it.source}),it.channel?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:"outline",children:it.channel}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:directionLabel(it.direction)})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:new Date(it.occurred_at).toLocaleString("fr-FR",{timeZone:"Europe/Paris"})}),it.external_url?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Anchor,{href:it.external_url,target:"_blank",size:"xs",children:"Ouvrir la source"}):null]})]},it.id))})}function LeadDetailDrawer({leadId,onClose}){const detail=useSalesLead(leadId);const update=useUpdateLead(leadId??0);const remove=useDeleteLead();const[temperature,setTemperature]=(0,index_js_.useState)(null);const[nextAction,setNextAction]=(0,index_js_.useState)("");const[dueAt,setDueAt]=(0,index_js_.useState)("");(0,index_js_.useEffect)(()=>{if(detail.data){setTemperature(detail.data.temperature);setNextAction(detail.data.next_action??"");setDueAt(detail.data.next_action_due_at??"")}},[detail.data]);function save(){update.mutate({temperature:temperature??void 0,next_action:""===nextAction?null:nextAction,next_action_due_at:""===dueAt?null:dueAt})}function handleDelete(){if(null===leadId)return;remove.mutate(leadId,{onSuccess:onClose})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Drawer,{opened:null!==leadId,onClose:onClose,position:"right",size:"lg",title:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,children:"Lead"}),children:[detail.isLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Loader,{}):null,detail.data?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Prochaine action",value:nextAction,onChange:e=>setNextAction(e.currentTarget.value),flex:1}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"\xc9ch\xe9ance (ISO)",placeholder:"Pas de date fix\xe9e",value:dueAt,onChange:e=>setDueAt(e.currentTarget.value)})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Temp\xe9rature",data:TEMPERATURE_ORDER.map(t=>({value:t,label:`${TEMPERATURE_META[t].emoji} ${TEMPERATURE_META[t].label}`})),value:temperature,onChange:setTemperature}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",variant:"light",onClick:handleDelete,children:"Supprimer"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:update.isPending,onClick:save,children:"Enregistrer"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,mt:"md",children:"Historique"}),/*#__PURE__*/(0,jsx_runtime.jsx)(LeadTimeline,{items:detail.data.interactions})]}):null]})}function SalesApp(){const leads=useSalesLeads();const rescan=useSalesRescan();const[selectedId,setSelectedId]=(0,index_js_.useState)(null);const[temperatureFilter,setTemperatureFilter]=(0,index_js_.useState)(null);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{fluid:true,my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",mb:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Sales"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{placeholder:"Toutes temp\xe9ratures",clearable:true,data:TEMPERATURE_ORDER.map(t=>({value:t,label:`${TEMPERATURE_META[t].emoji} ${TEMPERATURE_META[t].label}`})),value:temperatureFilter,onChange:v=>setTemperatureFilter(v)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:rescan.isPending,onClick:()=>rescan.mutate(),variant:"light",children:"Re-scanner"})]})]}),leads.isLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Loader,{}):null,leads.data?/*#__PURE__*/(0,jsx_runtime.jsx)(LeadsTable,{leads:leads.data.leads,temperatureFilter:temperatureFilter,onRowClick:setSelectedId}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(LeadDetailDrawer,{leadId:selectedId,onClose:()=>setSelectedId(null)})]})}function Sales(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(SalesApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["610"],{3897:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{O:()=>BrandLogo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(243);function BrandLogo({domain,alt,size=24}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Image,{src:(0,_src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__.j)(domain),alt:alt,title:alt,w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}},243:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{j:()=>logoDevUrl});const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}},2845:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Sales});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var index_mjs_=__webpack_require__(207);var esm_index_mjs_=__webpack_require__(3863);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useSalesLeads(){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sales","leads"],queryFn:async()=>(await api.sales.listLeadsV1()).data,refetchOnWindowFocus:true})}var notifications_esm_index_mjs_=__webpack_require__(1455);function useSalesRescan(){const api=(0,useApi.h)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async()=>(await api.sales.rescanV1()).data,onSuccess:data=>{notifications_esm_index_mjs_.notifications.show({title:"Re-scan",message:data?.message??"Re-scan lanc\xe9",color:data?.ok?"green":"orange"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Re-scan",message:err?.error?.error??err?.message??"\xc9chec du re-scan",color:"red"})}})}const TEMPERATURE_META={burning:{emoji:"\uD83D\uDD25\uD83D\uDD25",label:"Br\xfblant",order:5},hot:{emoji:"\uD83D\uDD25",label:"Chaud",order:4},warm:{emoji:"\uD83C\uDF21️",label:"Ti\xe8de",order:3},cold:{emoji:"❄️",label:"Froid",order:2},frozen:{emoji:"\uD83E\uDDCA",label:"Gel\xe9",order:1}};const TEMPERATURE_ORDER=["burning","hot","warm","cold","frozen"];function dueLabel(value){if(!value)return"Pas de date fix\xe9e";return new Date(value).toLocaleDateString("fr-FR",{timeZone:"Europe/Paris"})}function compare(a,b,key,desc){let av;let bv;if("temperature"===key){av=TEMPERATURE_META[a.temperature].order;bv=TEMPERATURE_META[b.temperature].order}else{av=a[key]?new Date(a[key]).getTime():0;bv=b[key]?new Date(b[key]).getTime():0}if(desc)return bv-av;return av-bv}function LeadsTable({leads,temperatureFilter,onRowClick}){const[sortKey,setSortKey]=(0,index_js_.useState)("last_contact_at");const[desc,setDesc]=(0,index_js_.useState)(true);function toggleSort(key){if(key===sortKey)setDesc(d=>!d);else{setSortKey(key);setDesc(true)}}const rows=(0,index_js_.useMemo)(()=>{const filtered=temperatureFilter?leads.filter(l=>l.temperature===temperatureFilter):leads;return[...filtered].sort((a,b)=>compare(a,b,sortKey,desc))},[leads,temperatureFilter,sortKey,desc]);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{highlightOnHover:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>toggleSort("temperature"),children:"Temp\xe9rature"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Pr\xe9nom"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Nom"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Entreprise"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>toggleSort("last_contact_at"),children:"Dernier contact"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Prochaine action"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.UnstyledButton,{onClick:()=>toggleSort("next_action_due_at"),children:"\xc9ch\xe9ance"})})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:rows.map(l=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{style:{cursor:"pointer"},onClick:()=>onRowClick(l.id),children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:TEMPERATURE_META[l.temperature].emoji}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.first_name??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.last_name??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.company??""}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.last_contact_at?new Date(l.last_contact_at).toLocaleDateString("fr-FR",{timeZone:"Europe/Paris"}):"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:l.next_action??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",c:l.next_action_due_at?void 0:"dimmed",children:dueLabel(l.next_action_due_at)})})]},l.id))})]})}function useSalesLead(id){const api=(0,useApi.h)();return(0,modern_index_js_.useQuery)({queryKey:["tech","sales","lead",id],enabled:null!==id,queryFn:async()=>(await api.sales.getLeadV1({id})).data})}function useUpdateLead(id){const api=(0,useApi.h)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async payload=>(await api.sales.updateLeadV1({id},payload)).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:"Modifications enregistr\xe9es",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la mise \xe0 jour",color:"red"})}})}function useDeleteLead(){const api=(0,useApi.h)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.sales.deleteLeadV1({id})).data,onSuccess:()=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:"Lead supprim\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la suppression",color:"red"})}})}var BrandLogo=__webpack_require__(3897);const SOURCE_DOMAIN={pipedrive:"pipedrive.com",gmail:"google.com",claap:"claap.io",granola:"granola.ai",lemlist:"lemlist.com",linkedin:"linkedin.com",imessage:"apple.com",whatsapp:"whatsapp.com",slack:"slack.com",calendar:"google.com",pennylane:"pennylane.com",yousign:"yousign.com",notion:"notion.so"};function SourceLogo({source,size=18}){const domain=SOURCE_DOMAIN[source];if(!domain)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:"light",color:"gray",title:source,children:source.slice(0,2).toUpperCase()});return/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:domain,alt:source,size:size})}function directionLabel(direction){if("inbound"===direction)return"↘ Entrant";return"↗ Sortant"}function LeadTimeline({items}){if(0===items.length)return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Aucun \xe9change."});return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Timeline,{active:items.length,bulletSize:14,lineWidth:2,children:items.map(it=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Timeline.Item,{title:it.summary??"(sans r\xe9sum\xe9)",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",mb:4,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(SourceLogo,{source:it.source}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",fw:500,tt:"capitalize",children:it.source}),it.channel?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{size:"xs",variant:"outline",children:it.channel}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:directionLabel(it.direction)})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",children:new Date(it.occurred_at).toLocaleString("fr-FR",{timeZone:"Europe/Paris"})}),it.external_url?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Anchor,{href:it.external_url,target:"_blank",size:"xs",children:"Ouvrir la source"}):null]})]},it.id))})}function LeadDetailDrawer({leadId,onClose}){const detail=useSalesLead(leadId);const update=useUpdateLead(leadId??0);const remove=useDeleteLead();const[temperature,setTemperature]=(0,index_js_.useState)(null);const[nextAction,setNextAction]=(0,index_js_.useState)("");const[dueAt,setDueAt]=(0,index_js_.useState)("");(0,index_js_.useEffect)(()=>{if(detail.data){setTemperature(detail.data.temperature);setNextAction(detail.data.next_action??"");setDueAt(detail.data.next_action_due_at??"")}},[detail.data]);function save(){update.mutate({temperature:temperature??void 0,next_action:""===nextAction?null:nextAction,next_action_due_at:""===dueAt?null:dueAt})}function handleDelete(){if(null===leadId)return;remove.mutate(leadId,{onSuccess:onClose})}return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Drawer,{opened:null!==leadId,onClose:onClose,position:"right",size:"lg",title:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:4,children:"Lead"}),children:[detail.isLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Loader,{}):null,detail.data?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Prochaine action",value:nextAction,onChange:e=>setNextAction(e.currentTarget.value),flex:1}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"\xc9ch\xe9ance (ISO)",placeholder:"Pas de date fix\xe9e",value:dueAt,onChange:e=>setDueAt(e.currentTarget.value)})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{label:"Temp\xe9rature",data:TEMPERATURE_ORDER.map(t=>({value:t,label:`${TEMPERATURE_META[t].emoji} ${TEMPERATURE_META[t].label}`})),value:temperature,onChange:setTemperature}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{color:"red",variant:"light",onClick:handleDelete,children:"Supprimer"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:update.isPending,onClick:save,children:"Enregistrer"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:5,mt:"md",children:"Historique"}),/*#__PURE__*/(0,jsx_runtime.jsx)(LeadTimeline,{items:detail.data.interactions})]}):null]})}var dates_esm_index_mjs_=__webpack_require__(9038);var form_esm_index_mjs_=__webpack_require__(5021);function useCreateLead(){const api=(0,useApi.h)();const queryClient=(0,modern_index_js_.useQueryClient)();return(0,modern_index_js_.useMutation)({mutationFn:async payload=>(await api.sales.createLeadV1(payload)).data,onSuccess:data=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:data?.attached?"Coordonn\xe9e d\xe9j\xe0 connue — rattach\xe9 au lead existant":"Lead cr\xe9\xe9",color:"green"});queryClient.invalidateQueries({queryKey:["tech","sales"]})},onError:err=>{notifications_esm_index_mjs_.notifications.show({title:"Lead",message:err?.error?.error??err?.message??"\xc9chec de la cr\xe9ation",color:"red"})}})}function NewLeadModal({opened,onClose}){const create=useCreateLead();const form=(0,form_esm_index_mjs_.useForm)({initialValues:{first_name:"",last_name:"",company:"",email:"",phone:"",note:"",next_action_due_at:null,request_reconstruction:true},validate:{email:(value,values)=>value||values.phone?null:"Email ou t\xe9l\xe9phone requis"}});function submit(values){create.mutate({first_name:values.first_name||null,last_name:values.last_name||null,company:values.company||null,emails:values.email?[values.email]:[],phones:values.phone?[values.phone]:[],note:values.note||null,next_action_due_at:values.next_action_due_at?values.next_action_due_at.toISOString():null,request_reconstruction:values.request_reconstruction},{onSuccess:()=>{form.reset();onClose()}})}return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Modal,{opened:opened,onClose:onClose,title:"Nouveau lead",children:/*#__PURE__*/(0,jsx_runtime.jsx)("form",{onSubmit:form.onSubmit(submit),children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"sm",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Pr\xe9nom",...form.getInputProps("first_name")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Nom",...form.getInputProps("last_name")})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Entreprise",...form.getInputProps("company")}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{grow:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"Email",...form.getInputProps("email")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.TextInput,{label:"T\xe9l\xe9phone",...form.getInputProps("phone")})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Textarea,{label:"Note / prochaine action",...form.getInputProps("note")}),/*#__PURE__*/(0,jsx_runtime.jsx)(dates_esm_index_mjs_.DateInput,{label:"Relancer le",placeholder:"Pas de date fix\xe9e",clearable:true,valueFormat:"DD/MM/YYYY",...form.getInputProps("next_action_due_at")}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Checkbox,{label:"Reconstruire l'historique (recherche multi-sources)",...form.getInputProps("request_reconstruction",{type:"checkbox"})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"flex-end",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{variant:"default",onClick:onClose,children:"Annuler"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{type:"submit",loading:create.isPending,children:"Cr\xe9er"})]})]})})})}function SalesApp(){const leads=useSalesLeads();const rescan=useSalesRescan();const[selectedId,setSelectedId]=(0,index_js_.useState)(null);const[temperatureFilter,setTemperatureFilter]=(0,index_js_.useState)(null);const[newLeadOpened,newLead]=(0,esm_index_mjs_.useDisclosure)(false);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{fluid:true,my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",mb:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Sales"}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Select,{placeholder:"Toutes temp\xe9ratures",clearable:true,data:TEMPERATURE_ORDER.map(t=>({value:t,label:`${TEMPERATURE_META[t].emoji} ${TEMPERATURE_META[t].label}`})),value:temperatureFilter,onChange:v=>setTemperatureFilter(v)}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{onClick:newLead.open,children:"+ Nouveau lead"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Button,{loading:rescan.isPending,onClick:()=>rescan.mutate(),variant:"light",children:"Re-scanner"})]})]}),leads.isLoading?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Loader,{}):null,leads.data?/*#__PURE__*/(0,jsx_runtime.jsx)(LeadsTable,{leads:leads.data.leads,temperatureFilter:temperatureFilter,onRowClick:setSelectedId}):null,/*#__PURE__*/(0,jsx_runtime.jsx)(NewLeadModal,{opened:newLeadOpened,onClose:newLead.close}),/*#__PURE__*/(0,jsx_runtime.jsx)(LeadDetailDrawer,{leadId:selectedId,onClose:()=>setSelectedId(null)})]})}function Sales(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(providers.C,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(SalesApp,{})})})}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["9047"],{3897:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{O:()=>BrandLogo});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(243);function BrandLogo({domain,alt,size=24}){return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Image,{src:(0,_src_components_logoDev_ts__WEBPACK_IMPORTED_MODULE_2__.j)(domain),alt:alt,title:alt,w:size,h:size,fit:"contain",radius:"sm",style:{aspectRatio:1}})}},1354:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{m:()=>PageHeader});var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5893);var _mantine_core__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(207);var _tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(9632);var react__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3106);function formatRelative(now,then){const seconds=Math.max(0,Math.floor((now-then)/1e3));if(seconds<5)return"\xe0 l’instant";if(seconds<60)return`il y a ${seconds}s`;const minutes=Math.floor(seconds/60);if(minutes<60)return`il y a ${minutes} min`;const hours=Math.floor(minutes/60);return`il y a ${hours} h`}function PageHeader({title,leading,badge,updatedAt,isFetching,isError,onRefresh,actions}){const[now,setNow]=(0,react__WEBPACK_IMPORTED_MODULE_3__.useState)(()=>Date.now());(0,react__WEBPACK_IMPORTED_MODULE_3__.useEffect)(()=>{if(!updatedAt)return;const id=window.setInterval(()=>setNow(Date.now()),1e3);return()=>window.clearInterval(id)},[updatedAt]);const relative=updatedAt?formatRelative(now,updatedAt):null;const color=isError?"orange":isFetching?"teal":"dimmed";return/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{justify:"space-between",align:"center",mih:48,mb:"md",children:[/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[leading,/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Title,{order:2,children:title}),badge]}),/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Group,{gap:"sm",align:"center",children:[relative&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Text,{size:"xs",c:color,fw:isFetching?600:400,"data-testid":"page-header-freshness",children:isError?"\xe9chec maj":isFetching?"maj…":relative}),onRefresh&&/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.Tooltip,{label:"Rafra\xeechir",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_mantine_core__WEBPACK_IMPORTED_MODULE_1__.ActionIcon,{variant:"default",size:"md",onClick:onRefresh,loading:isFetching,"aria-label":"Refresh",children:/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tabler_icons_react__WEBPACK_IMPORTED_MODULE_2__.IconRefresh,{size:16})})}),actions]})]})}},243:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{j:()=>logoDevUrl});const LOGO_DEV_TOKEN="pk_BVN4OQv0Qs-bnqjdIgTppg";function logoDevUrl(domain){return`https://img.logo.dev/${domain}?token=${LOGO_DEV_TOKEN}`}},4126:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Scrapers});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 useScrapersQuery(){const api=(0,useApi.h)();const query=(0,modern_index_js_.useQuery)({queryKey:["tech","scrapers"],queryFn:async()=>await api.getScrapers().then(x=>x.data),refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true});return query}var PageHeader=__webpack_require__(1354);var BrandLogo=__webpack_require__(3897);function IconBraintree({color="currentColor",size=20,...props}){return/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:size,height:size,viewBox:"0 0 24 24",fill:color,xmlns:"http://www.w3.org/2000/svg",...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{d:"M8.276 20.482h4.717c3.641 0 5.462-1.2 5.462-3.517 0-2.275-1.945-3.517-5.752-3.517H8.276Zm0-16.965v6.538h4.138c3.103 0 4.717-1.159 4.717-3.269 0-2.152-1.655-3.269-4.759-3.269zM1.696 24v-3.518H4.47V3.517H1.697V0h11.089c5.09 0 8.193 2.358 8.193 6.455 0 2.69-1.572 4.345-3.558 5.131 2.855.787 4.882 2.814 4.882 5.586 0 4.386-3.393 6.828-8.938 6.828H1.697"})})}function ScraperCard({scraper,onClick}){const color=scraper.isTooOld?"red":"green";return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{withBorder:true,radius:"md",p:"md",style:{cursor:"pointer"},onClick:onClick,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",mb:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[null!==scraper.logoDomain?/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:scraper.logoDomain,alt:scraper.label}):/*#__PURE__*/(0,jsx_runtime.jsx)(IconBraintree,{size:24}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,children:scraper.label})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Badge,{color:color,variant:"light",children:[scraper.connectors.length," connecteur",1!==scraper.connectors.length?"s":""]})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fz:"sm",c:color,children:null!==scraper.lastDataDate?`Derni\xe8re donn\xe9e : ${scraper.lastDataDate}`:"Aucune donn\xe9e"})]})}function PennylaneCard({pennylane}){const color=pennylane.isTooOld?"red":"green";return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Card,{withBorder:true,radius:"md",p:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{justify:"space-between",mb:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Group,{gap:"xs",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:"pennylane.com",alt:"Pennylane"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{fw:700,children:"Pennylane"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:color,variant:"light",children:"Cookie"})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fz:"sm",c:color,children:["\uD83C\uDF6A Dernier refresh \xe0 ",pennylane.lastTime]})]})}function ScraperDetailDrawer({scraper,onClose}){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Drawer,{opened:null!==scraper,onClose:onClose,title:null!==scraper?/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:scraper.label}):null,position:"right",size:"md",children:null!==scraper?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"md",children:[null!==scraper.logoDomain?/*#__PURE__*/(0,jsx_runtime.jsx)(BrandLogo.O,{domain:scraper.logoDomain,alt:scraper.label,size:40}):/*#__PURE__*/(0,jsx_runtime.jsx)(IconBraintree,{size:40}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{fz:"sm",c:"dimmed",children:[scraper.connectors.length," connecteur",1!==scraper.connectors.length?"s":""]}),/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table,{striped:true,highlightOnHover:true,withTableBorder:true,withColumnBorders:true,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Thead,{children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Connecteur"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Client"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Derni\xe8re donn\xe9e"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Th,{children:"Statut"})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Tbody,{children:scraper.connectors.map(connector=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Table.Tr,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:connector.connector}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:connector.client??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:connector.lastDataDate??"—"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Table.Td,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:connector.isTooOld?"red":"green",fw:600,fz:"sm",children:connector.isTooOld?"Retard":"OK"})})]},connector.connector))})]})]}):null})}function ScrapersApp(){const query=useScrapersQuery();const[selected,setSelected]=(0,index_js_.useState)(null);return/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Container,{fluid:true,my:"md",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"lg",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(PageHeader.m,{title:"Scrapers",updatedAt:query.dataUpdatedAt,isFetching:query.isFetching,isError:query.isError,onRefresh:()=>query.refetch()}),query.data?/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:"xl",children:[/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,mb:"sm",children:"Connecteurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:{base:1,sm:2,md:3},spacing:"md",children:query.data.scrapers.map(scraper=>/*#__PURE__*/(0,jsx_runtime.jsx)(ScraperCard,{scraper:scraper,onClick:()=>setSelected(scraper)},scraper.key))})]}),/*#__PURE__*/(0,jsx_runtime.jsxs)("div",{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"xs",c:"dimmed",tt:"uppercase",fw:600,mb:"sm",children:"Monitoring Cookie"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SimpleGrid,{cols:{base:1,sm:2,md:3},spacing:"md",children:/*#__PURE__*/(0,jsx_runtime.jsx)(PennylaneCard,{pennylane:query.data.pennylane})})]})]}):/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{c:"dimmed",children:"Chargement…"})]}),/*#__PURE__*/(0,jsx_runtime.jsx)(ScraperDetailDrawer,{scraper:selected,onClose:()=>setSelected(null)})]})}function Scrapers(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)(ScrapersApp,{})})})}}}]);
@@ -1 +1 @@
1
- "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["509"],{466:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>useGsheetStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useGsheetStock(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","gsheet","stock"],queryFn:async()=>(await api.gsheet.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},3809:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Spreadsheet});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var QueueDashboard=__webpack_require__(2663);var index_mjs_=__webpack_require__(207);var gsheetStockQuery=__webpack_require__(466);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useGsheetTasks(filters){const api=(0,useApi.h)();const query={...filters.service&&{service:filters.service},...filters.owner&&{owner:filters.owner},...filters.state&&{state:filters.state},...void 0!==filters.take&&{take:String(filters.take)},...void 0!==filters.skip&&{skip:String(filters.skip)}};return(0,modern_index_js_.useQuery)({queryKey:["tech","gsheet","tasks",filters],queryFn:async()=>(await api.gsheet.listTasksV1(query)).data,refetchOnWindowFocus:false})}function useInvalidate(){const queryClient=(0,modern_index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","gsheet"]})}function useUnstickTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.unstickV1({id:String(id)})).data,onSuccess:invalidate})}function useDiscardTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.discardV1({id:String(id)})).data,onSuccess:invalidate})}function useSetTaskOwner(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async({id,owner})=>(await api.gsheet.setOwnerV1({id:String(id)},{owner})).data,onSuccess:invalidate})}function useDeleteRedisLock(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.deleteRedisLockV1({id:String(id)})).data,onSuccess:invalidate})}var jobLogsContext=__webpack_require__(6845);var tabler_icons_react_mjs_=__webpack_require__(9632);var esm_index_mjs_=__webpack_require__(1455);function grafanaUrl(traceId){return`https://airporting.grafana.net/d/beegyy3vsp8n4c/recipes?var-trace=${encodeURIComponent(traceId)}&orgId=1&from=now-7d&to=now&timezone=browser&showCategory=Logs&refresh=7d`}function notify(title,message,color){esm_index_mjs_.notifications.show({title,message,color})}function RowActions({taskId,currentOwner,spreadsheet,worksheet,githubJob,traceId,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=useUnstickTask();const discard=useDiscardTask();const setOwner=useSetTaskOwner();const deleteLock=useDeleteRedisLock();const runUnstick=()=>unstick.mutate(taskId,{onSuccess:()=>notify("Unstuck",`Task #${taskId} reset`,"green"),onError:e=>notify("Failed",e?.message??"Unstick 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:"GitHub Actions logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",onClick:()=>onShowLogs(githubJob),"aria-label":"GitHub Actions logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTerminal,{size:16})})}),traceId&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Grafana Loki logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{component:"a",href:grafanaUrl(traceId),target:"_blank",rel:"noopener noreferrer",variant:"subtle","aria-label":"Grafana Loki logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconFileText,{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:()=>{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:"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," (",spreadsheet,worksheet?`:${worksheet}`:"",") as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"done"})," with step=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". The task will not be processed by the runner."]}),/*#__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 the Redis running-lock for ",spreadsheet,worksheet?`:${worksheet}`:"",". The runner will be able to pick up the worksheet 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"})]})]})})]})}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"};function fmt(d){return d?new Date(d).toLocaleString("fr-FR"):"—"}function ageBadge(created){const h=(Date.now()-new Date(created).getTime())/36e5;if(h<1)return null;const label=h>=24?`${Math.floor(h/24)}j`:`${Math.floor(h)}h`;const color=h>=24?"red":h>=4?"orange":"gray";return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{ml:6,size:"xs",color:color,variant:"light",children:label})}function GsheetRowActions({item}){const openLogs=(0,jobLogsContext.j)();return/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:item.id,currentOwner:item.owner,spreadsheet:item.spreadsheet,worksheet:item.worksheet,githubJob:item.github_job,traceId:item.trace_id,onShowLogs:openLogs})}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 useGsheetConfig(){const unstick=useUnstickTask();const discard=useDiscardTask();const setOwner=useSetTaskOwner();const deleteLock=useDeleteRedisLock();return(0,index_js_.useMemo)(()=>({title:"Gsheet",source:{useStock:gsheetStockQuery.U,useTasks:({service,owner,state})=>useGsheetTasks({service:service??void 0,owner:owner??void 0,state,take:50})},initialFilters:{service:null,owner:null,state:"pending",search:""},kpis:[{key:"pending",label:"Pending",value:s=>s?.pending??0,filter:{state:"pending"}},{key:"running",label:"Running",value:s=>s?.running??0,filter:{state:"running"}},{key:"stuck",label:"Stuck",value:s=>s?.stuck??0,tone:s=>(s?.stuck??0)>0?"warn":"neutral",filter:{state:"stuck"}},{key:"errored",label:"Errored",value:s=>s?.errored??0,tone:s=>(s?.errored??0)>0?"bad":"neutral",filter:{state:"errored"}},{key:"done_today",label:"Done today",value:s=>s?.done_today??0,filter:{state:"done"}},{key:"oldest",label:"Oldest pending",value:s=>s?.oldest?`${s.oldest.ageHours}h`:"—"}],filters:[{kind:"select",key:"service",label:"Service",options:s=>(s?.byService??[]).map(e=>e.key),width:240},{kind:"select",key:"owner",label:"Owner",options:s=>(s?.byOwner??[]).map(e=>e.key),width:240},{kind:"select",key:"state",label:"State",options:()=>["pending","running","stuck","errored","done","all"],clearable:false,width:140},{kind:"search",key:"search",label:"Recherche",placeholder:"id, owner, spreadsheet…",width:240}],columns:[{key:"service",label:"Service",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.service})},{key:"spreadsheet",label:"Spreadsheet:Worksheet",render:t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:[t.spreadsheet,t.worksheet?`:${t.worksheet}`:""]})},{key:"owner",label:"Owner",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.owner??"—"})},{key:"state",label:"State",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]})},{key:"created",label:"Created",render:t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.created)}),ageBadge(t.created)]})}],rowActions:[{key:"actions",render:item=>/*#__PURE__*/(0,jsx_runtime.jsx)(GsheetRowActions,{item:item})}],bulkActions:[{key:"unstick",label:"Unstick",run:ids=>runBulk(ids,id=>unstick.mutateAsync(id))},{key:"set-owner",label:"Set owner…",prompt:{label:"Owner email",placeholder:"bob@airporting.com"},run:(ids,owner)=>{if(!owner)return Promise.resolve({ok:0,failed:ids.length});return runBulk(ids,id=>setOwner.mutateAsync({id,owner}))}},{key:"delete-lock",label:"Delete Redis lock",color:"orange",confirm:{title:"Delete Redis lock for {count} task(s)",body:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"fm-task-node-<id>",disabled:true,children:/*#__PURE__*/(0,jsx_runtime.jsxs)("span",{children:["Suppression du verrou Redis pour ","{count}"," t\xe2che(s)."]})})},run:ids=>runBulk(ids,id=>deleteLock.mutateAsync(id))},{key:"discard",label:"Discard",color:"red",confirm:{title:"Discard {count} task(s)",body:"Les t\xe2ches seront marqu\xe9es comme finished/discarded."},run:ids=>runBulk(ids,id=>discard.mutateAsync(id))}],getRowId:t=>t.id,searchMatches:(t,q)=>String(t.id).includes(q)||(t.owner??"").toLowerCase().includes(q)||(t.spreadsheet??"").toLowerCase().includes(q)||(t.worksheet??"").toLowerCase().includes(q)||(t.service??"").toLowerCase().includes(q)}),[unstick,discard,setOwner,deleteLock])}function SpreadsheetApp(){const config=useGsheetConfig();return/*#__PURE__*/(0,jsx_runtime.jsx)(QueueDashboard.r,{config:config})}function Spreadsheet(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)(SpreadsheetApp,{})})})}}}]);
1
+ "use strict";(globalThis["chunk_tech_app"]=globalThis["chunk_tech_app"]||[]).push([["509"],{466:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.d(__webpack_exports__,{U:()=>useGsheetStock});var _tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(6197);var _useApi__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(4148);function useGsheetStock(){const api=(0,_useApi__WEBPACK_IMPORTED_MODULE_1__.h)();return(0,_tanstack_react_query__WEBPACK_IMPORTED_MODULE_0__.useQuery)({queryKey:["tech","gsheet","stock"],queryFn:async()=>(await api.gsheet.getStockV1()).data,refetchInterval:3e4,refetchIntervalInBackground:false,refetchOnWindowFocus:true})}},3809:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Spreadsheet});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(3106);var providers=__webpack_require__(7034);var QueueDashboard=__webpack_require__(2663);var index_mjs_=__webpack_require__(207);var gsheetStockQuery=__webpack_require__(466);var modern_index_js_=__webpack_require__(6197);var useApi=__webpack_require__(4148);function useGsheetTasks(filters){const api=(0,useApi.h)();const query={...filters.service&&{service:filters.service},...filters.owner&&{owner:filters.owner},...filters.state&&{state:filters.state},...void 0!==filters.take&&{take:String(filters.take)},...void 0!==filters.skip&&{skip:String(filters.skip)}};return(0,modern_index_js_.useQuery)({queryKey:["tech","gsheet","tasks",filters],queryFn:async()=>(await api.gsheet.listTasksV1(query)).data,refetchOnWindowFocus:false})}function useInvalidate(){const queryClient=(0,modern_index_js_.useQueryClient)();return()=>queryClient.invalidateQueries({queryKey:["tech","gsheet"]})}function useUnstickTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.unstickV1({id:String(id)})).data,onSuccess:invalidate})}function useDiscardTask(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.discardV1({id:String(id)})).data,onSuccess:invalidate})}function useSetTaskOwner(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async({id,owner})=>(await api.gsheet.setOwnerV1({id:String(id)},{owner})).data,onSuccess:invalidate})}function useDeleteRedisLock(){const api=(0,useApi.h)();const invalidate=useInvalidate();return(0,modern_index_js_.useMutation)({mutationFn:async id=>(await api.gsheet.deleteRedisLockV1({id:String(id)})).data,onSuccess:invalidate})}var jobLogsContext=__webpack_require__(4302);var tabler_icons_react_mjs_=__webpack_require__(9632);var esm_index_mjs_=__webpack_require__(1455);function grafanaUrl(traceId){return`https://airporting.grafana.net/d/beegyy3vsp8n4c/recipes?var-trace=${encodeURIComponent(traceId)}&orgId=1&from=now-7d&to=now&timezone=browser&showCategory=Logs&refresh=7d`}function notify(title,message,color){esm_index_mjs_.notifications.show({title,message,color})}function RowActions({taskId,currentOwner,spreadsheet,worksheet,githubJob,traceId,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=useUnstickTask();const discard=useDiscardTask();const setOwner=useSetTaskOwner();const deleteLock=useDeleteRedisLock();const runUnstick=()=>unstick.mutate(taskId,{onSuccess:()=>notify("Unstuck",`Task #${taskId} reset`,"green"),onError:e=>notify("Failed",e?.message??"Unstick 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:"GitHub Actions logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{variant:"subtle",onClick:()=>onShowLogs(githubJob),"aria-label":"GitHub Actions logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconTerminal,{size:16})})}),traceId&&/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"Grafana Loki logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.ActionIcon,{component:"a",href:grafanaUrl(traceId),target:"_blank",rel:"noopener noreferrer",variant:"subtle","aria-label":"Grafana Loki logs",children:/*#__PURE__*/(0,jsx_runtime.jsx)(tabler_icons_react_mjs_.IconFileText,{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:()=>{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:"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," (",spreadsheet,worksheet?`:${worksheet}`:"",") as ",/*#__PURE__*/(0,jsx_runtime.jsx)("b",{children:"done"})," with step=",/*#__PURE__*/(0,jsx_runtime.jsx)("code",{children:"discarded"}),". The task will not be processed by the runner."]}),/*#__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 the Redis running-lock for ",spreadsheet,worksheet?`:${worksheet}`:"",". The runner will be able to pick up the worksheet 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"})]})]})})]})}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"};function fmt(d){return d?new Date(d).toLocaleString("fr-FR"):"—"}function ageBadge(created){const h=(Date.now()-new Date(created).getTime())/36e5;if(h<1)return null;const label=h>=24?`${Math.floor(h/24)}j`:`${Math.floor(h)}h`;const color=h>=24?"red":h>=4?"orange":"gray";return/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{ml:6,size:"xs",color:color,variant:"light",children:label})}function GsheetRowActions({item}){const openLogs=(0,jobLogsContext.j)();return/*#__PURE__*/(0,jsx_runtime.jsx)(RowActions,{taskId:item.id,currentOwner:item.owner,spreadsheet:item.spreadsheet,worksheet:item.worksheet,githubJob:item.github_job,traceId:item.trace_id,onShowLogs:openLogs})}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 useGsheetConfig(){const unstick=useUnstickTask();const discard=useDiscardTask();const setOwner=useSetTaskOwner();const deleteLock=useDeleteRedisLock();return(0,index_js_.useMemo)(()=>({title:"Gsheet",source:{useStock:gsheetStockQuery.U,useTasks:({service,owner,state})=>useGsheetTasks({service:service??void 0,owner:owner??void 0,state,take:50})},initialFilters:{service:null,owner:null,state:"pending",search:""},kpis:[{key:"pending",label:"Pending",value:s=>s?.pending??0,filter:{state:"pending"}},{key:"running",label:"Running",value:s=>s?.running??0,filter:{state:"running"}},{key:"stuck",label:"Stuck",value:s=>s?.stuck??0,tone:s=>(s?.stuck??0)>0?"warn":"neutral",filter:{state:"stuck"}},{key:"errored",label:"Errored",value:s=>s?.errored??0,tone:s=>(s?.errored??0)>0?"bad":"neutral",filter:{state:"errored"}},{key:"done_today",label:"Done today",value:s=>s?.done_today??0,filter:{state:"done"}},{key:"oldest",label:"Oldest pending",value:s=>s?.oldest?`${s.oldest.ageHours}h`:"—"}],filters:[{kind:"select",key:"service",label:"Service",options:s=>(s?.byService??[]).map(e=>e.key),width:240},{kind:"select",key:"owner",label:"Owner",options:s=>(s?.byOwner??[]).map(e=>e.key),width:240},{kind:"select",key:"state",label:"State",options:()=>["pending","running","stuck","errored","done","all"],clearable:false,width:140},{kind:"search",key:"search",label:"Recherche",placeholder:"id, owner, spreadsheet…",width:240}],columns:[{key:"service",label:"Service",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.service})},{key:"spreadsheet",label:"Spreadsheet:Worksheet",render:t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Text,{size:"sm",style:{wordBreak:"break-all"},children:[t.spreadsheet,t.worksheet?`:${t.worksheet}`:""]})},{key:"owner",label:"Owner",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:t.owner??"—"})},{key:"state",label:"State",render:t=>/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Badge,{color:STATE_COLORS[t.state],children:STATE_LABELS[t.state]})},{key:"created",label:"Created",render:t=>/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{size:"sm",children:fmt(t.created)}),ageBadge(t.created)]})}],rowActions:[{key:"actions",render:item=>/*#__PURE__*/(0,jsx_runtime.jsx)(GsheetRowActions,{item:item})}],bulkActions:[{key:"unstick",label:"Unstick",run:ids=>runBulk(ids,id=>unstick.mutateAsync(id))},{key:"set-owner",label:"Set owner…",prompt:{label:"Owner email",placeholder:"bob@airporting.com"},run:(ids,owner)=>{if(!owner)return Promise.resolve({ok:0,failed:ids.length});return runBulk(ids,id=>setOwner.mutateAsync({id,owner}))}},{key:"delete-lock",label:"Delete Redis lock",color:"orange",confirm:{title:"Delete Redis lock for {count} task(s)",body:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Tooltip,{label:"fm-task-node-<id>",disabled:true,children:/*#__PURE__*/(0,jsx_runtime.jsxs)("span",{children:["Suppression du verrou Redis pour ","{count}"," t\xe2che(s)."]})})},run:ids=>runBulk(ids,id=>deleteLock.mutateAsync(id))},{key:"discard",label:"Discard",color:"red",confirm:{title:"Discard {count} task(s)",body:"Les t\xe2ches seront marqu\xe9es comme finished/discarded."},run:ids=>runBulk(ids,id=>discard.mutateAsync(id))}],getRowId:t=>t.id,searchMatches:(t,q)=>String(t.id).includes(q)||(t.owner??"").toLowerCase().includes(q)||(t.spreadsheet??"").toLowerCase().includes(q)||(t.worksheet??"").toLowerCase().includes(q)||(t.service??"").toLowerCase().includes(q)}),[unstick,discard,setOwner,deleteLock])}function SpreadsheetApp(){const config=useGsheetConfig();return/*#__PURE__*/(0,jsx_runtime.jsx)(QueueDashboard.r,{config:config})}function Spreadsheet(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)(SpreadsheetApp,{})})})}}}]);