Skip to content

Commit

Permalink
feat: master data + crud
Browse files Browse the repository at this point in the history
yosvelquintero committed Nov 28, 2023
1 parent 8d99521 commit 78012ba
Showing 103 changed files with 1,984 additions and 895 deletions.
2 changes: 0 additions & 2 deletions packages/modules/account/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from './lib/modules-account.module';
export * from './lib/lib.routes';

export * from './lib/lib.routes';
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

import { ROUTER } from '@console-core/config';
import { AccountFacade } from '@console-core/state';
@@ -8,60 +9,78 @@ import { AccountFacade } from '@console-core/state';
template: `
<ng-container *ngIf="user$ | async as user">
<div class="row">
<h3>
Personal Data [<a
[routerLink]="ROUTER.pages.main.children.profile.path"
>Edit</a
>]
</h3>
<ul>
<li><b>First Name</b>: {{ user.firstName }}</li>
<li><b>Last Name</b>: {{ user.lastName }}</li>
</ul>
<div class="col rc-page-container">
<h3>
Personal Data [<a
[routerLink]="
ROUTER.pages.main.children.account.children.profile.path
"
>Edit</a
>]
</h3>
<ul>
<li><b>First Name</b>: {{ user.firstName }}</li>
<li><b>Last Name</b>: {{ user.lastName }}</li>
</ul>
<h3>
Account Data [<a
[routerLink]="ROUTER.pages.main.children.profile.path"
>Edit</a
>]
</h3>
<ul>
<li><b>Username</b>: {{ user.name }}</li>
<li><b>Email</b>: {{ user.email }}</li>
</ul>
<h3>
Account Data [<a
[routerLink]="
ROUTER.pages.main.children.account.children.profile.path
"
>Edit</a
>]
</h3>
<ul>
<li><b>Username</b>: {{ user.name }}</li>
<li><b>Email</b>: {{ user.email }}</li>
</ul>
<h3>
Account Information [<a
[routerLink]="ROUTER.pages.main.children.preferences.path"
>Edit</a
>]
</h3>
<ul>
<li><b>User ID</b>: {{ user.id }}</li>
<li><b>Status</b>: {{ user.active ? 'Active' : 'Not active' }}</li>
<li><b>Timezone ID:</b> {{ user.timezoneId || '-' }}</li>
<li><b>Locale ID</b>: {{ user.localeId || '-' }}</li>
<li>
<b>Role Associations</b>:
<ul>
<li *ngFor="let association of user.roleAssociations">
{{ association.role }}
</li>
</ul>
</li>
<li><b>Created</b>: {{ user.meta?.created }}</li>
<li><b>Updated</b>: {{ user.meta?.modified }}</li>
</ul>
<h3>
Account Information [<a
[routerLink]="
ROUTER.pages.main.children.account.children.preferences.path
"
>Edit</a
>]
</h3>
<ul>
<li><b>User ID</b>: {{ user.id }}</li>
<li><b>Status</b>: {{ user.active ? 'Active' : 'Not active' }}</li>
<li><b>Timezone ID:</b> {{ user.timezoneId || '-' }}</li>
<li><b>Locale ID</b>: {{ user.localeId || '-' }}</li>
<li>
<b>Role Associations</b>:
<ul>
<li *ngFor="let association of user.roleAssociations">
{{ association.role }}
</li>
</ul>
</li>
<li><b>Created</b>: {{ user.meta.created }}</li>
<li><b>Updated</b>: {{ user.meta.modified }}</li>
</ul>
<h3>Support</h3>
<p>Contact us at support@restorecommerce.io</p>
<h3>Support</h3>
<p>Contact us at support@restorecommerce.io</p>
</div>
</div>
</ng-container>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AccountComponent {
export class AccountComponent implements OnInit {
ROUTER = ROUTER;
user$ = this.accountFacade.user$;
constructor(private readonly accountFacade: AccountFacade) {}

constructor(
private readonly router: Router,
private readonly accountFacade: AccountFacade
) {}

ngOnInit(): void {
this.router.navigate(
ROUTER.pages.main.children.account.children.profile.getLink()
);
}
}
Original file line number Diff line number Diff line change
@@ -34,8 +34,8 @@ export class PreferencesComponent implements OnInit {
readonly vm$ = combineLatest({
user: this.accountFacade.user$,
isRequesting: this.accountFacade.isRequesting$,
locales: this.localeFacade.allLocales$,
timezones: this.timezoneFacade.allTimezones$,
locales: this.localeFacade.all$,
timezones: this.timezoneFacade.all$,
}).pipe(
startWith({
user: null,
@@ -59,7 +59,7 @@ export class PreferencesComponent implements OnInit {
) {}

ngOnInit(): void {
this.localeFacade.localeReadRequest({});
this.timezoneFacade.timezoneReadRequest({});
this.localeFacade.read({});
this.timezoneFacade.read({});
}
}
Original file line number Diff line number Diff line change
@@ -9,17 +9,17 @@ interface ISchemaOptions {
user: IUser;
}

export const buildEmailSchema = (
options: ISchemaOptions
): VCLFormFieldSchemaRoot => {
export const buildEmailSchema = ({
user,
}: ISchemaOptions): VCLFormFieldSchemaRoot => {
return {
type: 'form',
fields: [
{
name: 'email',
label: 'Email',
type: 'input',
defaultValue: options.user.email,
defaultValue: user.email,
validators: [Validators.required, Validators.email],
params: {},
hints: [
@@ -35,6 +35,21 @@ export const buildEmailSchema = (
},
],
},
{
type: 'buttons',
buttons: [
{
type: 'submit',
label: 'Change Email',
},
{
type: 'button',
label: 'Cancel',
action: 'resetEmailForm',
class: 'transparent',
},
],
},
],
};
};
@@ -178,6 +193,21 @@ export const buildPasswordSchema = (): VCLFormFieldSchemaRoot => {
},
],
},
{
type: 'buttons',
buttons: [
{
type: 'submit',
label: 'Change Password',
},
{
type: 'button',
label: 'Cancel',
action: 'resetPasswordForm',
class: 'transparent',
},
],
},
],
};
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Validators } from '@angular/forms';

import { VCLFormFieldSchemaRoot } from '@vcl/ng-vcl';

import { IUser } from '@console-core/types';
@@ -8,9 +6,9 @@ interface ISchemaOptions {
user: IUser;
}

export const buildAccountInformationSchema = (
options: ISchemaOptions
): VCLFormFieldSchemaRoot => {
export const buildAccountInformationSchema = ({
user,
}: ISchemaOptions): VCLFormFieldSchemaRoot => {
return {
type: 'form',
fields: [
@@ -19,11 +17,38 @@ export const buildAccountInformationSchema = (
label: 'User ID',
type: 'input',
disabled: true,
defaultValue: options.user.id,
validators: [Validators.required],
defaultValue: user.id,
params: {},
hints: [],
},
{
name: 'attributes',
label: 'Roles',
type: 'select',
disabled: true,
defaultValue: [true],
params: {
placeholder: 'Select role',
selectionMode: 'multiple',
clearable: false,
search: false,
options: [
{
label: 'Super Administrator',
value: user.isSuperAdministrator,
},
{
label: 'Administrator',
value: user.isAdministrator,
},
{
label: 'User',
value: user.isUser,
},
],
},
hints: [],
},
],
};
};
Original file line number Diff line number Diff line change
@@ -8,9 +8,9 @@ interface ISchemaOptions {
user: IUser;
}

export const buildConfirmEmailSchema = (
options: ISchemaOptions
): VCLFormFieldSchemaRoot => {
export const buildConfirmEmailSchema = ({
user,
}: ISchemaOptions): VCLFormFieldSchemaRoot => {
return {
type: 'form',
fields: [
@@ -19,7 +19,7 @@ export const buildConfirmEmailSchema = (
label: 'New Email',
type: 'input',
disabled: true,
defaultValue: options.user.newEmail,
defaultValue: user.newEmail,
validators: [Validators.required, Validators.email],
params: {},
hints: [
@@ -35,6 +35,21 @@ export const buildConfirmEmailSchema = (
},
],
},
{
type: 'buttons',
buttons: [
{
type: 'submit',
label: 'Submit',
},
{
type: 'button',
label: 'Cancel',
action: 'reset',
class: 'transparent',
},
],
},
],
};
};
Loading

0 comments on commit 78012ba

Please sign in to comment.