UNPKG

@progress/sitefinity-nextjs-sdk

Version:

Provides OOB widgets developed using the Next.js framework, which includes an abstraction layer for Sitefinity communication. Additionally, it offers an expanded API, typings, and tools for further development and integration.

60 lines (59 loc) 3.44 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { PostPasswordChangeAction } from './interfaces/post-password-change-action'; import { StylingConfig } from '../styling/styling-config'; import { getMinimumWidgetContext } from '../../editor/widget-framework/widget-context'; import { RestSdkTypes } from '../../rest-sdk/rest-client'; import { RootUrlService } from '../../rest-sdk/root-url.service'; import { RestClientForContext } from '../../services/rest-client-for-context'; import { Tracer } from '@progress/sitefinity-nextjs-sdk/diagnostics/empty'; import { RenderView } from '../common/render-view'; import { ChangePasswordDefaultView } from './change-password.view'; import { getCustomAttributes, htmlAttributes } from '../../editor/widget-framework/attributes'; import { StyleGenerator } from '../styling/style-generator.service'; import { classNames } from '../../editor/utils/classNames'; import { VisibilityStyle } from '../styling/visibility-style'; export async function ChangePassword(props) { const { span, ctx } = Tracer.traceWidget(props, true); const entity = props.model.Properties; const dataAttributes = htmlAttributes(props); const defaultClass = entity.CssClass; const marginClass = entity.Margins && StyleGenerator.getMarginClasses(entity.Margins); dataAttributes['className'] = classNames(defaultClass, marginClass); const widgetAttributes = { ['data-sf-role']: 'sf-change-password-container', ['data-sf-visibility-hidden']: StylingConfig.VisibilityClasses[VisibilityStyle.Hidden], ['data-sf-invalid']: StylingConfig.InvalidClass }; const viewProps = { changePasswordHandlerPath: `/${RootUrlService.getWebServicePath()}/ChangePassword`, visibilityClasses: StylingConfig.VisibilityClasses, invalidClass: StylingConfig.InvalidClass, postPasswordChangeAction: entity.PostPasswordChangeAction, labels: { header: entity.Header, oldPassword: entity.CurrentPassword, newPassword: entity.NewPassword, repeatPassword: entity.ConfirmPassword, submitButtonLabel: entity.SubmitButtonLabel, loginFirstMessage: entity.LoginFirstMessage, validationRequiredMessage: entity.ValidationRequiredMessage, validationMismatchMessage: entity.ValidationMismatchMessage, externalProviderMessageFormat: entity.ExternalProviderMessageFormat }, isLive: props.requestContext.isLive, webserviceApiKey: props.requestContext.webserviceApiKey, attributes: { ...dataAttributes, ...getCustomAttributes(entity.Attributes, 'ChangePassword'), ...widgetAttributes }, widgetContext: getMinimumWidgetContext(props) }; if (entity.PostPasswordChangeAction === PostPasswordChangeAction.RedirectToPage) { try { const item = await RestClientForContext.getItem(entity.PostPasswordChangeRedirectPage, { type: RestSdkTypes.Pages, culture: props.requestContext.culture, traceContext: ctx }); viewProps.redirectUrl = item.ViewUrl; } catch (error) { /* empty */ } } else { viewProps.postPasswordChangeMessage = entity.PostPasswordChangeMessage; } return (_jsx(RenderView, { viewName: entity.SfViewName, widgetKey: props.model.Name, traceSpan: span, viewProps: viewProps, children: _jsx(ChangePasswordDefaultView, { ...viewProps }) })); }