@propeller-commerce/propeller-v2-react-ui 0.6.0 → 0.6.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/CHANGELOG.md +14 -0
- package/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -19
- package/dist/index.d.ts +0 -19
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -501,25 +501,6 @@ interface UseAuthReturn {
|
|
|
501
501
|
/** Triggers a password-reset email for the given address. */
|
|
502
502
|
forgotPassword: (email: string) => Promise<Result<void, string>>;
|
|
503
503
|
}
|
|
504
|
-
/**
|
|
505
|
-
* useAuth — login, registration, and forgot-password flows.
|
|
506
|
-
*
|
|
507
|
-
* @param options - see {@link UseAuthOptions}.
|
|
508
|
-
* @returns loading/error state plus async auth actions — see {@link UseAuthReturn}.
|
|
509
|
-
*
|
|
510
|
-
* @remarks
|
|
511
|
-
* GraphQL integration: services are built per-call via `createServices(graphqlClient)`.
|
|
512
|
-
* `login` calls `services.login.login()` (`LoginService`) then `services.user.getViewer()`
|
|
513
|
-
* (`UserService`) to fetch the Contact/Customer; the JWT is set as an in-memory Bearer
|
|
514
|
-
* header via `graphqlClient.updateConfig()` only — never persisted (cross-reload auth
|
|
515
|
-
* relies on an httpOnly cookie). `registerContact` runs `company.createCompany` →
|
|
516
|
-
* `user.registerContact` → implicit `login` → `address.createCompanyAddress` →
|
|
517
|
-
* `user.triggerContactSendWelcomeEmailEvent`. `registerCustomer` runs
|
|
518
|
-
* `user.registerCustomer` → `login` → `address.createCustomerAddress` →
|
|
519
|
-
* `user.triggerCustomerSendWelcomeEmailEvent`, re-fetching the viewer afterward.
|
|
520
|
-
* When `autoLogin` is `false` the session is dropped via `clearAccessToken()`.
|
|
521
|
-
* `forgotPassword` calls `user.sendPasswordResetEmail()`.
|
|
522
|
-
*/
|
|
523
504
|
declare function useAuth(options: UseAuthOptions): UseAuthReturn;
|
|
524
505
|
|
|
525
506
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -501,25 +501,6 @@ interface UseAuthReturn {
|
|
|
501
501
|
/** Triggers a password-reset email for the given address. */
|
|
502
502
|
forgotPassword: (email: string) => Promise<Result<void, string>>;
|
|
503
503
|
}
|
|
504
|
-
/**
|
|
505
|
-
* useAuth — login, registration, and forgot-password flows.
|
|
506
|
-
*
|
|
507
|
-
* @param options - see {@link UseAuthOptions}.
|
|
508
|
-
* @returns loading/error state plus async auth actions — see {@link UseAuthReturn}.
|
|
509
|
-
*
|
|
510
|
-
* @remarks
|
|
511
|
-
* GraphQL integration: services are built per-call via `createServices(graphqlClient)`.
|
|
512
|
-
* `login` calls `services.login.login()` (`LoginService`) then `services.user.getViewer()`
|
|
513
|
-
* (`UserService`) to fetch the Contact/Customer; the JWT is set as an in-memory Bearer
|
|
514
|
-
* header via `graphqlClient.updateConfig()` only — never persisted (cross-reload auth
|
|
515
|
-
* relies on an httpOnly cookie). `registerContact` runs `company.createCompany` →
|
|
516
|
-
* `user.registerContact` → implicit `login` → `address.createCompanyAddress` →
|
|
517
|
-
* `user.triggerContactSendWelcomeEmailEvent`. `registerCustomer` runs
|
|
518
|
-
* `user.registerCustomer` → `login` → `address.createCustomerAddress` →
|
|
519
|
-
* `user.triggerCustomerSendWelcomeEmailEvent`, re-fetching the viewer afterward.
|
|
520
|
-
* When `autoLogin` is `false` the session is dropped via `clearAccessToken()`.
|
|
521
|
-
* `forgotPassword` calls `user.sendPasswordResetEmail()`.
|
|
522
|
-
*/
|
|
523
504
|
declare function useAuth(options: UseAuthOptions): UseAuthReturn;
|
|
524
505
|
|
|
525
506
|
/**
|
package/dist/index.js
CHANGED
|
@@ -228,6 +228,7 @@ function useAddress(options) {
|
|
|
228
228
|
);
|
|
229
229
|
return { loading, error, createAddress, updateAddress, deleteAddress, setDefaultAddress };
|
|
230
230
|
}
|
|
231
|
+
var isViewerSearchInput = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
231
232
|
function useAuth(options) {
|
|
232
233
|
const { graphqlClient, language = "NL", onAuthHeaderUpdate, configuration } = options;
|
|
233
234
|
const [loading, setLoading] = useState(false);
|
|
@@ -264,8 +265,14 @@ function useAuth(options) {
|
|
|
264
265
|
...configuration?.companyTrackAttributes?.length && {
|
|
265
266
|
companyAttributesInput: { attributeDescription: { names: configuration.companyTrackAttributes } }
|
|
266
267
|
},
|
|
267
|
-
|
|
268
|
+
// Contact-scoped pagination inputs — only when the host supplies a real
|
|
269
|
+
// input object (an empty array `[]` is truthy but 400s the viewer). See
|
|
270
|
+
// isViewerSearchInput.
|
|
271
|
+
...isViewerSearchInput(configuration?.contactPAConfigInput) && {
|
|
268
272
|
contactPAConfigInput: configuration.contactPAConfigInput
|
|
273
|
+
},
|
|
274
|
+
...isViewerSearchInput(configuration?.contactCompaniesSearchInput) && {
|
|
275
|
+
contactCompaniesSearchInput: configuration.contactCompaniesSearchInput
|
|
269
276
|
}
|
|
270
277
|
};
|
|
271
278
|
const viewer = await userService.getViewer(viewerInput);
|
|
@@ -3446,7 +3453,13 @@ function LoginForm(rawProps) {
|
|
|
3446
3453
|
const [email, setEmail] = useState("");
|
|
3447
3454
|
const [password, setPassword] = useState("");
|
|
3448
3455
|
const { loading, error: authError, login } = useAuth({
|
|
3449
|
-
graphqlClient: props.graphqlClient
|
|
3456
|
+
graphqlClient: props.graphqlClient,
|
|
3457
|
+
// Resolved from <PropellerDepsProvider> by useInfraProps (the app's full
|
|
3458
|
+
// `config`), so the login viewer requests the configured track attributes +
|
|
3459
|
+
// pagination inputs (companyTrackAttributes → MY_INSTALLATIONS,
|
|
3460
|
+
// contactCompaniesSearchInput, contactPAConfigInput). Without this the header
|
|
3461
|
+
// login returns a viewer with no companies/attributes until a later refresh.
|
|
3462
|
+
configuration: props.configuration
|
|
3450
3463
|
});
|
|
3451
3464
|
getLabel(props.labels, "email", "Email");
|
|
3452
3465
|
getLabel(props.labels, "password", "Password");
|