PageSourceSearch

https://vizops360.ai/assets/revenue.sync-C84BuzcB.js

js vizops360.ai collected 2026-10-05 13:51:13 UTC 9,320 bytes, 14 lines download raw bytes

1import{y as f,d4 as b,r as i,j as e,L as y,K as j,hf as N,as as o,n as v,be as w,J as l,ak as S}from"./index-CpeGhXo5.js";import{a as k,P as r}from"./Panel-Cf_wAUzv.js";import{u as C}from"./syncStatus-CzKeOsxO.js";const E=f("Unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]),L=[{v:"realtime",label:"Real-time"},{v:"15min",label:"Every 15 min"},{v:"1hour",label:"Every hour"},{v:"daily",label:"Daily"},{v:"manual",label:"Manual only"}],x=`function onEdit(e) {
2  const sheet = e.source.getActiveSheet();
3  if (sheet.getName() !== 'Revenue') return;
4  const row = e.range.getRow();
5  if (row === 1) return;
6  const values = sheet.getRange(row, 1, 1, sheet.getLastColumn()).getValues()[0];
7  const headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
8  const payload = Object.fromEntries(headers.map((h, i) => [h, values[i]]));
9  UrlFetchApp.fetch('https://api.finsight.app/webhook/revenue', {
10    method: 'post',
11    contentType: 'application/json',
12    payload: JSON.stringify({ row, data: payload, ts: new Date() })
13  });
14}`;function A(){const p=b(),s=C(),[a,m]=i.useState(""),[u,d]=i.useState(!1),[n,c]=i.useState(!1),h=async()=>{c(!0),await s.runSyncNow(),c(!1)},g=async()=>{await navigator.clipboard.writeText(x),d(!0),setTimeout(()=>d(!1),2e3)};return e.jsxs("div",{className:"p-3 flex flex-col gap-3 min-h-full overflow-auto",children:[e.jsx(k,{title:"Google Sheets Sync",subtitle:"Connect a Google account to keep Revenue data in sync",accent:"mod-revenue",actions:e.jsxs(y,{to:`${p}/revenue`,className:"h-7 px-2.5 rounded-[4px] border border-border bg-card hover:bg-accent text-[11px] font-medium inline-flex items-center gap-1.5",children:[e.jsx(j,{className:"w-3.5 h-3.5"})," Back"]})}),e.jsx(r,{title:"Connection",accent:"mod-revenue",children:s.connected?e.jsxs("div",{className:"p-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-semibold",children:s.email}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Connected · scopes: spreadsheets.readonly, spreadsheets"})]})]}),e.jsxs("button",{onClick:s.disconnect,className:"h-7 px-2.5 rounded-[4px] border border-border hover:bg-destructive/10 hover:text-destructive text-[11px] inline-flex items-center gap-1.5",children:[e.jsx(E,{className:"w-3.5 h-3.5"})," Disconnect"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[11px] font-medium text-foreground/70",children:"Sheet URL"}),e.jsx("input",{value:s.sheetUrl,onChange:t=>s.setSheet(t.target.value,s.sheetName),placeholder:"https://docs.google.com/spreadsheets/d/…",className:"h-8 px-2 w-full rounded-[4px] border border-border bg-background text-[12px] focus:outline-none focus:ring-1 focus:ring-primary"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[11px] font-medium text-foreground/70",children:"Worksheet name"}),e.jsx("input",{value:s.sheetName,onChange:t=>s.setSheet(s.sheetUrl,t.target.value),className:"h-8 px-2 w-full rounded-[4px] border border-border bg-background text-[12px] focus:outline-none focus:ring-1 focus:ring-primary"})]})]})]}):e.jsxs("div",{className:"p-2 space-y-3",children:[e.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Sign in with Google to authorize FinSight to read & write your spreadsheet. (Demo: enter any email.)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"email",value:a,onChange:t=>m(t.target.value),placeholder:"[email protected]",className:"h-8 px-2 w-72 rounded-[4px] border border-border bg-background text-[12px] focus:outline-none focus:ring-1 focus:ring-primary"}),e.jsxs("button",{disabled:!a.includes("@"),onClick:()=>s.connect(a),className:"h-8 px-3 rounded-[4px] bg-primary text-primary-foreground text-[12px] font-medium inline-flex items-center gap-1.5 disabled:opacity-40",children:[e.jsx(N,{className:"w-3.5 h-3.5"})," Connect with Google"]})]})]})}),s.connected&&e.jsxs(e.Fragment,{children:[e.jsxs(r,{title:"Sync Settings",accent:"mod-revenue",children:[e.jsxs("div",{className:"p-2 grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground
14/70 mb-1.5",children:"Sync frequency"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:L.map(t=>e.jsx("button",{onClick:()=>s.setFrequency(t.v),className:o("h-7 px-2.5 rounded-full text-[11px] font-medium border",s.frequency===t.v?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:bg-accent"),children:t.label},t.v))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] font-medium text-foreground/70 mb-1.5",children:"Direction"}),e.jsx("div",{className:"flex gap-1.5",children:["one-way","two-way"].map(t=>e.jsx("button",{onClick:()=>s.setDirection(t),className:o("h-7 px-3 rounded-full text-[11px] font-medium border",s.direction===t?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:bg-accent"),children:t==="one-way"?"Sheets → FinSight":"Two-way (Sheets ↔ FinSight)"},t))})]})]}),e.jsxs("div",{className:"px-2 pt-2 pb-1 flex items-center justify-between border-t border-border mt-2",children:[e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Last sync:"," ",e.jsx("span",{className:"font-data text-foreground",children:s.lastSyncAt?new Date(s.lastSyncAt).toLocaleString():"Never"})]}),e.jsxs("button",{onClick:h,disabled:n,className:"h-8 px-3 rounded-[4px] bg-primary text-primary-foreground text-[12px] font-medium inline-flex items-center gap-1.5 disabled:opacity-40",children:[e.jsx(v,{className:o("w-3.5 h-3.5",n&&"animate-spin")}),n?"Syncing…":"Sync now"]})]})]}),e.jsx(r,{title:"Apps Script (real-time webhook)",accent:"mod-revenue",right:e.jsxs("button",{onClick:g,className:"h-7 px-2.5 rounded-[4px] border border-border bg-card hover:bg-accent text-[11px] inline-flex items-center gap-1.5",children:[e.jsx(w,{className:"w-3.5 h-3.5"})," ",u?"Copied!":"Copy script"]}),children:e.jsxs("div",{className:"p-1 space-y-2",children:[e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Paste this in your Sheet's Extensions → Apps Script to push edits to FinSight in real time."}),e.jsx("pre",{className:"text-[10.5px] font-data bg-muted/60 border border-border rounded-[4px] p-2 overflow-auto leading-relaxed",children:x})]})}),e.jsx(r,{title:"Sync History (last 10)",accent:"mod-revenue",children:e.jsx("div",{className:"p-1",children:s.history.length===0?e.jsx("div",{className:"text-center text-[11px] text-muted-foreground py-6",children:'No sync runs yet. Click "Sync now" to trigger your first run.'}):e.jsx("div",{className:"border border-border rounded-[4px] overflow-hidden",children:e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{className:"bg-muted/60",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-2 py-1.5 font-semibold text-[10px] uppercase tracking-wider text-muted-foreground",children:"When"}),e.jsx("th",{className:"text-left px-2 py-1.5 font-semibold text-[10px] uppercase tracking-wider text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-right px-2 py-1.5 font-semibold text-[10px] uppercase tracking-wider text-muted-foreground",children:"Added"}),e.jsx("th",{className:"text-right px-2 py-1.5 font-semibold text-[10px] uppercase tracking-wider text-muted-foreground",children:"Updated"}),e.jsx("th",{className:"text-right px-2 py-1.5 font-semibold text-[10px] uppercase tracking-wider text-muted-foreground",children:"Skipped"}),e.jsx("th",{className:"text-left px-2 py-1.5 font-semibold text-[10px] uppercase tracking-wider text-muted-foreground",children:"Note"})]})}),e.jsx("tbody",{children:s.history.map(t=>e.jsxs("tr",{className:"border-t border-border",children:[e.jsx("td",{className:"px-2 py-1 font-data",children:new Date(t.at).toLocaleString()}),e.jsxs("td",{className:"px-2 py-1",children:[t.status==="success"&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-600",children:[e.jsx(l,{className:"w-3 h-3"})," Success"]}),t.status==="partial"&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",children:[e.jsx(l,{className:"w-3 h-3"})," Partial"]}),t.status==="error"&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[e.jsx(S,{className:"w-3 h-3"})," Error"]})]}),e.jsx("td",{className:"px-2 py-1 text-right font-data",children:t.added}),e.jsx("td",{className:"px-2 py-1 text-right font-data",children:t.updated}),e.jsx("td",{className:"px-2 py-1 text-right font-data",children:t.skipped}),e.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:t.message??"—"})]},t.id))})]})})})})]})]})}export{A as SyncPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.