| 1 | package connect |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/estilo.git/homeconnect" |
| 5 | "embed" |
| 6 | ) |
| 7 | |
| 8 | func Templates() embed.FS { return homeconnect.Templates() } |
| 9 | |
| 10 | type PageData = homeconnect.PageData |
| 11 | |
| 12 | func Page(state, label string, translate ...func(string) string) PageData { |
| 13 | t := func(k string) string { return English[k] } |
| 14 | if len(translate) > 0 && translate[0] != nil { |
| 15 | t = translate[0] |
| 16 | } |
| 17 | p := PageData{Address: label} |
| 18 | switch state { |
| 19 | case "start": |
| 20 | p.Action = "/account/home" |
| 21 | p.PostAction = true |
| 22 | p.ActionLabel = t("start_action") |
| 23 | case "confirm": |
| 24 | p.Action = "/account/home/confirm" |
| 25 | p.PostAction = true |
| 26 | p.ActionLabel = t("confirm_action") |
| 27 | case "unknown": |
| 28 | p.Action = "/signin/local" |
| 29 | p.ActionLabel = t("local_action") |
| 30 | case "signedout": |
| 31 | p.Action = "/signin" |
| 32 | p.ActionLabel = t("signedout_action") |
| 33 | case "success": |
| 34 | p.Action = "/" |
| 35 | p.ActionLabel = t("documents_action") |
| 36 | default: |
| 37 | state = "failed" |
| 38 | p.Action = "/signin/local" |
| 39 | p.ActionLabel = t("local_action") |
| 40 | } |
| 41 | p.Title = t(state + "_title") |
| 42 | p.Body = t(state + "_body") |
| 43 | if state == "start" || state == "confirm" { |
| 44 | p.CancelLabel = t("cancel_action") |
| 45 | } |
| 46 | return p |
| 47 | } |
| 48 | |
| 49 | // English is the copy the apps render for connecting an account. It |
| 50 | // never names the hub: the account is "your Oficina account" (Paul, |
| 51 | // 2026-09-23), worded as Docs' approved docs.home.* strings are. The |
| 52 | // signed-out state speaks the door's words (estilo chrome.English). |
| 53 | var English = map[string]string{ |
| 54 | "signedout_title": "You’re signed out", "signedout_body": "You can sign in again with your Oficina account.", "signedout_action": "Sign in", |
| 55 | "start_title": "Connect your Oficina account", "start_body": "Use your Oficina account to sign in to this account. Your content and sharing settings stay as they are.", "start_action": "Connect", "cancel_action": "Back", |
| 56 | "confirm_title": "Confirm account connection", "confirm_body": "Connect the account below to the Oficina account you just signed in to.", "confirm_action": "Connect accounts", |
| 57 | "unknown_title": "Oficina account not connected", "unknown_body": "Sign in to your existing account, then connect your Oficina account from the account menu.", "local_action": "Sign in to your existing account", |
| 58 | "failed_title": "Could not connect accounts", "failed_body": "Return to the app and start again.", "success_title": "Accounts connected", "success_body": "You can now use your Oficina account to sign in to this account.", "documents_action": "Back to the app", "menu_action": "Connect your Oficina account", |
| 59 | } |
| 60 | |