wire resend invite
This commit is contained in:
@@ -39,18 +39,22 @@ export class UmbInviteUserModalElement extends UmbModalBaseElement {
|
||||
});
|
||||
|
||||
if (!error) {
|
||||
this.#closeModal();
|
||||
this.#submitModal();
|
||||
}
|
||||
}
|
||||
|
||||
#closeModal() {
|
||||
#submitModal() {
|
||||
this.modalContext?.submit();
|
||||
}
|
||||
|
||||
#rejectModal() {
|
||||
this.modalContext?.reject();
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`<uui-dialog-layout headline="Invite User">
|
||||
${this.#renderForm()}
|
||||
<uui-button @click=${this.#closeModal} slot="actions" label="Cancel" look="secondary"></uui-button>
|
||||
<uui-button @click=${this.#rejectModal} slot="actions" label="Cancel" look="secondary"></uui-button>
|
||||
<uui-button
|
||||
form="InviteUserForm"
|
||||
slot="actions"
|
||||
|
||||
@@ -28,12 +28,19 @@ export class UmbResendInviteToUserModalElement extends UmbModalBaseElement<
|
||||
const formData = new FormData(form);
|
||||
const message = formData.get('message') as string;
|
||||
|
||||
const { error } = await this.#userInviteUserRepository.resendInvite(this.modalContext.data.userId, {
|
||||
await this.#userInviteUserRepository.resendInvite({
|
||||
userId: this.modalContext.data.userId,
|
||||
message,
|
||||
});
|
||||
|
||||
this.#submitModal();
|
||||
}
|
||||
|
||||
private _closeModal() {
|
||||
#submitModal() {
|
||||
this.modalContext?.submit();
|
||||
}
|
||||
|
||||
#rejectModal() {
|
||||
this.modalContext?.reject();
|
||||
}
|
||||
|
||||
@@ -41,7 +48,7 @@ export class UmbResendInviteToUserModalElement extends UmbModalBaseElement<
|
||||
return html`<uui-dialog-layout headline="Resend invite">
|
||||
${this.#renderForm()}
|
||||
|
||||
<uui-button @click=${this._closeModal} slot="actions" label="Cancel" look="secondary"></uui-button>
|
||||
<uui-button @click=${this.#rejectModal} slot="actions" label="Cancel" look="secondary"></uui-button>
|
||||
<uui-button
|
||||
slot="actions"
|
||||
type="submit"
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { UmbUserServerDataSource } from '../../repository/detail/user-detail.server.data-source.js';
|
||||
import { type UmbInviteUserDataSource } from './types.js';
|
||||
import { InviteUserRequestModel, UserResource } from '@umbraco-cms/backoffice/backend-api';
|
||||
import {
|
||||
InviteUserRequestModel,
|
||||
ResendInviteUserRequestModel,
|
||||
UserResource,
|
||||
} from '@umbraco-cms/backoffice/backend-api';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
|
||||
@@ -47,31 +51,20 @@ export class UmbInviteUserServerDataSource implements UmbInviteUserDataSource {
|
||||
|
||||
/**
|
||||
* Resend an invite to a user
|
||||
* @param {string} userId
|
||||
* @param {string} userUnique
|
||||
* @param {InviteUserRequestModel} requestModel
|
||||
* @returns
|
||||
* @memberof UmbInviteUserServerDataSource
|
||||
*/
|
||||
async resendInvite(userId: string, requestModel: InviteUserRequestModel) {
|
||||
if (!userId) throw new Error('User id is missing');
|
||||
async resendInvite(requestModel: ResendInviteUserRequestModel) {
|
||||
if (!requestModel.userId) throw new Error('User id is missing');
|
||||
if (!requestModel) throw new Error('Data is missing');
|
||||
|
||||
alert('End point is missing');
|
||||
|
||||
const body = JSON.stringify({
|
||||
userId,
|
||||
requestModel,
|
||||
});
|
||||
|
||||
return tryExecuteAndNotify(
|
||||
this.#host,
|
||||
fetch('/umbraco/management/api/v1/user/invite/resend', {
|
||||
method: 'POST',
|
||||
body: body,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
}).then((res) => res.json()),
|
||||
UserResource.postUserInviteResend({
|
||||
requestBody: requestModel,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UmbUserRepositoryBase } from '../../repository/user-repository-base.js';
|
||||
import { UmbInviteUserServerDataSource } from './invite-user-server.data-source.js';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { InviteUserRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { InviteUserRequestModel, ResendInviteUserRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
|
||||
export class UmbInviteUserRepository extends UmbUserRepositoryBase {
|
||||
#inviteSource: UmbInviteUserServerDataSource;
|
||||
@@ -35,17 +35,17 @@ export class UmbInviteUserRepository extends UmbUserRepositoryBase {
|
||||
|
||||
/**
|
||||
* Resend an invite to a user
|
||||
* @param {string} userId
|
||||
* @param {string} userUnique
|
||||
* @param {InviteUserRequestModel} requestModel
|
||||
* @return {*}
|
||||
* @memberof UmbInviteUserRepository
|
||||
*/
|
||||
async resendInvite(userId: string, requestModel: any) {
|
||||
if (!userId) throw new Error('User id is missing');
|
||||
async resendInvite(requestModel: ResendInviteUserRequestModel) {
|
||||
if (!requestModel.userId) throw new Error('User unique is missing');
|
||||
if (!requestModel) throw new Error('data is missing');
|
||||
await this.init;
|
||||
|
||||
const { error } = await this.#inviteSource.resendInvite(userId, requestModel);
|
||||
const { error } = await this.#inviteSource.resendInvite(requestModel);
|
||||
|
||||
if (!error) {
|
||||
const notification = { data: { message: `Invite resent to user` } };
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { UmbUserDetailModel } from '../../types.js';
|
||||
import { InviteUserRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { DataSourceResponse } from '@umbraco-cms/backoffice/repository';
|
||||
import { InviteUserRequestModel, ResendInviteUserRequestModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { DataSourceResponse, UmbDataSourceErrorResponse } from '@umbraco-cms/backoffice/repository';
|
||||
|
||||
export interface UmbInviteUserDataSource {
|
||||
invite(requestModel: InviteUserRequestModel): Promise<DataSourceResponse<UmbUserDetailModel>>;
|
||||
resendInvite(userId: string, requestModel: any): Promise<DataSourceResponse<UmbUserDetailModel>>;
|
||||
resendInvite(requestModel: ResendInviteUserRequestModel): Promise<UmbDataSourceErrorResponse>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user