@hanzo/dev 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/{BinaryViewer-qn8xfPZp.js → BinaryViewer-CmFUK4zZ.js} +2 -2
- package/dist/{ChatMarkdown-Cyujn3JJ.js → ChatMarkdown-nvEI7iCv.js} +4 -4
- package/dist/{DiffCommentAnnotation-BZu1TP6E.js → DiffCommentAnnotation-BPTN_2a6.js} +1 -1
- package/dist/{DiffFileTree-CcJ91zOM.js → DiffFileTree-B_br90vY.js} +2 -2
- package/dist/{DiffPanel-BXC88NMs.js → DiffPanel-V5R5TPuK.js} +5 -5
- package/dist/{ExpandedImageDialog-BZnGRBJR.js → ExpandedImageDialog-CAorLacL.js} +1 -1
- package/dist/{FileExplorerPane-vBJS6V75.js → FileExplorerPane-CeHulcPz.js} +1 -1
- package/dist/{FilePreviewPanel-jJHWsMzm.js → FilePreviewPanel-BVNLvWOc.js} +8 -8
- package/dist/{MermaidDiagram-paNwQY33.js → MermaidDiagram-CTolIzQD.js} +1 -1
- package/dist/{MermaidFilePreview-B9KxfnIN.js → MermaidFilePreview-CP2zP4FU.js} +1 -1
- package/dist/{MermaidViewer-CAEGpLyD.js → MermaidViewer-BDfYkS9E.js} +2 -2
- package/dist/{NotebookPreview-D01mMCpR.js → NotebookPreview-Cybs5uM0.js} +1 -1
- package/dist/{OfficeFilePreview-DWaRgfQU.js → OfficeFilePreview-7JsmSoKU.js} +1 -1
- package/dist/{OfficeViewer-BudrZbBA.js → OfficeViewer-CJoojlJK.js} +1 -1
- package/dist/{OpenInPicker-Dd3ifHa1.js → OpenInPicker-BIMWUxBP.js} +7 -7
- package/dist/{OpenXmlOfficeViewer-CXcKdq7k.js → OpenXmlOfficeViewer-C24Kj8DM.js} +1 -1
- package/dist/{PreviewImage-C4Ku4z7v.js → PreviewImage-oY5YnuTr.js} +1 -1
- package/dist/{PreviewImageContent-BwOB9Lyd.js → PreviewImageContent-n6eLzY99.js} +1 -1
- package/dist/{PullRequestCodeTab-BcwyMk7d.js → PullRequestCodeTab-Dv_0kVad.js} +7 -7
- package/dist/{PullRequestReviewAnnotation-BU5t_1fC.js → PullRequestReviewAnnotation-LeuwO-iH.js} +4 -4
- package/dist/builder/activity.d.ts +16 -0
- package/dist/builder/activity.js +51 -0
- package/dist/builder/address.d.ts +11 -0
- package/dist/builder/address.js +50 -0
- package/dist/builder/ago.d.ts +2 -0
- package/dist/builder/ago.js +18 -0
- package/dist/builder/api/agents.d.ts +139 -0
- package/dist/builder/api/agents.js +253 -0
- package/dist/builder/api/auto.d.ts +166 -0
- package/dist/builder/api/auto.js +300 -0
- package/dist/builder/api/billing.d.ts +263 -0
- package/dist/builder/api/billing.js +401 -0
- package/dist/builder/api/call.d.ts +53 -0
- package/dist/builder/api/call.js +123 -0
- package/dist/builder/api/capabilities.d.ts +14 -0
- package/dist/builder/api/capabilities.js +41 -0
- package/dist/builder/api/changes.d.ts +74 -0
- package/dist/builder/api/changes.js +75 -0
- package/dist/builder/api/chat.d.ts +12 -0
- package/dist/builder/api/chat.js +28 -0
- package/dist/builder/api/cli.d.ts +59 -0
- package/dist/builder/api/cli.js +133 -0
- package/dist/builder/api/codebases.d.ts +46 -0
- package/dist/builder/api/codebases.js +100 -0
- package/dist/builder/api/coding.d.ts +117 -0
- package/dist/builder/api/coding.js +222 -0
- package/dist/builder/api/connectors.d.ts +76 -0
- package/dist/builder/api/connectors.js +111 -0
- package/dist/builder/api/consent.d.ts +22 -0
- package/dist/builder/api/consent.js +28 -0
- package/dist/builder/api/conversations.d.ts +20 -0
- package/dist/builder/api/conversations.js +23 -0
- package/dist/builder/api/draft.d.ts +38 -0
- package/dist/builder/api/draft.js +87 -0
- package/dist/builder/api/environment.d.ts +55 -0
- package/dist/builder/api/environment.js +126 -0
- package/dist/builder/api/gallery.d.ts +32 -0
- package/dist/builder/api/gallery.js +85 -0
- package/dist/builder/api/git.d.ts +59 -0
- package/dist/builder/api/git.js +117 -0
- package/dist/builder/api/github.d.ts +230 -0
- package/dist/builder/api/github.js +373 -0
- package/dist/builder/api/keys.d.ts +35 -0
- package/dist/builder/api/keys.js +72 -0
- package/dist/builder/api/library.d.ts +116 -0
- package/dist/builder/api/library.js +214 -0
- package/dist/builder/api/limits.d.ts +69 -0
- package/dist/builder/api/limits.js +86 -0
- package/dist/builder/api/links.d.ts +51 -0
- package/dist/builder/api/links.js +75 -0
- package/dist/builder/api/machines.d.ts +122 -0
- package/dist/builder/api/machines.js +238 -0
- package/dist/builder/api/mcp.d.ts +10 -0
- package/dist/builder/api/mcp.js +47 -0
- package/dist/builder/api/members.d.ts +35 -0
- package/dist/builder/api/members.js +95 -0
- package/dist/builder/api/memory.d.ts +14 -0
- package/dist/builder/api/memory.js +35 -0
- package/dist/builder/api/models.d.ts +17 -0
- package/dist/builder/api/models.js +20 -0
- package/dist/builder/api/places.d.ts +32 -0
- package/dist/builder/api/places.js +29 -0
- package/dist/builder/api/platform.d.ts +68 -0
- package/dist/builder/api/platform.js +87 -0
- package/dist/builder/api/plugins.d.ts +42 -0
- package/dist/builder/api/plugins.js +175 -0
- package/dist/builder/api/pref.d.ts +77 -0
- package/dist/builder/api/pref.js +93 -0
- package/dist/builder/api/profile.d.ts +11 -0
- package/dist/builder/api/profile.js +41 -0
- package/dist/builder/api/projects.d.ts +99 -0
- package/dist/builder/api/projects.js +166 -0
- package/dist/builder/api/provider.d.ts +49 -0
- package/dist/builder/api/provider.js +96 -0
- package/dist/builder/api/sandbox.d.ts +90 -0
- package/dist/builder/api/sandbox.js +223 -0
- package/dist/builder/api/sessions.d.ts +123 -0
- package/dist/builder/api/sessions.js +255 -0
- package/dist/builder/api/skills.d.ts +82 -0
- package/dist/builder/api/skills.js +117 -0
- package/dist/builder/api/sse.d.ts +24 -0
- package/dist/builder/api/sse.js +68 -0
- package/dist/builder/api/studio.d.ts +59 -0
- package/dist/builder/api/studio.js +91 -0
- package/dist/builder/api/talk.d.ts +48 -0
- package/dist/builder/api/talk.js +81 -0
- package/dist/builder/api/tools.d.ts +34 -0
- package/dist/builder/api/tools.js +37 -0
- package/dist/builder/api/turn.d.ts +202 -0
- package/dist/builder/api/turn.js +772 -0
- package/dist/builder/api/verdict.d.ts +3 -0
- package/dist/builder/api/verdict.js +21 -0
- package/dist/builder/api/webhooks.d.ts +47 -0
- package/dist/builder/api/webhooks.js +82 -0
- package/dist/builder/api/work.d.ts +110 -0
- package/dist/builder/api/work.js +218 -0
- package/dist/builder/ask.d.ts +51 -0
- package/dist/builder/ask.js +147 -0
- package/dist/builder/automations.d.ts +33 -0
- package/dist/builder/automations.js +453 -0
- package/dist/builder/awake.d.ts +24 -0
- package/dist/builder/awake.js +68 -0
- package/dist/builder/back.d.ts +30 -0
- package/dist/builder/back.js +105 -0
- package/dist/builder/builder.d.ts +12 -0
- package/dist/builder/builder.js +162 -0
- package/dist/builder/carry.d.ts +48 -0
- package/dist/builder/carry.js +278 -0
- package/dist/builder/choice.d.ts +134 -0
- package/dist/builder/choice.js +152 -0
- package/dist/builder/claims.d.ts +13 -0
- package/dist/builder/claims.js +35 -0
- package/dist/builder/clipboard.d.ts +2 -0
- package/dist/builder/clipboard.js +10 -0
- package/dist/builder/customize/agents.d.ts +11 -0
- package/dist/builder/customize/agents.js +513 -0
- package/dist/builder/customize/connectors.d.ts +2 -0
- package/dist/builder/customize/connectors.js +319 -0
- package/dist/builder/customize/drafted.d.ts +4 -0
- package/dist/builder/customize/drafted.js +92 -0
- package/dist/builder/customize/index.d.ts +8 -0
- package/dist/builder/customize/index.js +127 -0
- package/dist/builder/customize/inventory.d.ts +14 -0
- package/dist/builder/customize/inventory.js +127 -0
- package/dist/builder/customize/load.d.ts +9 -0
- package/dist/builder/customize/load.js +22 -0
- package/dist/builder/customize/ocean.d.ts +41 -0
- package/dist/builder/customize/ocean.js +332 -0
- package/dist/builder/customize/plugins.d.ts +2 -0
- package/dist/builder/customize/plugins.js +136 -0
- package/dist/builder/customize/roles.d.ts +4 -0
- package/dist/builder/customize/roles.js +105 -0
- package/dist/builder/customize/say.d.ts +13 -0
- package/dist/builder/customize/say.js +32 -0
- package/dist/builder/customize/skills.d.ts +2 -0
- package/dist/builder/customize/skills.js +208 -0
- package/dist/builder/customize/ui.d.ts +152 -0
- package/dist/builder/customize/ui.js +208 -0
- package/dist/builder/data.d.ts +57 -0
- package/dist/builder/data.js +322 -0
- package/dist/builder/design.d.ts +140 -0
- package/dist/builder/design.js +175 -0
- package/dist/builder/desk.d.ts +48 -0
- package/dist/builder/desk.js +449 -0
- package/dist/builder/dev-mode.d.ts +43 -0
- package/dist/builder/dev-mode.js +120 -0
- package/dist/builder/door.d.ts +11 -0
- package/dist/builder/door.js +126 -0
- package/dist/builder/environment.d.ts +23 -0
- package/dist/builder/environment.js +193 -0
- package/dist/builder/files.d.ts +23 -0
- package/dist/builder/files.js +175 -0
- package/dist/builder/find.d.ts +7 -0
- package/dist/builder/find.js +80 -0
- package/dist/builder/foot.d.ts +30 -0
- package/dist/builder/foot.js +79 -0
- package/dist/builder/forge.d.ts +4 -0
- package/dist/builder/forge.js +639 -0
- package/dist/builder/gear.d.ts +60 -0
- package/dist/builder/gear.js +180 -0
- package/dist/builder/git.d.ts +21 -0
- package/dist/builder/git.js +118 -0
- package/dist/builder/github-sync.d.ts +70 -0
- package/dist/builder/github-sync.js +435 -0
- package/dist/builder/gutter.d.ts +17 -0
- package/dist/builder/gutter.js +25 -0
- package/dist/builder/handoff.d.ts +8 -0
- package/dist/builder/handoff.js +22 -0
- package/dist/builder/host.d.ts +189 -0
- package/dist/builder/host.js +46 -0
- package/dist/builder/index.d.ts +108 -0
- package/dist/builder/index.js +99 -0
- package/dist/builder/landing.d.ts +34 -0
- package/dist/builder/landing.js +725 -0
- package/dist/builder/library.d.ts +21 -0
- package/dist/builder/library.js +526 -0
- package/dist/builder/local.d.ts +80 -0
- package/dist/builder/local.js +124 -0
- package/dist/builder/make.d.ts +10 -0
- package/dist/builder/make.js +120 -0
- package/dist/builder/markdown.d.ts +49 -0
- package/dist/builder/markdown.js +125 -0
- package/dist/builder/marks.d.ts +15 -0
- package/dist/builder/marks.js +18 -0
- package/dist/builder/merge.d.ts +223 -0
- package/dist/builder/merge.js +380 -0
- package/dist/builder/meter.d.ts +31 -0
- package/dist/builder/meter.js +54 -0
- package/dist/builder/mind.d.ts +107 -0
- package/dist/builder/mind.js +335 -0
- package/dist/builder/names.d.ts +40 -0
- package/dist/builder/names.js +189 -0
- package/dist/builder/nav.d.ts +28 -0
- package/dist/builder/nav.js +218 -0
- package/dist/builder/out.d.ts +16 -0
- package/dist/builder/out.js +24 -0
- package/dist/builder/page.d.ts +55 -0
- package/dist/builder/page.js +217 -0
- package/dist/builder/pane.d.ts +30 -0
- package/dist/builder/pane.js +21 -0
- package/dist/builder/panel.d.ts +101 -0
- package/dist/builder/panel.js +408 -0
- package/dist/builder/pdf.d.ts +139 -0
- package/dist/builder/pdf.js +847 -0
- package/dist/builder/pick.d.ts +10 -0
- package/dist/builder/pick.js +38 -0
- package/dist/builder/plain.d.ts +59 -0
- package/dist/builder/plain.js +209 -0
- package/dist/builder/plan.d.ts +63 -0
- package/dist/builder/plan.js +155 -0
- package/dist/builder/plans.d.ts +1 -0
- package/dist/builder/plans.js +157 -0
- package/dist/builder/plugin.d.ts +60 -0
- package/dist/builder/plugin.js +1 -0
- package/dist/builder/plugins/design.d.ts +8 -0
- package/dist/builder/plugins/design.js +71 -0
- package/dist/builder/plugins/index.d.ts +46 -0
- package/dist/builder/plugins/index.js +117 -0
- package/dist/builder/plugins/pdf.d.ts +18 -0
- package/dist/builder/plugins/pdf.js +83 -0
- package/dist/builder/plugins/project.d.ts +5 -0
- package/dist/builder/plugins/project.js +68 -0
- package/dist/builder/plugins/research.d.ts +24 -0
- package/dist/builder/plugins/research.js +147 -0
- package/dist/builder/plugins/sketch.d.ts +9 -0
- package/dist/builder/plugins/sketch.js +101 -0
- package/dist/builder/plugins/slides.d.ts +14 -0
- package/dist/builder/plugins/slides.js +55 -0
- package/dist/builder/plugins/template.d.ts +13 -0
- package/dist/builder/plugins/template.js +95 -0
- package/dist/builder/prefs.d.ts +29 -0
- package/dist/builder/prefs.js +91 -0
- package/dist/builder/preview-url.d.ts +47 -0
- package/dist/builder/preview-url.js +107 -0
- package/dist/builder/project.d.ts +18 -0
- package/dist/builder/project.js +604 -0
- package/dist/builder/prose.d.ts +4 -0
- package/dist/builder/prose.js +57 -0
- package/dist/builder/publish.d.ts +18 -0
- package/dist/builder/publish.js +141 -0
- package/dist/builder/question.d.ts +33 -0
- package/dist/builder/question.js +64 -0
- package/dist/builder/redesign.d.ts +32 -0
- package/dist/builder/redesign.js +117 -0
- package/dist/builder/removal.d.ts +71 -0
- package/dist/builder/removal.js +73 -0
- package/dist/builder/reply.d.ts +50 -0
- package/dist/builder/reply.js +196 -0
- package/dist/builder/roles.d.ts +10 -0
- package/dist/builder/roles.js +28 -0
- package/dist/builder/route.d.ts +85 -0
- package/dist/builder/route.js +126 -0
- package/dist/builder/run.d.ts +4 -0
- package/dist/builder/run.js +804 -0
- package/dist/builder/runmeta.d.ts +16 -0
- package/dist/builder/runmeta.js +69 -0
- package/dist/builder/say.d.ts +2 -0
- package/dist/builder/say.js +7 -0
- package/dist/builder/scheduled.d.ts +3 -0
- package/dist/builder/scheduled.js +328 -0
- package/dist/builder/section.d.ts +27 -0
- package/dist/builder/section.js +60 -0
- package/dist/builder/settings/account.d.ts +1 -0
- package/dist/builder/settings/account.js +111 -0
- package/dist/builder/settings/billing.d.ts +1 -0
- package/dist/builder/settings/billing.js +210 -0
- package/dist/builder/settings/capabilities.d.ts +1 -0
- package/dist/builder/settings/capabilities.js +66 -0
- package/dist/builder/settings/card.d.ts +31 -0
- package/dist/builder/settings/card.js +140 -0
- package/dist/builder/settings/code.d.ts +1 -0
- package/dist/builder/settings/code.js +70 -0
- package/dist/builder/settings/credits.d.ts +10 -0
- package/dist/builder/settings/credits.js +123 -0
- package/dist/builder/settings/environments.d.ts +1 -0
- package/dist/builder/settings/environments.js +60 -0
- package/dist/builder/settings/general.d.ts +1 -0
- package/dist/builder/settings/general.js +58 -0
- package/dist/builder/settings/index.d.ts +4 -0
- package/dist/builder/settings/index.js +25 -0
- package/dist/builder/settings/integrations.d.ts +8 -0
- package/dist/builder/settings/integrations.js +138 -0
- package/dist/builder/settings/keys.d.ts +1 -0
- package/dist/builder/settings/keys.js +114 -0
- package/dist/builder/settings/list.d.ts +10 -0
- package/dist/builder/settings/list.js +28 -0
- package/dist/builder/settings/machines.d.ts +4 -0
- package/dist/builder/settings/machines.js +243 -0
- package/dist/builder/settings/members.d.ts +1 -0
- package/dist/builder/settings/members.js +77 -0
- package/dist/builder/settings/memory.d.ts +1 -0
- package/dist/builder/settings/memory.js +62 -0
- package/dist/builder/settings/notifications.d.ts +1 -0
- package/dist/builder/settings/notifications.js +111 -0
- package/dist/builder/settings/plan.d.ts +17 -0
- package/dist/builder/settings/plan.js +131 -0
- package/dist/builder/settings/privacy.d.ts +1 -0
- package/dist/builder/settings/privacy.js +76 -0
- package/dist/builder/settings/sections.d.ts +16 -0
- package/dist/builder/settings/sections.js +34 -0
- package/dist/builder/settings/shared.d.ts +6 -0
- package/dist/builder/settings/shared.js +58 -0
- package/dist/builder/settings/ui.d.ts +50 -0
- package/dist/builder/settings/ui.js +53 -0
- package/dist/builder/settings/usage.d.ts +1 -0
- package/dist/builder/settings/usage.js +24 -0
- package/dist/builder/shared.d.ts +26 -0
- package/dist/builder/shared.js +15 -0
- package/dist/builder/shelf.d.ts +16 -0
- package/dist/builder/shelf.js +219 -0
- package/dist/builder/side.d.ts +40 -0
- package/dist/builder/side.js +208 -0
- package/dist/builder/site.d.ts +75 -0
- package/dist/builder/site.js +138 -0
- package/dist/builder/spend.d.ts +21 -0
- package/dist/builder/spend.js +80 -0
- package/dist/builder/standing.d.ts +36 -0
- package/dist/builder/standing.js +66 -0
- package/dist/builder/suggest.d.ts +238 -0
- package/dist/builder/suggest.js +463 -0
- package/dist/builder/suggestions.d.ts +49 -0
- package/dist/builder/suggestions.js +260 -0
- package/dist/builder/summary.d.ts +60 -0
- package/dist/builder/summary.js +81 -0
- package/dist/builder/sync.d.ts +1 -0
- package/dist/builder/sync.js +187 -0
- package/dist/builder/tabs.d.ts +85 -0
- package/dist/builder/tabs.js +288 -0
- package/dist/builder/talk.d.ts +5 -0
- package/dist/builder/talk.js +108 -0
- package/dist/builder/thread.d.ts +60 -0
- package/dist/builder/thread.js +302 -0
- package/dist/builder/tools.d.ts +22 -0
- package/dist/builder/tools.js +52 -0
- package/dist/builder/transcript.d.ts +47 -0
- package/dist/builder/transcript.js +108 -0
- package/dist/builder/voice.d.ts +8 -0
- package/dist/builder/voice.js +24 -0
- package/dist/{changedFileKind-DqgCCDUs.js → changedFileKind-D6QYvIez.js} +1 -1
- package/dist/core.js +1 -0
- package/dist/{decodeImagePreview-CesVZYP4.js → decodeImagePreview-DnfFEjhw.js} +1 -1
- package/dist/{embed-DYP-OUlb.js → embed-c030vUqM.js} +11 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/{micromark-util-decode-string-NQjVkmZH.js → micromark-util-decode-string-C-5AXkOV.js} +5 -3
- package/dist/{readBinaryPreview-D2X4Uahu.js → readBinaryPreview-BAQ4fFjm.js} +1 -1
- package/dist/{useTextFieldSpeech-CyOZZPrV.js → useTextFieldSpeech-COa9XcRx.js} +1 -1
- package/package.json +101 -11
- /package/{index.d.ts → dist/core.d.ts} +0 -0
- /package/{keymap.d.ts → dist/keymap.d.ts} +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Account: who is signed in and how Hanzo should know them — the photo and
|
|
4
|
+
* full name on their Hanzo identity, what to call them, what they work on and
|
|
5
|
+
* the instructions every coding run reads — then the organizations they belong
|
|
6
|
+
* to, the one this page acts in, a way to act in another, and logging out.
|
|
7
|
+
*
|
|
8
|
+
* The email is how the person signs in, so it is shown and not edited here.
|
|
9
|
+
*
|
|
10
|
+
* Its words are the reader's language (@hanzo/i18n `t`); a name, an email and
|
|
11
|
+
* an organization's id are drawn as given.
|
|
12
|
+
*/
|
|
13
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
14
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
15
|
+
import { Check, Copy, LogOut } from '@hanzogui/lucide-icons-2';
|
|
16
|
+
import { Button, Input, Textarea } from '@hanzo/ui';
|
|
17
|
+
import { ChipSelect } from '@hanzo/ui/product';
|
|
18
|
+
import { useEffect, useRef, useState } from 'react';
|
|
19
|
+
import { told } from '../api/call.js';
|
|
20
|
+
import { PHOTO, photo, rename } from '../api/profile.js';
|
|
21
|
+
import { copy } from '../clipboard.js';
|
|
22
|
+
import { useHost, useTarget } from '../host.js';
|
|
23
|
+
import { usePrefs } from '../prefs.js';
|
|
24
|
+
import { WORK } from '../roles.js';
|
|
25
|
+
import { Card, Field, Group, Heading, Note, Row, Soft } from './ui.js';
|
|
26
|
+
/** Long enough for real guidance, short enough to sit in the settings document beside everything else. */
|
|
27
|
+
const INSTRUCTIONS = 3000;
|
|
28
|
+
export function Account() {
|
|
29
|
+
const { t } = useI18n();
|
|
30
|
+
const host = useHost();
|
|
31
|
+
const target = useTarget();
|
|
32
|
+
const { prefs, save } = usePrefs();
|
|
33
|
+
const who = host.person;
|
|
34
|
+
const [name, setName] = useState(who?.name ?? '');
|
|
35
|
+
const [shownName, setShownName] = useState(who?.name ?? '');
|
|
36
|
+
const [face, setFace] = useState(who?.avatar ?? '');
|
|
37
|
+
const [callName, setCallName] = useState('');
|
|
38
|
+
const [work, setWork] = useState('');
|
|
39
|
+
const [instructions, setInstructions] = useState('');
|
|
40
|
+
const [busy, setBusy] = useState(false);
|
|
41
|
+
const [note, setNote] = useState('');
|
|
42
|
+
const picker = useRef(null);
|
|
43
|
+
const [copied, setCopied] = useState(false);
|
|
44
|
+
// The identity can arrive after the page does.
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
setName(who?.name ?? '');
|
|
47
|
+
setShownName(who?.name ?? '');
|
|
48
|
+
setFace(who?.avatar ?? '');
|
|
49
|
+
}, [who?.name, who?.avatar]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
setCallName(prefs.callName ?? '');
|
|
52
|
+
setWork(prefs.work ?? '');
|
|
53
|
+
setInstructions(prefs.instructions ?? '');
|
|
54
|
+
}, [prefs.callName, prefs.work, prefs.instructions]);
|
|
55
|
+
if (!who) {
|
|
56
|
+
return (_jsxs(YStack, { gap: "$5", children: [_jsx(Heading, { title: t('Account') }), _jsx(Soft, { children: t('Sign in to see your account.') }), host.signIn ? (_jsx(XStack, { justify: "center", children: _jsx(Button, { size: "sm", onPress: () => host.signIn?.(), children: t('Sign in') }) })) : null] }));
|
|
57
|
+
}
|
|
58
|
+
const patch = {};
|
|
59
|
+
if (callName.trim() !== (prefs.callName ?? ''))
|
|
60
|
+
patch.callName = callName.trim() || null;
|
|
61
|
+
// A work is only ever chosen from the list, never emptied.
|
|
62
|
+
if (work !== (prefs.work ?? ''))
|
|
63
|
+
patch.work = work;
|
|
64
|
+
if (instructions.trim() !== (prefs.instructions ?? '').trim())
|
|
65
|
+
patch.instructions = instructions.trim() || null;
|
|
66
|
+
const renamed = name.trim() !== shownName.trim();
|
|
67
|
+
const changed = renamed || Object.keys(patch).length > 0;
|
|
68
|
+
const submit = async () => {
|
|
69
|
+
setBusy(true);
|
|
70
|
+
setNote('');
|
|
71
|
+
try {
|
|
72
|
+
if (renamed)
|
|
73
|
+
setShownName((await rename(target, name)).displayName || name.trim());
|
|
74
|
+
if (Object.keys(patch).length)
|
|
75
|
+
await save(patch);
|
|
76
|
+
setNote(t('Saved'));
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
setNote(told(e, t));
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
setBusy(false);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const upload = async (file) => {
|
|
86
|
+
setBusy(true);
|
|
87
|
+
setNote('');
|
|
88
|
+
try {
|
|
89
|
+
setFace(await photo(target, file));
|
|
90
|
+
setNote(t('Your photo is saved'));
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
setNote(told(e, t));
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
setBusy(false);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const org = host.org;
|
|
100
|
+
const orgs = host.memberships ?? (org ? [org] : []);
|
|
101
|
+
// The list's words in the reader's language; a work the list does not hold is the person's own, as given.
|
|
102
|
+
const works = WORK.map((w) => ({ ...w, label: t(w.label) }));
|
|
103
|
+
const chosenWork = works.find((w) => w.id === work) ?? (work ? { id: work, label: work } : null);
|
|
104
|
+
return (_jsxs(YStack, { gap: "$6", children: [_jsx(Heading, { title: t('Account'), detail: t('Your Hanzo identity, and what Hanzo should know about you.'), action: host.signOut ? (_jsxs(Button, { size: "sm", variant: "outline", onPress: () => host.signOut?.(), children: [_jsx(LogOut, { size: 14 }), " ", t('Log out')] })) : undefined }), _jsx(Group, { title: t('Profile'), children: _jsxs(YStack, { gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [face ? (_jsx("img", { src: face, alt: "", width: 48, height: 48, style: { borderRadius: 999, objectFit: 'cover' } })) : (_jsx(YStack, { width: 48, height: 48, rounded: 999, bg: "$raised", items: "center", justify: "center", children: _jsx(SizableText, { size: "$5", color: "$ink", children: (shownName || who.email || '?').charAt(0).toUpperCase() }) })), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$4", color: "$ink", numberOfLines: 1, children: shownName || who.email }), _jsx(SizableText, { size: "$2", color: "$soft", numberOfLines: 1, children: who.email })] }), _jsx(Button, { size: "sm", variant: "outline", disabled: busy, onPress: () => picker.current?.click(), children: t('Change photo') }), _jsx("input", { ref: picker, type: "file", accept: PHOTO, hidden: true, style: { display: 'none' }, tabIndex: -1, "aria-label": t('Photo'), onChange: (e) => {
|
|
105
|
+
const input = e.currentTarget;
|
|
106
|
+
const file = input.files?.[0];
|
|
107
|
+
input.value = '';
|
|
108
|
+
if (file)
|
|
109
|
+
void upload(file);
|
|
110
|
+
} })] }), _jsx(Field, { label: t('Full name'), children: _jsx(Input, { value: name, onChangeText: setName, "aria-label": t('Full name'), placeholder: t('Your name') }) }), _jsx(Field, { label: t('Email'), hint: t('You sign in with this address, so it is not changed here.'), children: _jsx(SizableText, { size: "$2", color: "$soft", numberOfLines: 1, children: who.email || t('No email on this account') }) }), _jsx(Field, { label: t('What should Hanzo call you?'), children: _jsx(Input, { value: callName, onChangeText: setCallName, "aria-label": t('What should Hanzo call you?'), placeholder: shownName.split(' ')[0] || t('A first name') }) }), _jsx(Field, { label: t('What best describes your work?'), children: _jsx(XStack, { children: _jsx(ChipSelect, { name: t('Work'), label: chosenWork?.label ?? t('Choose one'), chosen: chosenWork, items: works, onChange: (w) => setWork(w.id), placement: "bottom-start", width: 260 }) }) }), _jsx(Field, { label: t('Instructions for Hanzo'), hint: t('Every coding run reads these before it starts. {used}/{most}', { used: instructions.length, most: INSTRUCTIONS }), children: _jsx(Textarea, { value: instructions, onChangeText: (v) => setInstructions(v.slice(0, INSTRUCTIONS)), "aria-label": t('Instructions for Hanzo'), placeholder: t('How you like to work: the languages and tools you prefer, the style to follow, what to avoid.'), rows: 5 }) }), _jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(Button, { size: "sm", disabled: busy || !changed, onPress: () => void submit(), children: t('Save') }), _jsx(Note, { children: note })] })] }) }), org ? (_jsx(Group, { title: t('Organization'), detail: t('The organization this page acts in. Runs, codebases and settings belong to it.'), children: _jsx(Card, { children: _jsx(Row, { first: true, mono: true, title: org, detail: host.admin ? t('Organization ID · you are an admin') : t('Organization ID'), trailing: _jsx(Button, { size: "icon-sm", variant: "ghost", "aria-label": copied ? t('Organization ID copied') : t('Copy organization ID'), onPress: () => void copy(org).then((ok) => ok && setCopied(true)), children: copied ? _jsx(Check, { size: 14 }) : _jsx(Copy, { size: 14 }) }) }) }) })) : null, _jsx(Group, { title: t('Organizations'), detail: t('Every organization you belong to. Switch to act in another.'), children: orgs.length ? (_jsx(Card, { children: orgs.map((o, i) => (_jsx(Row, { first: i === 0, title: o, detail: o === host.org ? (host.admin ? t('Acting in {org} as an admin', { org: o }) : t('Acting in {org}', { org: o })) : undefined, trailing: o === host.org ? (_jsx(Check, { size: 16 })) : host.chooseOrg ? (_jsx(Button, { size: "sm", variant: "ghost", onPress: () => host.chooseOrg?.(o), children: t('Switch') })) : null }, o))) })) : (_jsx(Soft, { children: t('You belong to no organization yet.') })) })] }));
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Billing(): import("react").JSX.Element;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Billing: the plan this organization is on and the way to change it, its
|
|
4
|
+
* credits (`Credits`: the balance, grants, top-ups, auto-reload, this month's
|
|
5
|
+
* spend and its limit), the cards it pays with, its invoices, and ending the
|
|
6
|
+
* plan. Changing plan is the Plans screen; this page says what is true now.
|
|
7
|
+
*
|
|
8
|
+
* Its words are the reader's language (@hanzo/i18n `t`); a plan's name, a
|
|
9
|
+
* card's, an invoice's lines and its status are billing's, drawn as given.
|
|
10
|
+
*/
|
|
11
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
12
|
+
import { phrase } from '@hanzo/i18n';
|
|
13
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
14
|
+
import { CreditCard, Download, Plus, X } from '@hanzogui/lucide-icons-2';
|
|
15
|
+
import { Button, Dialog, DialogContent, DialogTitle, Input, toast } from '@hanzo/ui';
|
|
16
|
+
import { useEffect, useState } from 'react';
|
|
17
|
+
import { cancel, chosen, current, detach, formatAddress, invoices, label, makeDefault, methods, money, pdf, reactivate, subscriptions, tier, updateMethod, } from '../api/billing.js';
|
|
18
|
+
import { told } from '../api/call.js';
|
|
19
|
+
import { useRead } from '../data.js';
|
|
20
|
+
import { useHost, useTarget } from '../host.js';
|
|
21
|
+
import { Title } from '../meter.js';
|
|
22
|
+
import { label as named } from '../plan.js';
|
|
23
|
+
import { path } from '../route.js';
|
|
24
|
+
import { AddCard } from './card.js';
|
|
25
|
+
import { Credits } from './credits.js';
|
|
26
|
+
import { Card, day, Field, Group, Heading, Note, Row, Soft } from './ui.js';
|
|
27
|
+
import { Confirm } from '../ask.js';
|
|
28
|
+
export function Billing() {
|
|
29
|
+
const { t } = useI18n();
|
|
30
|
+
const host = useHost();
|
|
31
|
+
const target = useTarget();
|
|
32
|
+
const signed = Boolean(host.person);
|
|
33
|
+
const subs = useRead(signed ? () => subscriptions(target) : null, [], [target, signed]);
|
|
34
|
+
const cards = useRead(signed ? () => methods(target) : null, [], [target, signed]);
|
|
35
|
+
const bills = useRead(signed ? () => invoices(target) : null, [], [target, signed]);
|
|
36
|
+
const billed = useRead(signed ? () => tier(target) : null, null, [target, signed]);
|
|
37
|
+
const [adding, setAdding] = useState(false);
|
|
38
|
+
const [cardsVersion, setCardsVersion] = useState(0);
|
|
39
|
+
const [ending, setEnding] = useState(false);
|
|
40
|
+
const [editingBilling, setEditingBilling] = useState(null);
|
|
41
|
+
const [open, setOpen] = useState(null);
|
|
42
|
+
const [working, setWorking] = useState(false);
|
|
43
|
+
const [note, setNote] = useState('');
|
|
44
|
+
if (!signed) {
|
|
45
|
+
return (_jsxs(YStack, { gap: "$5", children: [_jsx(Heading, { title: t('Billing') }), _jsx(Soft, { children: t('Sign in to see this organization’s billing.') })] }));
|
|
46
|
+
}
|
|
47
|
+
const plan = current(subs.value);
|
|
48
|
+
// The plan by its family, `Max` with `20x` beside it; the subscription names
|
|
49
|
+
// it, else the rung billing serves.
|
|
50
|
+
const title = named(plan?.plan || billed.value?.plan, billed.value?.tier) ?? (plan ? { name: plan.name, tag: '' } : null);
|
|
51
|
+
// Nothing is said about the plan until both reads have answered: a page that
|
|
52
|
+
// has not asked yet is not a page on Free.
|
|
53
|
+
const reading = (subs.loading && !subs.value.length) || (billed.value === null && !billed.error && !subs.error);
|
|
54
|
+
const empty = !cards.error && !cards.loading && cards.value.length === 0;
|
|
55
|
+
const defaultCard = chosen(cards.value);
|
|
56
|
+
const reloadCards = () => {
|
|
57
|
+
cards.reload();
|
|
58
|
+
setCardsVersion((v) => v + 1);
|
|
59
|
+
};
|
|
60
|
+
// A done act is a toast; a refused one stays on the page, beside what was tried.
|
|
61
|
+
const act = async (what, done, after) => {
|
|
62
|
+
setWorking(true);
|
|
63
|
+
setNote('');
|
|
64
|
+
try {
|
|
65
|
+
await what();
|
|
66
|
+
after();
|
|
67
|
+
toast.success(done);
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
setNote(told(e, t));
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
setWorking(false);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return (_jsxs(YStack, { gap: "$6", children: [_jsx(Heading, { title: t('Billing'), detail: host.org ? t('The plan {org} is on, the cards it pays with, and its invoices.', { org: host.org }) : t('The plan this organization is on, the cards it pays with, and its invoices.') }), _jsxs(XStack, { items: "center", gap: "$3", px: "$4", py: "$4", borderWidth: 1, borderColor: "$borderColor", rounded: "$3", flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 200, gap: "$1", "data-slot": "billing-plan", children: [reading ? (_jsx(SizableText, { size: "$5", color: "$ink", children: t('Reading your plan…') })) : (_jsx(Title, { label: title ?? { name: phrase('Free'), tag: '' }, size: "$5" })), _jsx(SizableText, { size: "$2", color: "$soft", children: subs.error ? told(subs.error, t) : plan ? terms(plan, t) : title ? t('Your plan.') : t('No paid plan. Usage is paid from credits.') })] }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => host.go(path({ kind: 'screen', screen: 'plans' })), children: t('Adjust plan') })] }), _jsx(Credits, { target: target, admin: host.admin, cardsVersion: cardsVersion, onCard: () => setAdding(true) }), _jsxs(Group, { title: t('Payment'), detail: t('The card a plan renews on and a top-up charges.'), action: host.admin && (cards.error || cards.value.length > 0) ? (_jsxs(Button, { size: "sm", variant: "outline", onPress: () => setAdding(true), children: [_jsx(Plus, { size: 14 }), " ", t('Add card')] })) : undefined, children: [cards.error ? (_jsx(Soft, { children: told(cards.error, t) })) : cards.loading && !cards.value.length ? (_jsx(Soft, { children: t('Reading cards…') })) : empty ? (_jsxs(XStack, { items: "center", gap: "$3", px: "$4", py: "$4", borderWidth: 1, borderColor: "$borderColor", rounded: "$3", flexWrap: "wrap", children: [_jsx(CreditCard, { size: 20 }), _jsxs(YStack, { flex: 1, minW: 180, gap: "$1", children: [_jsx(SizableText, { size: "$3", color: "$ink", children: t('No card on file.') }), _jsx(SizableText, { size: "$2", color: "$soft", children: host.admin ? t('Add one to pay for a plan or a top-up. Adding it charges nothing.') : t('An org admin adds cards.') })] }), host.admin ? (_jsxs(Button, { variant: "primary", onPress: () => setAdding(true), children: [_jsx(Plus, { size: 16 }), " ", t('Add card')] })) : null] })) : (_jsx(Card, { children: cards.value.map((m, i) => (_jsx(Row, { first: i === 0, leading: _jsx(CreditCard, { size: 16 }), title: method(m, t), detail: [
|
|
77
|
+
m.expires ? t('Expires {date}', { date: m.expires }) : '',
|
|
78
|
+
m.default ? t('Default') : '',
|
|
79
|
+
m.billingAddress ? formatAddress(m.billingAddress) : '',
|
|
80
|
+
]
|
|
81
|
+
.filter(Boolean)
|
|
82
|
+
.join(' · ') || undefined, trailing: host.admin ? (_jsxs(XStack, { gap: "$2", items: "center", children: [!m.default ? (_jsx(Button, { size: "sm", variant: "ghost", "aria-label": t('Make {card} default', { card: method(m, t) }), disabled: working, onPress: () => void act(() => makeDefault(target, m.id), t('{card} is now the default', { card: method(m, t) }), reloadCards), children: t('Make default') })) : null, _jsx(Button, { size: "sm", variant: "ghost", "aria-label": t('Edit billing info for {card}', { card: method(m, t) }), disabled: working, onPress: () => setEditingBilling(m), children: t('Edit info') }), _jsx(Button, { size: "sm", variant: "ghost", "aria-label": t('Remove {card}', { card: method(m, t) }), disabled: working, onPress: () => void act(() => detach(target, m.id), t('{card} is removed', { card: method(m, t) }), reloadCards), children: t('Remove') })] })) : undefined }, m.id))) })), !host.admin && cards.value.length ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('An org admin adds and removes cards.') })) : null] }), _jsx(Group, { title: t('Billing details'), detail: t('Information printed on invoices and payment receipts.'), action: host.admin && defaultCard ? (_jsx(Button, { size: "sm", variant: "outline", onPress: () => setEditingBilling(defaultCard), children: defaultCard.billingAddress ? t('Edit details') : t('Add billing info') })) : undefined, children: defaultCard?.billingAddress ? (_jsx(Card, { children: _jsxs(YStack, { p: "$3", gap: "$1.5", children: [defaultCard.billingAddress.name ? (_jsx(SizableText, { size: "$3", color: "$ink", style: { fontWeight: 600 }, children: defaultCard.billingAddress.name })) : null, defaultCard.billingAddress.line1 ? (_jsxs(SizableText, { size: "$2", color: "$soft", children: [defaultCard.billingAddress.line1, defaultCard.billingAddress.line2 ? `, ${defaultCard.billingAddress.line2}` : ''] })) : null, defaultCard.billingAddress.city || defaultCard.billingAddress.state || defaultCard.billingAddress.postalCode ? (_jsx(SizableText, { size: "$2", color: "$soft", children: [defaultCard.billingAddress.city, defaultCard.billingAddress.state, defaultCard.billingAddress.postalCode]
|
|
83
|
+
.filter(Boolean)
|
|
84
|
+
.join(' ') })) : null, defaultCard.billingAddress.country ? (_jsx(SizableText, { size: "$2", color: "$soft", children: defaultCard.billingAddress.country })) : null] }) })) : (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", px: "$4", py: "$3", borderWidth: 1, borderColor: "$borderColor", rounded: "$3", flexWrap: "wrap", children: [_jsxs(YStack, { flex: 1, minW: 180, gap: "$1", children: [_jsx(SizableText, { size: "$2", color: "$ink", children: t('No billing address on file.') }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Add your company name and address so they appear on monthly invoices and receipts.') })] }), host.admin ? (_jsxs(Button, { size: "sm", variant: "outline", onPress: () => (defaultCard ? setEditingBilling(defaultCard) : setAdding(true)), children: [_jsx(Plus, { size: 14 }), " ", defaultCard ? t('Add billing info') : t('Set billing info')] })) : null] })) }), _jsx(Group, { title: t('Invoices'), children: bills.error ? (_jsx(Soft, { children: told(bills.error, t) })) : bills.loading && !bills.value.length ? (_jsx(Soft, { children: t('Reading invoices…') })) : bills.value.length === 0 ? (_jsx(Card, { children: _jsx(Soft, { children: t('No invoices yet.') }) })) : (_jsxs(Card, { children: [_jsxs(XStack, { px: "$3", py: "$2", gap: "$3", children: [_jsx(SizableText, { flex: 1, size: "$1", color: "$soft", children: t('Date') }), _jsx(SizableText, { width: 90, size: "$1", color: "$soft", text: "end", children: t('Total') }), _jsx(SizableText, { width: 70, size: "$1", color: "$soft", "$max-sm": { display: 'none' }, children: t('Status') }), _jsx(YStack, { width: 64 })] }), bills.value.map((b) => (_jsxs(XStack, { items: "center", gap: "$3", px: "$3", py: "$2.5", borderTopWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { flex: 1, size: "$2", color: "$ink", numberOfLines: 1, children: day(b.date) || b.number || b.id }), _jsx(SizableText, { width: 90, size: "$2", color: "$ink", text: "end", children: money(b.total, b.currency) }), _jsx(SizableText, { width: 70, size: "$1", color: "$soft", "$max-sm": { display: 'none' }, children: word(b.status) }), _jsx(XStack, { width: 64, justify: "flex-end", children: _jsx(Button, { size: "sm", variant: "ghost", "aria-label": t('View invoice {invoice}', { invoice: b.number || day(b.date) }), onPress: () => setOpen(b), children: t('View') }) })] }, b.id)))] })) }), plan ? (_jsx(Group, { title: t('Cancellation'), children: _jsx(Card, { children: _jsx(Row, { first: true, title: plan.ending ? t('Your plan ends on {date}', { date: day(plan.ends) }) : t('Cancel plan'), detail: plan.ending ? t('Keep it, and it renews as before.') : t('It runs to the end of the period you paid for, then ends.'), trailing: !host.admin ? undefined : plan.ending ? (_jsx(Button, { size: "sm", variant: "outline", disabled: working, onPress: () => void act(() => reactivate(target, plan.id), t('Your plan renews as before'), subs.reload), children: t('Keep plan') })) : (_jsx(Button, { size: "sm", variant: "destructive", disabled: working, onPress: () => setEnding(true), children: t('Cancel') })) }) }) })) : null, _jsx(Note, { children: note }), _jsx(AddCard, { open: adding, onOpenChange: setAdding, onSaved: (m) => {
|
|
85
|
+
reloadCards();
|
|
86
|
+
toast.success(t('{card} is saved', { card: method(m, t) }));
|
|
87
|
+
} }), _jsx(EditBilling, { open: editingBilling !== null, onOpenChange: (o) => !o && setEditingBilling(null), card: editingBilling, onSaved: () => {
|
|
88
|
+
reloadCards();
|
|
89
|
+
} }), plan ? (_jsx(Ending, { plan: plan, open: ending, working: working, onOpenChange: setEnding, onConfirm: () => act(() => cancel(target, plan.id), t('Your plan ends on {date}', { date: day(plan.ends) }), () => {
|
|
90
|
+
setEnding(false);
|
|
91
|
+
subs.reload();
|
|
92
|
+
}) })) : null, open ? _jsx(Bill, { invoice: open, onClose: () => setOpen(null) }) : null] }));
|
|
93
|
+
}
|
|
94
|
+
function EditBilling({ open, onOpenChange, card, onSaved, }) {
|
|
95
|
+
const { t } = useI18n();
|
|
96
|
+
const target = useTarget();
|
|
97
|
+
const [name, setName] = useState('');
|
|
98
|
+
const [line1, setLine1] = useState('');
|
|
99
|
+
const [line2, setLine2] = useState('');
|
|
100
|
+
const [city, setCity] = useState('');
|
|
101
|
+
const [stateVal, setStateVal] = useState('');
|
|
102
|
+
const [postalCode, setPostalCode] = useState('');
|
|
103
|
+
const [country, setCountry] = useState('US');
|
|
104
|
+
const [working, setWorking] = useState(false);
|
|
105
|
+
const [note, setNote] = useState('');
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (card?.billingAddress) {
|
|
108
|
+
setName(card.billingAddress.name ?? '');
|
|
109
|
+
setLine1(card.billingAddress.line1 ?? '');
|
|
110
|
+
setLine2(card.billingAddress.line2 ?? '');
|
|
111
|
+
setCity(card.billingAddress.city ?? '');
|
|
112
|
+
setStateVal(card.billingAddress.state ?? '');
|
|
113
|
+
setPostalCode(card.billingAddress.postalCode ?? '');
|
|
114
|
+
setCountry(card.billingAddress.country ?? 'US');
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
setName('');
|
|
118
|
+
setLine1('');
|
|
119
|
+
setLine2('');
|
|
120
|
+
setCity('');
|
|
121
|
+
setStateVal('');
|
|
122
|
+
setPostalCode('');
|
|
123
|
+
setCountry('US');
|
|
124
|
+
}
|
|
125
|
+
setNote('');
|
|
126
|
+
}, [card]);
|
|
127
|
+
const save = async () => {
|
|
128
|
+
if (!card)
|
|
129
|
+
return;
|
|
130
|
+
setWorking(true);
|
|
131
|
+
setNote('');
|
|
132
|
+
try {
|
|
133
|
+
const address = {
|
|
134
|
+
name: name.trim() || undefined,
|
|
135
|
+
line1: line1.trim() || undefined,
|
|
136
|
+
line2: line2.trim() || undefined,
|
|
137
|
+
city: city.trim() || undefined,
|
|
138
|
+
state: stateVal.trim() || undefined,
|
|
139
|
+
postalCode: postalCode.trim() || undefined,
|
|
140
|
+
country: country.trim() || undefined,
|
|
141
|
+
};
|
|
142
|
+
await updateMethod(target, card.id, { billingAddress: address });
|
|
143
|
+
onSaved();
|
|
144
|
+
onOpenChange(false);
|
|
145
|
+
toast.success(t('Billing details updated'));
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
setNote(told(e, t));
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
setWorking(false);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { maxW: 460, showCloseButton: false, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(DialogTitle, { children: t('Billing details') }), _jsx(XStack, { render: "button", "aria-label": t('Close'), p: "$1", onPress: () => onOpenChange(false), children: _jsx(X, { size: 16 }) })] }), _jsxs(YStack, { gap: "$3", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('These details appear on your invoices and receipts.') }), _jsx(Field, { label: t('Business or personal name'), children: _jsx(Input, { value: name, onChangeText: setName, placeholder: t('e.g. Webby AI, Inc. or Joshua Lynch') }) }), _jsx(Field, { label: t('Address line 1'), children: _jsx(Input, { value: line1, onChangeText: setLine1, placeholder: t('Street address or P.O. Box') }) }), _jsx(Field, { label: t('Address line 2'), hint: t('Optional'), children: _jsx(Input, { value: line2, onChangeText: setLine2, placeholder: t('Suite, unit, building, floor') }) }), _jsxs(XStack, { gap: "$2", children: [_jsx(YStack, { flex: 1, children: _jsx(Field, { label: t('City'), children: _jsx(Input, { value: city, onChangeText: setCity, placeholder: t('City') }) }) }), _jsx(YStack, { width: 100, children: _jsx(Field, { label: t('State'), children: _jsx(Input, { value: stateVal, onChangeText: setStateVal, placeholder: t('State / Prov') }) }) })] }), _jsxs(XStack, { gap: "$2", children: [_jsx(YStack, { flex: 1, children: _jsx(Field, { label: t('Postal / ZIP code'), children: _jsx(Input, { value: postalCode, onChangeText: setPostalCode, placeholder: t('ZIP or Postal Code') }) }) }), _jsx(YStack, { width: 110, children: _jsx(Field, { label: t('Country'), children: _jsx(Input, { value: country, onChangeText: setCountry, placeholder: t('Country (US)') }) }) })] }), note ? (_jsx(SizableText, { size: "$2", color: "$red10", role: "alert", children: note })) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", pt: "$2", children: [_jsx(Button, { size: "sm", variant: "ghost", disabled: working, onPress: () => onOpenChange(false), children: t('Cancel') }), _jsx(Button, { size: "sm", disabled: working, onPress: () => void save(), children: t('Save details') })] })] })] }) }));
|
|
155
|
+
}
|
|
156
|
+
/** What a plan costs by its interval, alone and for its seats: one sentence each, so a language says the interval its own way. */
|
|
157
|
+
const COST = {
|
|
158
|
+
month: { one: phrase('{amount} a month.'), seats: phrase('{amount} a month for {seats} seats.') },
|
|
159
|
+
year: { one: phrase('{amount} a year.'), seats: phrase('{amount} a year for {seats} seats.') },
|
|
160
|
+
};
|
|
161
|
+
/** What the plan costs, and when it renews or ends, in the words of `t`. */
|
|
162
|
+
function terms(p, t) {
|
|
163
|
+
const amount = money(p.price * p.seats, p.currency);
|
|
164
|
+
const by = COST[p.interval];
|
|
165
|
+
const cost = by
|
|
166
|
+
? t(p.seats > 1 ? by.seats : by.one, { amount, seats: p.seats })
|
|
167
|
+
: p.seats > 1
|
|
168
|
+
? t('{amount} a {interval} for {seats} seats.', { amount, interval: p.interval, seats: p.seats })
|
|
169
|
+
: t('{amount} a {interval}.', { amount, interval: p.interval });
|
|
170
|
+
if (!p.ends)
|
|
171
|
+
return cost;
|
|
172
|
+
return `${cost} ${p.ending ? t('Ends on {date}.', { date: day(p.ends) }) : t('Renews on {date}.', { date: day(p.ends) })}`;
|
|
173
|
+
}
|
|
174
|
+
/** A saved method as a row names it (api/billing.ts `label`); a card with no brand is said in the words of `t`. */
|
|
175
|
+
const method = (m, t) => (m.last4 && !m.brand ? t('Card •••• {last4}', { last4: m.last4 }) : label(m));
|
|
176
|
+
const word = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1).replace(/_/g, ' ') : '');
|
|
177
|
+
function Ending({ plan, open, working, onOpenChange, onConfirm, }) {
|
|
178
|
+
const { t } = useI18n();
|
|
179
|
+
return (_jsx(Confirm, { open: open, onOpenChange: (o) => !working && onOpenChange(o), title: t('Cancel your plan?'), says: day(plan.ends)
|
|
180
|
+
? t('{plan} stays on until {date}, and nothing is charged after that. You can keep it any time before then.', { plan: plan.name, date: day(plan.ends) })
|
|
181
|
+
: t('{plan} stays on until the end of this period, and nothing is charged after that. You can keep it any time before then.', { plan: plan.name }), act: t('Cancel plan'), no: t('Keep plan'), run: onConfirm }));
|
|
182
|
+
}
|
|
183
|
+
/** One invoice, read in the page, with its PDF to keep. Drawn while it is open, so each opens anew. */
|
|
184
|
+
function Bill({ invoice: b, onClose }) {
|
|
185
|
+
const { t } = useI18n();
|
|
186
|
+
const target = useTarget();
|
|
187
|
+
const [note, setNote] = useState('');
|
|
188
|
+
const [working, setWorking] = useState(false);
|
|
189
|
+
const keep = async () => {
|
|
190
|
+
setWorking(true);
|
|
191
|
+
setNote('');
|
|
192
|
+
try {
|
|
193
|
+
const blob = await pdf(target, b.id);
|
|
194
|
+
const url = URL.createObjectURL(blob);
|
|
195
|
+
const a = document.createElement('a');
|
|
196
|
+
a.href = url;
|
|
197
|
+
a.download = `${b.number || b.id}.pdf`;
|
|
198
|
+
a.click();
|
|
199
|
+
window.setTimeout(() => URL.revokeObjectURL(url), 1000);
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
setNote(told(e, t));
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
setWorking(false);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const line = (what, cents, strong = false) => (_jsxs(XStack, { justify: "space-between", gap: "$3", children: [_jsx(SizableText, { size: "$2", color: strong ? '$ink' : '$soft', children: what }), _jsx(SizableText, { size: "$2", color: strong ? '$ink' : '$soft', children: money(cents, b.currency) })] }, what));
|
|
209
|
+
return (_jsx(Dialog, { open: true, onOpenChange: (o) => !o && onClose(), children: _jsxs(DialogContent, { maxW: 480, showCloseButton: false, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(DialogTitle, { children: b.number ? t('Invoice {number}', { number: b.number }) : t('Invoice') }), _jsx(XStack, { render: "button", "aria-label": t('Close'), p: "$1", onPress: onClose, children: _jsx(X, { size: 16 }) })] }), _jsxs(YStack, { gap: "$3", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: [day(b.date), word(b.status), b.start && b.end ? t('for {start} – {end}', { start: day(b.start), end: day(b.end) }) : ''].filter(Boolean).join(' · ') }), _jsx(YStack, { gap: "$1.5", borderTopWidth: 1, borderColor: "$borderColor", pt: "$3", children: b.lines.length ? b.lines.map((l, i) => line(l.description || t('Line {n}', { n: i + 1 }), l.amount)) : line(t('Subtotal'), b.subtotal) }), _jsxs(YStack, { gap: "$1.5", borderTopWidth: 1, borderColor: "$borderColor", pt: "$3", children: [b.discount ? line(t('Discount'), -b.discount) : null, b.tax ? line(t('Tax'), b.tax) : null, line(t('Total'), b.total, true), b.credit ? line(t('Credit applied'), -b.credit) : null, line(t('Paid'), b.paid), b.due ? line(t('Due'), b.due, true) : null] }), _jsx(Note, { children: note }), _jsx(XStack, { justify: "flex-end", children: _jsxs(Button, { size: "sm", variant: "outline", disabled: working, onPress: () => void keep(), children: [_jsx(Download, { size: 14 }), " ", t('Download PDF')] }) })] })] }) }));
|
|
210
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Capabilities(): import("react").JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Capabilities: what the agent may use, by where it comes from — connector
|
|
4
|
+
* actions, functions, services, agents, skills and the organization's own MCP
|
|
5
|
+
* servers. A tool that is off is still listed to the agent's discovery but is
|
|
6
|
+
* refused when called. Switching a kind on turns on every tool of that kind;
|
|
7
|
+
* off turns them all off. It is the organization's setting, not only yours.
|
|
8
|
+
*
|
|
9
|
+
* Its words are the reader's language (@hanzo/i18n `t`).
|
|
10
|
+
*/
|
|
11
|
+
import { SizableText, YStack } from '@hanzo/gui';
|
|
12
|
+
import { phrase } from '@hanzo/i18n';
|
|
13
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
14
|
+
import { Switch } from '@hanzo/ui';
|
|
15
|
+
import { useState } from 'react';
|
|
16
|
+
import { told } from '../api/call.js';
|
|
17
|
+
import { activate, SOURCES, tools } from '../api/capabilities.js';
|
|
18
|
+
import { useRead } from '../data.js';
|
|
19
|
+
import { useHost, useTarget } from '../host.js';
|
|
20
|
+
import { Card, Group, Heading, Note, Row, Soft } from './ui.js';
|
|
21
|
+
/** Each kind's name and the sentence that says what it is, English and marked (`phrase`), drawn through `t`. */
|
|
22
|
+
const KINDS = {
|
|
23
|
+
connector: { label: phrase('Connector actions'), about: phrase('Actions in the apps your organization connected.') },
|
|
24
|
+
function: { label: phrase('Functions'), about: phrase('Functions your organization wrote.') },
|
|
25
|
+
'zap-service': { label: phrase('Services'), about: phrase('Routes of the services your organization runs.') },
|
|
26
|
+
agent: { label: phrase('Agents'), about: phrase('Your organization’s agents, called as tools.') },
|
|
27
|
+
skill: { label: phrase('Skills'), about: phrase('Skills attached to agents.') },
|
|
28
|
+
mcp: { label: phrase('MCP servers'), about: phrase('Tools on the MCP servers your organization added.') },
|
|
29
|
+
};
|
|
30
|
+
export function Capabilities() {
|
|
31
|
+
const { t } = useI18n();
|
|
32
|
+
const host = useHost();
|
|
33
|
+
const target = useTarget();
|
|
34
|
+
const signed = Boolean(host.person);
|
|
35
|
+
const list = useRead(signed ? () => tools(target) : null, [], [target, signed]);
|
|
36
|
+
const [busy, setBusy] = useState('');
|
|
37
|
+
const [note, setNote] = useState('');
|
|
38
|
+
if (!signed) {
|
|
39
|
+
return (_jsxs(YStack, { gap: "$5", children: [_jsx(Heading, { title: t('Capabilities') }), _jsx(Soft, { children: t('Sign in to see what the agent may use.') })] }));
|
|
40
|
+
}
|
|
41
|
+
const kinds = SOURCES.map((s) => ({ source: s, all: list.value.filter((x) => x.source === s) })).filter((k) => k.all.length);
|
|
42
|
+
const flip = async (source, all, on) => {
|
|
43
|
+
setBusy(source);
|
|
44
|
+
setNote('');
|
|
45
|
+
try {
|
|
46
|
+
await activate(target, all.map((x) => x.name), on);
|
|
47
|
+
list.reload();
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
setNote(told(e, t));
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
setBusy('');
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return (_jsxs(YStack, { gap: "$6", children: [_jsx(Heading, { title: t('Capabilities'), detail: host.org
|
|
57
|
+
? t('What the agent may use in {org}. A tool that is off is refused when the agent calls it.', { org: host.org })
|
|
58
|
+
: t('What the agent may use in this organization. A tool that is off is refused when the agent calls it.') }), _jsx(Group, { title: t('Tools'), detail: host.admin
|
|
59
|
+
? t('Switching a kind on or off applies to every tool of that kind, for everyone in the organization.')
|
|
60
|
+
: t('An org admin switches these, for everyone in the organization.'), children: list.error ? (_jsx(Soft, { children: told(list.error, t) })) : list.loading && !list.value.length ? (_jsx(Soft, { children: t('Reading tools…') })) : !kinds.length ? (_jsx(Soft, { children: t('No tools are available to this organization yet.') })) : (_jsx(Card, { children: kinds.map(({ source, all }, i) => {
|
|
61
|
+
const on = all.filter((x) => x.activated).length;
|
|
62
|
+
// What the kind is, then how much of it is on: two sentences.
|
|
63
|
+
const count = on === all.length ? t('All {n} on.', { n: all.length }) : on ? t('{on} of {n} on.', { on, n: all.length }) : t('{n} available, all off.', { n: all.length });
|
|
64
|
+
return (_jsx(Row, { first: i === 0, title: t(KINDS[source].label), detail: `${t(KINDS[source].about)} ${count}`, trailing: host.admin ? (_jsx(Switch, { "aria-label": t(KINDS[source].label), checked: on === all.length, disabled: busy !== '', onCheckedChange: (v) => void flip(source, all, v) })) : (_jsx(SizableText, { size: "$1", color: "$soft", children: on === all.length ? t('On') : on ? t('Partly on') : t('Off') })) }, source));
|
|
65
|
+
}) })) }), _jsx(Note, { children: note })] }));
|
|
66
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Method } from '../api/billing.ts';
|
|
2
|
+
/** The part of Square's Web Payments SDK this uses. */
|
|
3
|
+
interface Field {
|
|
4
|
+
attach(el: HTMLElement): Promise<void>;
|
|
5
|
+
tokenize(): Promise<{
|
|
6
|
+
status: string;
|
|
7
|
+
token?: string;
|
|
8
|
+
errors?: {
|
|
9
|
+
message?: string;
|
|
10
|
+
}[];
|
|
11
|
+
}>;
|
|
12
|
+
destroy(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
interface Sdk {
|
|
15
|
+
payments(application: string, location: string): {
|
|
16
|
+
card(options?: object): Promise<Field>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface Window {
|
|
21
|
+
Square?: Sdk;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Anything but production loads the sandbox SDK, so a misread setting never arms real charges. */
|
|
25
|
+
export declare const sdk: (environment: string) => string;
|
|
26
|
+
export declare function AddCard({ open, onOpenChange, onSaved }: {
|
|
27
|
+
open: boolean;
|
|
28
|
+
onOpenChange: (o: boolean) => void;
|
|
29
|
+
onSaved: (m: Method) => void;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Adding a card. The card number is typed into the payment processor's own
|
|
4
|
+
* field — its iframe, served from its own host — and never reaches this page or
|
|
5
|
+
* the platform: the field hands back a single-use token, and the platform vaults
|
|
6
|
+
* the card from that. Which processor, and its sandbox or live account, is the
|
|
7
|
+
* platform's answer at /v1/billing/settings, so the card is saved to the account
|
|
8
|
+
* it will be charged on.
|
|
9
|
+
*
|
|
10
|
+
* Its words are the reader's language (@hanzo/i18n `t`); what the processor's
|
|
11
|
+
* field says of a card is the processor's, drawn as given.
|
|
12
|
+
*/
|
|
13
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
14
|
+
import { phrase } from '@hanzo/i18n';
|
|
15
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
16
|
+
import { ChevronDown, ChevronUp, X } from '@hanzogui/lucide-icons-2';
|
|
17
|
+
import { Button, Dialog, DialogContent, DialogTitle, Input } from '@hanzo/ui';
|
|
18
|
+
import { useEffect, useRef, useState } from 'react';
|
|
19
|
+
import { processor, save } from '../api/billing.js';
|
|
20
|
+
import { told } from '../api/call.js';
|
|
21
|
+
import { useRead } from '../data.js';
|
|
22
|
+
import { useTarget } from '../host.js';
|
|
23
|
+
import { Field as FormField } from './ui.js';
|
|
24
|
+
/** Anything but production loads the sandbox SDK, so a misread setting never arms real charges. */
|
|
25
|
+
export const sdk = (environment) => environment === 'production' ? 'https://web.squarecdn.com/v1/square.js' : 'https://sandbox.web.squarecdn.com/v1/square.js';
|
|
26
|
+
const loads = new Map();
|
|
27
|
+
function load(environment) {
|
|
28
|
+
if (window.Square)
|
|
29
|
+
return Promise.resolve(window.Square);
|
|
30
|
+
const src = sdk(environment);
|
|
31
|
+
const was = loads.get(src);
|
|
32
|
+
if (was)
|
|
33
|
+
return was;
|
|
34
|
+
const p = new Promise((resolve, reject) => {
|
|
35
|
+
const s = document.createElement('script');
|
|
36
|
+
s.src = src;
|
|
37
|
+
s.async = true;
|
|
38
|
+
s.onload = () => (window.Square ? resolve(window.Square) : reject(new Error(phrase('The card form did not load'))));
|
|
39
|
+
s.onerror = () => {
|
|
40
|
+
loads.delete(src);
|
|
41
|
+
reject(new Error(phrase('The card form did not load')));
|
|
42
|
+
};
|
|
43
|
+
document.head.appendChild(s);
|
|
44
|
+
});
|
|
45
|
+
loads.set(src, p);
|
|
46
|
+
return p;
|
|
47
|
+
}
|
|
48
|
+
const ready = (p) => Boolean(p && p.provider === 'square' && p.application && p.location);
|
|
49
|
+
export function AddCard({ open, onOpenChange, onSaved }) {
|
|
50
|
+
const { t } = useI18n();
|
|
51
|
+
const target = useTarget();
|
|
52
|
+
const cfg = useRead(open ? () => processor(target) : null, null, [target, open]);
|
|
53
|
+
const [box, setBox] = useState(null);
|
|
54
|
+
const field = useRef(null);
|
|
55
|
+
const [mounted, setMounted] = useState(false);
|
|
56
|
+
const [working, setWorking] = useState(false);
|
|
57
|
+
const [note, setNote] = useState('');
|
|
58
|
+
const [name, setName] = useState('');
|
|
59
|
+
const [postalCode, setPostalCode] = useState('');
|
|
60
|
+
const [moreAddress, setMoreAddress] = useState(false);
|
|
61
|
+
const [line1, setLine1] = useState('');
|
|
62
|
+
const [city, setCity] = useState('');
|
|
63
|
+
const [stateVal, setStateVal] = useState('');
|
|
64
|
+
const [country, setCountry] = useState('US');
|
|
65
|
+
const p = cfg.value;
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!open || !box || !ready(p))
|
|
68
|
+
return;
|
|
69
|
+
let gone = false;
|
|
70
|
+
setMounted(false);
|
|
71
|
+
setNote('');
|
|
72
|
+
load(p.environment)
|
|
73
|
+
.then((square) => square.payments(p.application, p.location).card())
|
|
74
|
+
.then(async (f) => {
|
|
75
|
+
if (gone) {
|
|
76
|
+
void f.destroy().catch(() => { });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
await f.attach(box);
|
|
80
|
+
field.current = f;
|
|
81
|
+
setMounted(true);
|
|
82
|
+
})
|
|
83
|
+
.catch((e) => {
|
|
84
|
+
if (!gone)
|
|
85
|
+
setNote(e instanceof Error ? told(e, t) : t('The card form did not load'));
|
|
86
|
+
});
|
|
87
|
+
return () => {
|
|
88
|
+
gone = true;
|
|
89
|
+
const f = field.current;
|
|
90
|
+
field.current = null;
|
|
91
|
+
setMounted(false);
|
|
92
|
+
if (f)
|
|
93
|
+
void f.destroy().catch(() => { });
|
|
94
|
+
};
|
|
95
|
+
}, [open, box, p]);
|
|
96
|
+
// Save is offered only while the field is drawn.
|
|
97
|
+
const add = async () => {
|
|
98
|
+
const f = field.current;
|
|
99
|
+
setWorking(true);
|
|
100
|
+
setNote('');
|
|
101
|
+
try {
|
|
102
|
+
const r = await f.tokenize();
|
|
103
|
+
if (r.status !== 'OK' || !r.token)
|
|
104
|
+
throw new Error(r.errors?.map((e) => e.message).filter(Boolean).join('; ') || phrase('The card details are incomplete'));
|
|
105
|
+
const billingAddress = name.trim() || postalCode.trim() || line1.trim() || city.trim() || stateVal.trim()
|
|
106
|
+
? {
|
|
107
|
+
name: name.trim() || undefined,
|
|
108
|
+
postalCode: postalCode.trim() || undefined,
|
|
109
|
+
line1: line1.trim() || undefined,
|
|
110
|
+
city: city.trim() || undefined,
|
|
111
|
+
state: stateVal.trim() || undefined,
|
|
112
|
+
country: country.trim() || 'US',
|
|
113
|
+
}
|
|
114
|
+
: undefined;
|
|
115
|
+
const m = await save(target, r.token, billingAddress);
|
|
116
|
+
onSaved(m);
|
|
117
|
+
onOpenChange(false);
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
setNote(e instanceof Error ? told(e, t) : t('The card was not saved'));
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
setWorking(false);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const nonSquareConfigured = Boolean(p && p.provider && p.provider !== 'square');
|
|
127
|
+
const why = cfg.error
|
|
128
|
+
? told(cfg.error, t)
|
|
129
|
+
: !cfg.loading && !ready(p)
|
|
130
|
+
? nonSquareConfigured
|
|
131
|
+
? t('Cards for your region are added securely on the payment page.')
|
|
132
|
+
: t('This deployment takes no cards yet.')
|
|
133
|
+
: '';
|
|
134
|
+
const payCardsHref = typeof window !== 'undefined'
|
|
135
|
+
? `https://hanzo.ai/pay/cards?returnUrl=${encodeURIComponent(window.location.href)}`
|
|
136
|
+
: 'https://hanzo.ai/pay/cards';
|
|
137
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { maxW: 460, showCloseButton: false, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(DialogTitle, { children: t('Add a card') }), _jsx(XStack, { render: "button", "aria-label": t('Close'), p: "$1", onPress: () => onOpenChange(false), children: _jsx(X, { size: 16 }) })] }), _jsxs(YStack, { gap: "$3", children: [why ? (_jsx(SizableText, { size: "$2", color: "$soft", children: why })) : (_jsxs(_Fragment, { children: [_jsxs(YStack, { minH: 96, "aria-label": t('Card details'), children: [_jsx("div", { ref: setBox, style: { minHeight: 96 } }), !mounted && !note ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Loading the card form…') })) : null] }), _jsxs(XStack, { gap: "$2", children: [_jsx(YStack, { flex: 1, children: _jsx(FormField, { label: t('Name on card'), hint: t('Optional'), children: _jsx(Input, { value: name, onChangeText: setName, placeholder: t('Name or business') }) }) }), _jsx(YStack, { width: 120, children: _jsx(FormField, { label: t('Postal code'), hint: t('Optional'), children: _jsx(Input, { value: postalCode, onChangeText: setPostalCode, placeholder: t('ZIP / Postal') }) }) })] }), _jsx(XStack, { children: _jsxs(Button, { size: "sm", variant: "ghost", onPress: () => setMoreAddress(!moreAddress), children: [moreAddress ? _jsx(ChevronUp, { size: 14 }) : _jsx(ChevronDown, { size: 14 }), moreAddress ? t('Hide address') : t('Add billing address')] }) }), moreAddress ? (_jsxs(YStack, { gap: "$2", pt: "$1", children: [_jsx(FormField, { label: t('Street address'), children: _jsx(Input, { value: line1, onChangeText: setLine1, placeholder: t('Address line 1') }) }), _jsxs(XStack, { gap: "$2", children: [_jsx(YStack, { flex: 1, children: _jsx(FormField, { label: t('City'), children: _jsx(Input, { value: city, onChangeText: setCity, placeholder: t('City') }) }) }), _jsx(YStack, { width: 90, children: _jsx(FormField, { label: t('State'), children: _jsx(Input, { value: stateVal, onChangeText: setStateVal, placeholder: t('State') }) }) }), _jsx(YStack, { width: 90, children: _jsx(FormField, { label: t('Country'), children: _jsx(Input, { value: country, onChangeText: setCountry, placeholder: t('Country (US)') }) }) })] })] })) : null, _jsx(SizableText, { size: "$1", color: "$soft", children: p && p.environment !== 'production'
|
|
138
|
+
? t('Sandbox: use a test card. Nothing is charged.')
|
|
139
|
+
: t('The card number goes to the payment processor, never to Hanzo. Saving it charges nothing.') })] })), note ? (_jsx(SizableText, { size: "$2", color: "$red10", role: "alert", children: note })) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", onPress: () => onOpenChange(false), children: t('Cancel') }), nonSquareConfigured ? (_jsx(Button, { size: "sm", onPress: () => window.location.assign(payCardsHref), children: t('Add card on hanzo.ai/pay') })) : (_jsx(Button, { size: "sm", disabled: !mounted || working, onPress: () => void add(), children: t('Save card') }))] })] })] }) }));
|
|
140
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Code(): import("react").JSX.Element;
|