| 546 | } |
| 547 | |
| 548 | function OAuthAutoView() { |
| 549 | const code = createMemo(() => { |
| 550 | const instructions = store.authorization?.instructions |
| 551 | if (instructions?.includes(":")) { |
| 552 | return instructions.split(":").pop()?.trim() |
| 553 | } |
| 554 | return instructions |
| 555 | }) |
| 556 | |
| 557 | onMount(() => { |
| 558 | void (async () => { |
| 559 | const result = await serverSDK() |
| 560 | .client.provider.oauth.callback({ |
| 561 | providerID: props.provider, |
| 562 | method: store.methodIndex, |
| 563 | }) |
| 564 | .then((value) => (value.error ? { ok: false as const, error: value.error } : { ok: true as const })) |
| 565 | .catch((error) => ({ ok: false as const, error })) |
| 566 | |
| 567 | if (!alive.value) return |
| 568 | |
| 569 | if (!result.ok) { |
| 570 | const message = formatError(result.error, language.t("common.requestFailed")) |
| 571 | dispatch({ type: "auth.error", error: message }) |
| 572 | return |
| 573 | } |
| 574 | |
| 575 | await complete() |
| 576 | })() |
| 577 | }) |
| 578 | |
| 579 | return ( |
| 580 | <div class="flex flex-col gap-6"> |
| 581 | <div class="text-14-regular text-text-base"> |
| 582 | {language.t("provider.connect.oauth.auto.visit.prefix")} |
| 583 | <Link href={store.authorization!.url}>{language.t("provider.connect.oauth.auto.visit.link")}</Link> |
| 584 | {language.t("provider.connect.oauth.auto.visit.suffix", { provider: provider().name })} |
| 585 | </div> |
| 586 | <TextField |
| 587 | label={language.t("provider.connect.oauth.auto.confirmationCode")} |
| 588 | class="font-mono" |
| 589 | value={code()} |
| 590 | readOnly |
| 591 | copyable |
| 592 | /> |
| 593 | <div class="text-14-regular text-text-base flex items-center gap-4"> |
| 594 | <Spinner /> |
| 595 | <span>{language.t("provider.connect.status.waiting")}</span> |
| 596 | </div> |
| 597 | </div> |
| 598 | ) |
| 599 | } |
| 600 | |
| 601 | return ( |
| 602 | <Dialog |