@orechio/platform-angular 0.5.0 → 0.7.1
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/README.md +134 -64
- package/fesm2022/orechio-platform-angular-account-account-client-mPl0tzMg.mjs +56 -0
- package/fesm2022/orechio-platform-angular-account-account-client-mPl0tzMg.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-account-forgot-password.page-L-Z-s49p.mjs +136 -0
- package/fesm2022/orechio-platform-angular-account-forgot-password.page-L-Z-s49p.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-account-initial-branch.page-C8a1eU3L.mjs +121 -0
- package/fesm2022/orechio-platform-angular-account-initial-branch.page-C8a1eU3L.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-account-resend-verification.page-C3lk1vNj.mjs +122 -0
- package/fesm2022/orechio-platform-angular-account-resend-verification.page-C3lk1vNj.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-account-token-password.page-1vn5XGVu.mjs +181 -0
- package/fesm2022/orechio-platform-angular-account-token-password.page-1vn5XGVu.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-account-verify-email.page-xulVDiOn.mjs +121 -0
- package/fesm2022/orechio-platform-angular-account-verify-email.page-xulVDiOn.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-account.mjs +106 -0
- package/fesm2022/orechio-platform-angular-account.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-billing-billing-format-0nlddK-x.mjs +194 -0
- package/fesm2022/orechio-platform-angular-billing-billing-format-0nlddK-x.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-billing-checkout.page-CHU_Drpu.mjs +186 -0
- package/fesm2022/orechio-platform-angular-billing-checkout.page-CHU_Drpu.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-billing-invoice.page-BVyWur3o.mjs +136 -0
- package/fesm2022/orechio-platform-angular-billing-invoice.page-BVyWur3o.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-billing-invoices.page-BiEm3hRf.mjs +105 -0
- package/fesm2022/orechio-platform-angular-billing-invoices.page-BiEm3hRf.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-billing-pix-panel.component-B608dQmc.mjs +81 -0
- package/fesm2022/orechio-platform-angular-billing-pix-panel.component-B608dQmc.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-billing-profile.page-Baa6uoM6.mjs +282 -0
- package/fesm2022/orechio-platform-angular-billing-profile.page-Baa6uoM6.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-billing-subscription.page-9NF8bWhu.mjs +160 -0
- package/fesm2022/orechio-platform-angular-billing-subscription.page-9NF8bWhu.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular-billing.mjs +69 -0
- package/fesm2022/orechio-platform-angular-billing.mjs.map +1 -0
- package/fesm2022/orechio-platform-angular.mjs +62 -62
- package/fesm2022/orechio-platform-angular.mjs.map +1 -1
- package/package.json +9 -1
- package/types/orechio-platform-angular-account.d.ts +97 -0
- package/types/orechio-platform-angular-billing.d.ts +32 -0
package/README.md
CHANGED
|
@@ -1,64 +1,134 @@
|
|
|
1
|
-
# PlatformAngular
|
|
2
|
-
|
|
3
|
-
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 22.1.0.
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
# PlatformAngular
|
|
2
|
+
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 22.1.0.
|
|
4
|
+
|
|
5
|
+
## Entry points
|
|
6
|
+
|
|
7
|
+
| Import | Contents |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `@orechio/platform-angular` | Session, login, interceptors, capabilities, problem-details, pagination. |
|
|
10
|
+
| `@orechio/platform-angular/account` | The shared account onboarding screens (since 0.6.0). |
|
|
11
|
+
| `@orechio/platform-angular/billing` | The account holder's billing screens (since 0.7.0). |
|
|
12
|
+
|
|
13
|
+
### `@orechio/platform-angular/account`
|
|
14
|
+
|
|
15
|
+
Six screens — e-mail verification, first operating unit, password recovery, password reset,
|
|
16
|
+
invite acceptance and verification resend — as routes the host mounts wherever it wants.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { provideOrechioAccount, ORECHIO_ACCOUNT_ROUTES } from '@orechio/platform-angular/account';
|
|
20
|
+
|
|
21
|
+
provideOrechioAccount({
|
|
22
|
+
basePath: '/api/account', // the product's own BFF, same-origin
|
|
23
|
+
branchLabel: 'loja', // whatever the product calls its first unit
|
|
24
|
+
onCompleted: () => '/painel', // where an operational account goes next
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// routes:
|
|
28
|
+
{ path: 'conta', children: ORECHIO_ACCOUNT_ROUTES }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`onCompleted` is required and validated at bootstrap — the package deliberately has no
|
|
32
|
+
default destination, because a wrong one is only discovered by the first real customer
|
|
33
|
+
finishing the flow, once, with no way to retry the step.
|
|
34
|
+
|
|
35
|
+
The host must serve the six routes of **`Orechio.Platform.Bff.Account` 0.1.1 or newer**
|
|
36
|
+
under `basePath`. No token ever reaches the browser: the BFF exchanges with the Platform
|
|
37
|
+
and hands the session to the host's own cookie writer.
|
|
38
|
+
|
|
39
|
+
### Cobrança — `@orechio/platform-angular/billing`
|
|
40
|
+
|
|
41
|
+
As telas de cobrança do titular (ADR-021 §3.5): situação da assinatura, dados de cobrança,
|
|
42
|
+
pagar por PIX e faturas.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { provideOrechioBilling, ORECHIO_BILLING_ROUTES } from '@orechio/platform-angular/billing';
|
|
46
|
+
|
|
47
|
+
provideOrechioBilling(); // basePath default: '/api/billing'
|
|
48
|
+
provideOrechioBilling({ basePath: '/bff/cobranca' }); // se o host mudou o prefixo no BFF
|
|
49
|
+
|
|
50
|
+
// rotas — em /billing, sempre:
|
|
51
|
+
{ path: 'billing', children: ORECHIO_BILLING_ROUTES }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Monte em `/billing`.** Os e-mails de cobrança da Platform apontam para `{base}/billing`
|
|
55
|
+
(ADR-021 §3.2); montar em outro caminho quebra todo link já enviado.
|
|
56
|
+
|
|
57
|
+
**O que o host precisa ter no BFF:** `Orechio.Platform.Bff.Account` **0.2.0** com
|
|
58
|
+
`app.MapOrechioBillingEndpoints()` — as rotas de cobrança são opt-in no BFF. O prefixo do BFF
|
|
59
|
+
(`BillingRoutePrefix`, default `/api/billing`) e o `basePath` daqui têm de ser o mesmo. A
|
|
60
|
+
sessão é a que o host já registra como `IAccountSessionAccessor` para o onboarding; nenhum
|
|
61
|
+
token chega ao browser.
|
|
62
|
+
|
|
63
|
+
| Tela | Rota | Chama no BFF |
|
|
64
|
+
| --- | --- | --- |
|
|
65
|
+
| Situação | `/billing` | `GET subscription` · `GET invoices` (só em carência e suspensão) |
|
|
66
|
+
| Dados de cobrança | `/billing/profile` | `GET profile` · `POST profile` · `PATCH profile/contact` · `PATCH profile/address` |
|
|
67
|
+
| Pagar | `/billing/checkout` | `GET subscription` · `GET profile` · `GET pricing/preview` (um por ciclo) · `POST checkout` |
|
|
68
|
+
| Faturas | `/billing/invoices` | `GET invoices` |
|
|
69
|
+
| Fatura | `/billing/invoices/:id` | `GET invoices/{id}` · `POST invoices/{id}/refresh` |
|
|
70
|
+
|
|
71
|
+
A v1 mostra só PIX; trocar de plano, cancelar e reativar ficam para a v2. Erros aparecem em
|
|
72
|
+
português por `code`; um `code` desconhecido mostra uma mensagem genérica com o
|
|
73
|
+
`correlation_id`, que é o que o suporte usa para achar o caso no log.
|
|
74
|
+
|
|
75
|
+
## Code scaffolding
|
|
76
|
+
|
|
77
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
ng generate component component-name
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
ng generate --help
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Building
|
|
90
|
+
|
|
91
|
+
To build the library, run:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
ng build platform-angular
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
98
|
+
|
|
99
|
+
### Publishing the Library
|
|
100
|
+
|
|
101
|
+
Once the project is built, you can publish your library by following these steps:
|
|
102
|
+
|
|
103
|
+
1. Navigate to the `dist` directory:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
cd dist/platform-angular
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
110
|
+
```bash
|
|
111
|
+
npm publish
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Running unit tests
|
|
115
|
+
|
|
116
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
ng test
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Running end-to-end tests
|
|
123
|
+
|
|
124
|
+
For end-to-end (e2e) testing, run:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
ng e2e
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
131
|
+
|
|
132
|
+
## Additional Resources
|
|
133
|
+
|
|
134
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, Injectable } from '@angular/core';
|
|
4
|
+
import { map, catchError, throwError } from 'rxjs';
|
|
5
|
+
import { normalizeProblemDetails } from '@orechio/platform-angular';
|
|
6
|
+
import { ORECHIO_ACCOUNT_CONFIG } from './orechio-platform-angular-account.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* O cliente do BFF de conta.
|
|
10
|
+
*
|
|
11
|
+
* <p>
|
|
12
|
+
* Fala só com o BFF do próprio host, same-origin — nunca com a Platform. É essa indireção
|
|
13
|
+
* que mantém o token fora do browser: o BFF recebe o par da Platform, entrega ao mecanismo
|
|
14
|
+
* de sessão, e devolve aqui apenas estado.
|
|
15
|
+
* </p>
|
|
16
|
+
*
|
|
17
|
+
* <p>
|
|
18
|
+
* Todo erro sai normalizado como <c>ProblemDetails</c>, reusando o
|
|
19
|
+
* <c>normalizeProblemDetails</c> do entry primário. Um segundo normalizador aqui divergiria
|
|
20
|
+
* do primeiro na primeira mudança de contrato.
|
|
21
|
+
* </p>
|
|
22
|
+
*/
|
|
23
|
+
class AccountClient {
|
|
24
|
+
http = inject(HttpClient);
|
|
25
|
+
config = inject(ORECHIO_ACCOUNT_CONFIG);
|
|
26
|
+
verifyEmail(token) {
|
|
27
|
+
return this.post(this.config.paths.verifyEmail, { token });
|
|
28
|
+
}
|
|
29
|
+
createInitialBranch(name) {
|
|
30
|
+
return this.post(this.config.paths.initialBranch, { name });
|
|
31
|
+
}
|
|
32
|
+
forgotPassword(email) {
|
|
33
|
+
return this.post(this.config.paths.forgotPassword, { email });
|
|
34
|
+
}
|
|
35
|
+
resetPassword(token, newPassword) {
|
|
36
|
+
return this.post(this.config.paths.resetPassword, { token, newPassword });
|
|
37
|
+
}
|
|
38
|
+
acceptInvite(token, password) {
|
|
39
|
+
return this.post(this.config.paths.acceptInvite, { token, password });
|
|
40
|
+
}
|
|
41
|
+
resendVerification(email) {
|
|
42
|
+
return this.post(this.config.paths.resendVerification, { email });
|
|
43
|
+
}
|
|
44
|
+
post(path, body) {
|
|
45
|
+
return this.http.post(`${this.config.basePath}${path}`, body).pipe(map((response) => response), catchError((error) => throwError(() => normalizeProblemDetails(error))));
|
|
46
|
+
}
|
|
47
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.2", ngImport: i0, type: AccountClient, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
48
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.2", ngImport: i0, type: AccountClient, providedIn: 'root' });
|
|
49
|
+
}
|
|
50
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.2", ngImport: i0, type: AccountClient, decorators: [{
|
|
51
|
+
type: Injectable,
|
|
52
|
+
args: [{ providedIn: 'root' }]
|
|
53
|
+
}] });
|
|
54
|
+
|
|
55
|
+
export { AccountClient as A };
|
|
56
|
+
//# sourceMappingURL=orechio-platform-angular-account-account-client-mPl0tzMg.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orechio-platform-angular-account-account-client-mPl0tzMg.mjs","sources":["../../../projects/platform-angular/account/src/account-client.ts"],"sourcesContent":["import { HttpClient, HttpErrorResponse } from '@angular/common/http';\r\nimport { Injectable, inject } from '@angular/core';\r\nimport { Observable, catchError, map, throwError } from 'rxjs';\r\nimport { ProblemDetails, normalizeProblemDetails } from '@orechio/platform-angular';\r\nimport { AccountCompletionResult, ORECHIO_ACCOUNT_CONFIG } from './account-config';\r\n\r\nexport interface VerifyEmailResult {\r\n status: string;\r\n provisioningRequired: boolean;\r\n}\r\n\r\n/** Resposta dos fluxos anti-enumeration. Opaca por desenho. */\r\nexport interface OpaqueAcknowledgement {\r\n message: string;\r\n}\r\n\r\n/**\r\n * O cliente do BFF de conta.\r\n *\r\n * <p>\r\n * Fala só com o BFF do próprio host, same-origin — nunca com a Platform. É essa indireção\r\n * que mantém o token fora do browser: o BFF recebe o par da Platform, entrega ao mecanismo\r\n * de sessão, e devolve aqui apenas estado.\r\n * </p>\r\n *\r\n * <p>\r\n * Todo erro sai normalizado como <c>ProblemDetails</c>, reusando o\r\n * <c>normalizeProblemDetails</c> do entry primário. Um segundo normalizador aqui divergiria\r\n * do primeiro na primeira mudança de contrato.\r\n * </p>\r\n */\r\n@Injectable({ providedIn: 'root' })\r\nexport class AccountClient {\r\n private readonly http = inject(HttpClient);\r\n private readonly config = inject(ORECHIO_ACCOUNT_CONFIG);\r\n\r\n verifyEmail(token: string): Observable<VerifyEmailResult> {\r\n return this.post<VerifyEmailResult>(this.config.paths.verifyEmail, { token });\r\n }\r\n\r\n createInitialBranch(name: string): Observable<AccountCompletionResult> {\r\n return this.post<AccountCompletionResult>(this.config.paths.initialBranch, { name });\r\n }\r\n\r\n forgotPassword(email: string): Observable<OpaqueAcknowledgement> {\r\n return this.post<OpaqueAcknowledgement>(this.config.paths.forgotPassword, { email });\r\n }\r\n\r\n resetPassword(token: string, newPassword: string): Observable<OpaqueAcknowledgement> {\r\n return this.post<OpaqueAcknowledgement>(this.config.paths.resetPassword, { token, newPassword });\r\n }\r\n\r\n acceptInvite(token: string, password: string): Observable<OpaqueAcknowledgement> {\r\n return this.post<OpaqueAcknowledgement>(this.config.paths.acceptInvite, { token, password });\r\n }\r\n\r\n resendVerification(email: string): Observable<OpaqueAcknowledgement> {\r\n return this.post<OpaqueAcknowledgement>(this.config.paths.resendVerification, { email });\r\n }\r\n\r\n private post<T>(path: string, body: unknown): Observable<T> {\r\n return this.http.post<T>(`${this.config.basePath}${path}`, body).pipe(\r\n map((response) => response as T),\r\n catchError((error: HttpErrorResponse) =>\r\n throwError((): ProblemDetails => normalizeProblemDetails(error)),\r\n ),\r\n );\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;AAgBA;;;;;;;;;;;;;;AAcG;MAEU,aAAa,CAAA;AACP,IAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;AACzB,IAAA,MAAM,GAAG,MAAM,CAAC,sBAAsB,CAAC;AAExD,IAAA,WAAW,CAAC,KAAa,EAAA;AACvB,QAAA,OAAO,IAAI,CAAC,IAAI,CAAoB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC;IAC/E;AAEA,IAAA,mBAAmB,CAAC,IAAY,EAAA;AAC9B,QAAA,OAAO,IAAI,CAAC,IAAI,CAA0B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,CAAC;IACtF;AAEA,IAAA,cAAc,CAAC,KAAa,EAAA;AAC1B,QAAA,OAAO,IAAI,CAAC,IAAI,CAAwB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC;IACtF;IAEA,aAAa,CAAC,KAAa,EAAE,WAAmB,EAAA;AAC9C,QAAA,OAAO,IAAI,CAAC,IAAI,CAAwB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;IAClG;IAEA,YAAY,CAAC,KAAa,EAAE,QAAgB,EAAA;AAC1C,QAAA,OAAO,IAAI,CAAC,IAAI,CAAwB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAC9F;AAEA,IAAA,kBAAkB,CAAC,KAAa,EAAA;AAC9B,QAAA,OAAO,IAAI,CAAC,IAAI,CAAwB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,CAAC;IAC1F;IAEQ,IAAI,CAAI,IAAY,EAAE,IAAa,EAAA;QACzC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAI,CAAA,EAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAA,EAAG,IAAI,CAAA,CAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CACnE,GAAG,CAAC,CAAC,QAAQ,KAAK,QAAa,CAAC,EAChC,UAAU,CAAC,CAAC,KAAwB,KAClC,UAAU,CAAC,MAAsB,uBAAuB,CAAC,KAAK,CAAC,CAAC,CACjE,CACF;IACH;uGAnCW,aAAa,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAb,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,aAAa,cADA,MAAM,EAAA,CAAA;;2FACnB,aAAa,EAAA,UAAA,EAAA,CAAA;kBADzB,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;;;"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, signal, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/forms';
|
|
4
|
+
import { FormsModule } from '@angular/forms';
|
|
5
|
+
import { A as AccountClient } from './orechio-platform-angular-account-account-client-mPl0tzMg.mjs';
|
|
6
|
+
|
|
7
|
+
class ForgotPasswordPage {
|
|
8
|
+
client = inject(AccountClient);
|
|
9
|
+
email = '';
|
|
10
|
+
enviando = signal(false, /* @ts-ignore */
|
|
11
|
+
...(ngDevMode ? [{ debugName: "enviando" }] : /* istanbul ignore next */ []));
|
|
12
|
+
enviado = signal(false, /* @ts-ignore */
|
|
13
|
+
...(ngDevMode ? [{ debugName: "enviado" }] : /* istanbul ignore next */ []));
|
|
14
|
+
erro = signal(null, /* @ts-ignore */
|
|
15
|
+
...(ngDevMode ? [{ debugName: "erro" }] : /* istanbul ignore next */ []));
|
|
16
|
+
mensagemDeErro() {
|
|
17
|
+
const code = this.erro()?.code;
|
|
18
|
+
if (code === 'rate_limit_exceeded')
|
|
19
|
+
return 'Muitas tentativas. Aguarde alguns minutos.';
|
|
20
|
+
if (code === 'platform.unavailable')
|
|
21
|
+
return 'Serviço indisponível. Tente novamente em instantes.';
|
|
22
|
+
return 'Não foi possível enviar. Tente novamente.';
|
|
23
|
+
}
|
|
24
|
+
enviar() {
|
|
25
|
+
const email = this.email.trim();
|
|
26
|
+
if (!email || this.enviando())
|
|
27
|
+
return;
|
|
28
|
+
this.enviando.set(true);
|
|
29
|
+
this.erro.set(null);
|
|
30
|
+
this.client.forgotPassword(email).subscribe({
|
|
31
|
+
// Sucesso é sucesso, sem olhar o corpo: a resposta é opaca por desenho, e inspecioná-la
|
|
32
|
+
// para decidir o texto seria a porta dos fundos da enumeração.
|
|
33
|
+
next: () => {
|
|
34
|
+
this.enviado.set(true);
|
|
35
|
+
this.enviando.set(false);
|
|
36
|
+
},
|
|
37
|
+
error: (problema) => {
|
|
38
|
+
this.erro.set(problema);
|
|
39
|
+
this.enviando.set(false);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.2", ngImport: i0, type: ForgotPasswordPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
44
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.2", type: ForgotPasswordPage, isStandalone: true, selector: "orechio-account-forgot-password", ngImport: i0, template: `
|
|
45
|
+
<section class="orechio-account">
|
|
46
|
+
<ng-content select="[orechioAccountBrand]"></ng-content>
|
|
47
|
+
|
|
48
|
+
@if (enviado()) {
|
|
49
|
+
<h1>Verifique seu e-mail</h1>
|
|
50
|
+
<!--
|
|
51
|
+
O texto NÃO confirma que a conta existe, e isso é deliberado.
|
|
52
|
+
|
|
53
|
+
A Platform responde 202 idêntico para e-mail conhecido e desconhecido — defesa
|
|
54
|
+
anti-enumeration, provada byte a byte no ACCOUNT-1B. Uma tela que dissesse
|
|
55
|
+
"enviamos para você" só quando a conta existe desfaria a defesa na camada de cima:
|
|
56
|
+
bastaria comparar as duas telas para descobrir quem tem conta aqui.
|
|
57
|
+
-->
|
|
58
|
+
<p>Se houver uma conta com esse endereço, as instruções chegarão em instantes.</p>
|
|
59
|
+
<p class="orechio-account__muted">Confira também a caixa de spam.</p>
|
|
60
|
+
} @else {
|
|
61
|
+
<h1>Recuperar acesso</h1>
|
|
62
|
+
<p class="orechio-account__muted">Informe o e-mail da sua conta.</p>
|
|
63
|
+
|
|
64
|
+
<form (ngSubmit)="enviar()">
|
|
65
|
+
<label for="orechio-account-forgot-email">E-mail</label>
|
|
66
|
+
<input
|
|
67
|
+
id="orechio-account-forgot-email"
|
|
68
|
+
name="email"
|
|
69
|
+
type="email"
|
|
70
|
+
autocomplete="email"
|
|
71
|
+
[(ngModel)]="email"
|
|
72
|
+
[disabled]="enviando()"
|
|
73
|
+
required
|
|
74
|
+
/>
|
|
75
|
+
|
|
76
|
+
@if (erro()) {
|
|
77
|
+
<p class="orechio-account__error">{{ mensagemDeErro() }}</p>
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
<button type="submit" [disabled]="enviando() || !email.trim()">
|
|
81
|
+
{{ enviando() ? 'Enviando…' : 'Enviar instruções' }}
|
|
82
|
+
</button>
|
|
83
|
+
</form>
|
|
84
|
+
}
|
|
85
|
+
</section>
|
|
86
|
+
`, isInline: true, styles: [".orechio-account{display:flex;flex-direction:column;gap:var(--orechio-space-3, .75rem);max-width:28rem;margin:0 auto;padding:var(--orechio-space-6, 1.5rem);color:var(--orechio-color-text, inherit);font-family:var(--orechio-font-body, inherit)}.orechio-account form{display:flex;flex-direction:column;gap:var(--orechio-space-2, .5rem)}.orechio-account__muted{color:var(--orechio-color-text-muted, #666)}.orechio-account__error{color:var(--orechio-color-danger, #b00020)}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i1.NgForm, selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
87
|
+
}
|
|
88
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.2", ngImport: i0, type: ForgotPasswordPage, decorators: [{
|
|
89
|
+
type: Component,
|
|
90
|
+
args: [{ selector: 'orechio-account-forgot-password', standalone: true, imports: [FormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
91
|
+
<section class="orechio-account">
|
|
92
|
+
<ng-content select="[orechioAccountBrand]"></ng-content>
|
|
93
|
+
|
|
94
|
+
@if (enviado()) {
|
|
95
|
+
<h1>Verifique seu e-mail</h1>
|
|
96
|
+
<!--
|
|
97
|
+
O texto NÃO confirma que a conta existe, e isso é deliberado.
|
|
98
|
+
|
|
99
|
+
A Platform responde 202 idêntico para e-mail conhecido e desconhecido — defesa
|
|
100
|
+
anti-enumeration, provada byte a byte no ACCOUNT-1B. Uma tela que dissesse
|
|
101
|
+
"enviamos para você" só quando a conta existe desfaria a defesa na camada de cima:
|
|
102
|
+
bastaria comparar as duas telas para descobrir quem tem conta aqui.
|
|
103
|
+
-->
|
|
104
|
+
<p>Se houver uma conta com esse endereço, as instruções chegarão em instantes.</p>
|
|
105
|
+
<p class="orechio-account__muted">Confira também a caixa de spam.</p>
|
|
106
|
+
} @else {
|
|
107
|
+
<h1>Recuperar acesso</h1>
|
|
108
|
+
<p class="orechio-account__muted">Informe o e-mail da sua conta.</p>
|
|
109
|
+
|
|
110
|
+
<form (ngSubmit)="enviar()">
|
|
111
|
+
<label for="orechio-account-forgot-email">E-mail</label>
|
|
112
|
+
<input
|
|
113
|
+
id="orechio-account-forgot-email"
|
|
114
|
+
name="email"
|
|
115
|
+
type="email"
|
|
116
|
+
autocomplete="email"
|
|
117
|
+
[(ngModel)]="email"
|
|
118
|
+
[disabled]="enviando()"
|
|
119
|
+
required
|
|
120
|
+
/>
|
|
121
|
+
|
|
122
|
+
@if (erro()) {
|
|
123
|
+
<p class="orechio-account__error">{{ mensagemDeErro() }}</p>
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
<button type="submit" [disabled]="enviando() || !email.trim()">
|
|
127
|
+
{{ enviando() ? 'Enviando…' : 'Enviar instruções' }}
|
|
128
|
+
</button>
|
|
129
|
+
</form>
|
|
130
|
+
}
|
|
131
|
+
</section>
|
|
132
|
+
`, styles: [".orechio-account{display:flex;flex-direction:column;gap:var(--orechio-space-3, .75rem);max-width:28rem;margin:0 auto;padding:var(--orechio-space-6, 1.5rem);color:var(--orechio-color-text, inherit);font-family:var(--orechio-font-body, inherit)}.orechio-account form{display:flex;flex-direction:column;gap:var(--orechio-space-2, .5rem)}.orechio-account__muted{color:var(--orechio-color-text-muted, #666)}.orechio-account__error{color:var(--orechio-color-danger, #b00020)}\n"] }]
|
|
133
|
+
}] });
|
|
134
|
+
|
|
135
|
+
export { ForgotPasswordPage };
|
|
136
|
+
//# sourceMappingURL=orechio-platform-angular-account-forgot-password.page-L-Z-s49p.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orechio-platform-angular-account-forgot-password.page-L-Z-s49p.mjs","sources":["../../../projects/platform-angular/account/src/pages/forgot-password.page.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';\r\nimport { FormsModule } from '@angular/forms';\r\nimport { ProblemDetails } from '@orechio/platform-angular';\r\nimport { AccountClient } from '../account-client';\r\n\r\n@Component({\r\n selector: 'orechio-account-forgot-password',\r\n standalone: true,\r\n imports: [FormsModule],\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n template: `\r\n <section class=\"orechio-account\">\r\n <ng-content select=\"[orechioAccountBrand]\"></ng-content>\r\n\r\n @if (enviado()) {\r\n <h1>Verifique seu e-mail</h1>\r\n <!--\r\n O texto NÃO confirma que a conta existe, e isso é deliberado.\r\n\r\n A Platform responde 202 idêntico para e-mail conhecido e desconhecido — defesa\r\n anti-enumeration, provada byte a byte no ACCOUNT-1B. Uma tela que dissesse\r\n \"enviamos para você\" só quando a conta existe desfaria a defesa na camada de cima:\r\n bastaria comparar as duas telas para descobrir quem tem conta aqui.\r\n -->\r\n <p>Se houver uma conta com esse endereço, as instruções chegarão em instantes.</p>\r\n <p class=\"orechio-account__muted\">Confira também a caixa de spam.</p>\r\n } @else {\r\n <h1>Recuperar acesso</h1>\r\n <p class=\"orechio-account__muted\">Informe o e-mail da sua conta.</p>\r\n\r\n <form (ngSubmit)=\"enviar()\">\r\n <label for=\"orechio-account-forgot-email\">E-mail</label>\r\n <input\r\n id=\"orechio-account-forgot-email\"\r\n name=\"email\"\r\n type=\"email\"\r\n autocomplete=\"email\"\r\n [(ngModel)]=\"email\"\r\n [disabled]=\"enviando()\"\r\n required\r\n />\r\n\r\n @if (erro()) {\r\n <p class=\"orechio-account__error\">{{ mensagemDeErro() }}</p>\r\n }\r\n\r\n <button type=\"submit\" [disabled]=\"enviando() || !email.trim()\">\r\n {{ enviando() ? 'Enviando…' : 'Enviar instruções' }}\r\n </button>\r\n </form>\r\n }\r\n </section>\r\n `,\r\n styles: `\r\n .orechio-account {\r\n display: flex;\r\n flex-direction: column;\r\n gap: var(--orechio-space-3, 0.75rem);\r\n max-width: 28rem;\r\n margin: 0 auto;\r\n padding: var(--orechio-space-6, 1.5rem);\r\n color: var(--orechio-color-text, inherit);\r\n font-family: var(--orechio-font-body, inherit);\r\n }\r\n .orechio-account form { display: flex; flex-direction: column; gap: var(--orechio-space-2, 0.5rem); }\r\n .orechio-account__muted { color: var(--orechio-color-text-muted, #666); }\r\n .orechio-account__error { color: var(--orechio-color-danger, #b00020); }\r\n `,\r\n})\r\nexport class ForgotPasswordPage {\r\n private readonly client = inject(AccountClient);\r\n\r\n protected email = '';\r\n protected readonly enviando = signal(false);\r\n protected readonly enviado = signal(false);\r\n protected readonly erro = signal<ProblemDetails | null>(null);\r\n\r\n protected mensagemDeErro(): string {\r\n const code = this.erro()?.code;\r\n if (code === 'rate_limit_exceeded') return 'Muitas tentativas. Aguarde alguns minutos.';\r\n if (code === 'platform.unavailable') return 'Serviço indisponível. Tente novamente em instantes.';\r\n return 'Não foi possível enviar. Tente novamente.';\r\n }\r\n\r\n protected enviar(): void {\r\n const email = this.email.trim();\r\n if (!email || this.enviando()) return;\r\n\r\n this.enviando.set(true);\r\n this.erro.set(null);\r\n\r\n this.client.forgotPassword(email).subscribe({\r\n // Sucesso é sucesso, sem olhar o corpo: a resposta é opaca por desenho, e inspecioná-la\r\n // para decidir o texto seria a porta dos fundos da enumeração.\r\n next: () => {\r\n this.enviado.set(true);\r\n this.enviando.set(false);\r\n },\r\n error: (problema: ProblemDetails) => {\r\n this.erro.set(problema);\r\n this.enviando.set(false);\r\n },\r\n });\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;MAqEa,kBAAkB,CAAA;AACZ,IAAA,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;IAErC,KAAK,GAAG,EAAE;IACD,QAAQ,GAAG,MAAM,CAAC,KAAK;iFAAC;IACxB,OAAO,GAAG,MAAM,CAAC,KAAK;gFAAC;IACvB,IAAI,GAAG,MAAM,CAAwB,IAAI;6EAAC;IAEnD,cAAc,GAAA;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI;QAC9B,IAAI,IAAI,KAAK,qBAAqB;AAAE,YAAA,OAAO,4CAA4C;QACvF,IAAI,IAAI,KAAK,sBAAsB;AAAE,YAAA,OAAO,qDAAqD;AACjG,QAAA,OAAO,2CAA2C;IACpD;IAEU,MAAM,GAAA;QACd,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;AAC/B,QAAA,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE;YAAE;AAE/B,QAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;AACvB,QAAA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QAEn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@angular/forms';
|
|
4
|
+
import { FormsModule } from '@angular/forms';
|
|
5
|
+
import { Router } from '@angular/router';
|
|
6
|
+
import { A as AccountClient } from './orechio-platform-angular-account-account-client-mPl0tzMg.mjs';
|
|
7
|
+
import { ORECHIO_ACCOUNT_CONFIG } from './orechio-platform-angular-account.mjs';
|
|
8
|
+
|
|
9
|
+
class InitialBranchPage {
|
|
10
|
+
router = inject(Router);
|
|
11
|
+
client = inject(AccountClient);
|
|
12
|
+
config = inject(ORECHIO_ACCOUNT_CONFIG);
|
|
13
|
+
rotulo = this.config.branchLabel;
|
|
14
|
+
nome = '';
|
|
15
|
+
enviando = signal(false, /* @ts-ignore */
|
|
16
|
+
...(ngDevMode ? [{ debugName: "enviando" }] : /* istanbul ignore next */ []));
|
|
17
|
+
erro = signal(null, /* @ts-ignore */
|
|
18
|
+
...(ngDevMode ? [{ debugName: "erro" }] : /* istanbul ignore next */ []));
|
|
19
|
+
mensagemDeErro() {
|
|
20
|
+
const code = this.erro()?.code;
|
|
21
|
+
if (code === 'onboarding.branch_already_exists')
|
|
22
|
+
return `Esta ${this.rotulo} já foi criada.`;
|
|
23
|
+
if (code === 'session.missing')
|
|
24
|
+
return 'Sua sessão expirou. Abra o link do e-mail novamente.';
|
|
25
|
+
if (code === 'onboarding.not_in_provisioning')
|
|
26
|
+
return 'Este passo já foi concluído.';
|
|
27
|
+
if (code === 'rate_limit_exceeded')
|
|
28
|
+
return 'Muitas tentativas. Aguarde alguns minutos.';
|
|
29
|
+
if (code?.startsWith('branch.'))
|
|
30
|
+
return 'Escolha um nome válido.';
|
|
31
|
+
return 'Não foi possível concluir. Tente novamente.';
|
|
32
|
+
}
|
|
33
|
+
enviar() {
|
|
34
|
+
const nome = this.nome.trim();
|
|
35
|
+
if (!nome || this.enviando())
|
|
36
|
+
return;
|
|
37
|
+
this.enviando.set(true);
|
|
38
|
+
this.erro.set(null);
|
|
39
|
+
this.client.createInitialBranch(nome).subscribe({
|
|
40
|
+
next: async (resultado) => {
|
|
41
|
+
// O pacote entrega o resultado e sai. Quem decide para onde ir é o host —
|
|
42
|
+
// `nextStep` é repassado inteiro, sem interpretação (ADR-019 §3).
|
|
43
|
+
const destino = this.config.onCompleted(resultado);
|
|
44
|
+
await this.router.navigateByUrl(destino, { replaceUrl: true });
|
|
45
|
+
},
|
|
46
|
+
error: (problema) => {
|
|
47
|
+
this.erro.set(problema);
|
|
48
|
+
this.enviando.set(false);
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.2", ngImport: i0, type: InitialBranchPage, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
53
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.2", type: InitialBranchPage, isStandalone: true, selector: "orechio-account-initial-branch", ngImport: i0, template: `
|
|
54
|
+
<section class="orechio-account">
|
|
55
|
+
<ng-content select="[orechioAccountBrand]"></ng-content>
|
|
56
|
+
|
|
57
|
+
<h1>Configure sua primeira {{ rotulo }}</h1>
|
|
58
|
+
<p class="orechio-account__muted">
|
|
59
|
+
É onde seus lançamentos vão nascer. Dá para criar outras depois.
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
<form (ngSubmit)="enviar()">
|
|
63
|
+
<label for="orechio-account-branch-name">Nome da {{ rotulo }}</label>
|
|
64
|
+
<input
|
|
65
|
+
id="orechio-account-branch-name"
|
|
66
|
+
name="nome"
|
|
67
|
+
type="text"
|
|
68
|
+
autocomplete="organization"
|
|
69
|
+
[(ngModel)]="nome"
|
|
70
|
+
[disabled]="enviando()"
|
|
71
|
+
required
|
|
72
|
+
/>
|
|
73
|
+
|
|
74
|
+
@if (erro()) {
|
|
75
|
+
<p class="orechio-account__error">{{ mensagemDeErro() }}</p>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
<button type="submit" [disabled]="enviando() || !nome.trim()">
|
|
79
|
+
{{ enviando() ? 'Criando…' : 'Concluir' }}
|
|
80
|
+
</button>
|
|
81
|
+
</form>
|
|
82
|
+
</section>
|
|
83
|
+
`, isInline: true, styles: [".orechio-account{display:flex;flex-direction:column;gap:var(--orechio-space-3, .75rem);max-width:28rem;margin:0 auto;padding:var(--orechio-space-6, 1.5rem);color:var(--orechio-color-text, inherit);font-family:var(--orechio-font-body, inherit)}.orechio-account form{display:flex;flex-direction:column;gap:var(--orechio-space-2, .5rem)}.orechio-account__muted{color:var(--orechio-color-text-muted, #666)}.orechio-account__error{color:var(--orechio-color-danger, #b00020)}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i1.NgForm, selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
84
|
+
}
|
|
85
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.2", ngImport: i0, type: InitialBranchPage, decorators: [{
|
|
86
|
+
type: Component,
|
|
87
|
+
args: [{ selector: 'orechio-account-initial-branch', standalone: true, imports: [FormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
88
|
+
<section class="orechio-account">
|
|
89
|
+
<ng-content select="[orechioAccountBrand]"></ng-content>
|
|
90
|
+
|
|
91
|
+
<h1>Configure sua primeira {{ rotulo }}</h1>
|
|
92
|
+
<p class="orechio-account__muted">
|
|
93
|
+
É onde seus lançamentos vão nascer. Dá para criar outras depois.
|
|
94
|
+
</p>
|
|
95
|
+
|
|
96
|
+
<form (ngSubmit)="enviar()">
|
|
97
|
+
<label for="orechio-account-branch-name">Nome da {{ rotulo }}</label>
|
|
98
|
+
<input
|
|
99
|
+
id="orechio-account-branch-name"
|
|
100
|
+
name="nome"
|
|
101
|
+
type="text"
|
|
102
|
+
autocomplete="organization"
|
|
103
|
+
[(ngModel)]="nome"
|
|
104
|
+
[disabled]="enviando()"
|
|
105
|
+
required
|
|
106
|
+
/>
|
|
107
|
+
|
|
108
|
+
@if (erro()) {
|
|
109
|
+
<p class="orechio-account__error">{{ mensagemDeErro() }}</p>
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
<button type="submit" [disabled]="enviando() || !nome.trim()">
|
|
113
|
+
{{ enviando() ? 'Criando…' : 'Concluir' }}
|
|
114
|
+
</button>
|
|
115
|
+
</form>
|
|
116
|
+
</section>
|
|
117
|
+
`, styles: [".orechio-account{display:flex;flex-direction:column;gap:var(--orechio-space-3, .75rem);max-width:28rem;margin:0 auto;padding:var(--orechio-space-6, 1.5rem);color:var(--orechio-color-text, inherit);font-family:var(--orechio-font-body, inherit)}.orechio-account form{display:flex;flex-direction:column;gap:var(--orechio-space-2, .5rem)}.orechio-account__muted{color:var(--orechio-color-text-muted, #666)}.orechio-account__error{color:var(--orechio-color-danger, #b00020)}\n"] }]
|
|
118
|
+
}] });
|
|
119
|
+
|
|
120
|
+
export { InitialBranchPage };
|
|
121
|
+
//# sourceMappingURL=orechio-platform-angular-account-initial-branch.page-C8a1eU3L.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orechio-platform-angular-account-initial-branch.page-C8a1eU3L.mjs","sources":["../../../projects/platform-angular/account/src/pages/initial-branch.page.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';\r\nimport { FormsModule } from '@angular/forms';\r\nimport { Router } from '@angular/router';\r\nimport { ProblemDetails } from '@orechio/platform-angular';\r\nimport { AccountClient } from '../account-client';\r\nimport { ORECHIO_ACCOUNT_CONFIG } from '../account-config';\r\n\r\n@Component({\r\n selector: 'orechio-account-initial-branch',\r\n standalone: true,\r\n imports: [FormsModule],\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n template: `\r\n <section class=\"orechio-account\">\r\n <ng-content select=\"[orechioAccountBrand]\"></ng-content>\r\n\r\n <h1>Configure sua primeira {{ rotulo }}</h1>\r\n <p class=\"orechio-account__muted\">\r\n É onde seus lançamentos vão nascer. Dá para criar outras depois.\r\n </p>\r\n\r\n <form (ngSubmit)=\"enviar()\">\r\n <label for=\"orechio-account-branch-name\">Nome da {{ rotulo }}</label>\r\n <input\r\n id=\"orechio-account-branch-name\"\r\n name=\"nome\"\r\n type=\"text\"\r\n autocomplete=\"organization\"\r\n [(ngModel)]=\"nome\"\r\n [disabled]=\"enviando()\"\r\n required\r\n />\r\n\r\n @if (erro()) {\r\n <p class=\"orechio-account__error\">{{ mensagemDeErro() }}</p>\r\n }\r\n\r\n <button type=\"submit\" [disabled]=\"enviando() || !nome.trim()\">\r\n {{ enviando() ? 'Criando…' : 'Concluir' }}\r\n </button>\r\n </form>\r\n </section>\r\n `,\r\n styles: `\r\n .orechio-account {\r\n display: flex;\r\n flex-direction: column;\r\n gap: var(--orechio-space-3, 0.75rem);\r\n max-width: 28rem;\r\n margin: 0 auto;\r\n padding: var(--orechio-space-6, 1.5rem);\r\n color: var(--orechio-color-text, inherit);\r\n font-family: var(--orechio-font-body, inherit);\r\n }\r\n .orechio-account form { display: flex; flex-direction: column; gap: var(--orechio-space-2, 0.5rem); }\r\n .orechio-account__muted { color: var(--orechio-color-text-muted, #666); }\r\n .orechio-account__error { color: var(--orechio-color-danger, #b00020); }\r\n `,\r\n})\r\nexport class InitialBranchPage {\r\n private readonly router = inject(Router);\r\n private readonly client = inject(AccountClient);\r\n private readonly config = inject(ORECHIO_ACCOUNT_CONFIG);\r\n\r\n protected readonly rotulo = this.config.branchLabel;\r\n protected nome = '';\r\n protected readonly enviando = signal(false);\r\n protected readonly erro = signal<ProblemDetails | null>(null);\r\n\r\n protected mensagemDeErro(): string {\r\n const code = this.erro()?.code;\r\n if (code === 'onboarding.branch_already_exists') return `Esta ${this.rotulo} já foi criada.`;\r\n if (code === 'session.missing') return 'Sua sessão expirou. Abra o link do e-mail novamente.';\r\n if (code === 'onboarding.not_in_provisioning') return 'Este passo já foi concluído.';\r\n if (code === 'rate_limit_exceeded') return 'Muitas tentativas. Aguarde alguns minutos.';\r\n if (code?.startsWith('branch.')) return 'Escolha um nome válido.';\r\n return 'Não foi possível concluir. Tente novamente.';\r\n }\r\n\r\n protected enviar(): void {\r\n const nome = this.nome.trim();\r\n if (!nome || this.enviando()) return;\r\n\r\n this.enviando.set(true);\r\n this.erro.set(null);\r\n\r\n this.client.createInitialBranch(nome).subscribe({\r\n next: async (resultado) => {\r\n // O pacote entrega o resultado e sai. Quem decide para onde ir é o host —\r\n // `nextStep` é repassado inteiro, sem interpretação (ADR-019 §3).\r\n const destino = this.config.onCompleted(resultado);\r\n await this.router.navigateByUrl(destino, { replaceUrl: true });\r\n },\r\n error: (problema: ProblemDetails) => {\r\n this.erro.set(problema);\r\n this.enviando.set(false);\r\n },\r\n });\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;;;;MA2Da,iBAAiB,CAAA;AACX,IAA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