This commit is contained in:
gofnnp 2023-07-11 14:24:09 +04:00
commit feeed2c640
9 changed files with 237 additions and 173 deletions

View File

@ -9,9 +9,11 @@
"schematics": { "schematics": {
"@schematics/angular:component": { "@schematics/angular:component": {
"style": "scss" "style": "scss"
},
"i18n": {
"sourceLocale": "ru-RU"
} }
}, },
"root": "", "root": "",
"sourceRoot": "src", "sourceRoot": "src",
"prefix": "app", "prefix": "app",

View File

@ -16,6 +16,7 @@
"@angular/fire": "^7.5.0", "@angular/fire": "^7.5.0",
"@angular/forms": "^15.2.9", "@angular/forms": "^15.2.9",
"@angular/material": "^15.2.9", "@angular/material": "^15.2.9",
"@angular/material-moment-adapter": "^15.2.9",
"@angular/platform-browser": "^15.2.9", "@angular/platform-browser": "^15.2.9",
"@angular/platform-browser-dynamic": "^15.2.9", "@angular/platform-browser-dynamic": "^15.2.9",
"@angular/router": "^15.2.9", "@angular/router": "^15.2.9",
@ -27,6 +28,7 @@
"@types/uuid": "^8.3.4", "@types/uuid": "^8.3.4",
"@types/web": "^0.0.99", "@types/web": "^0.0.99",
"angular-moment-timezone": "^1.7.1", "angular-moment-timezone": "^1.7.1",
"angular2-text-mask": "^9.0.0",
"barcode-2-svg": "^0.3.3", "barcode-2-svg": "^0.3.3",
"firebase": "^9.9.3", "firebase": "^9.9.3",
"google-libphonenumber": "^3.2.30", "google-libphonenumber": "^3.2.30",
@ -864,6 +866,19 @@
"rxjs": "^6.5.3 || ^7.4.0" "rxjs": "^6.5.3 || ^7.4.0"
} }
}, },
"node_modules/@angular/material-moment-adapter": {
"version": "15.2.9",
"resolved": "https://registry.npmjs.org/@angular/material-moment-adapter/-/material-moment-adapter-15.2.9.tgz",
"integrity": "sha512-DHG8z8DG1/+oO/bRC/k+1nXwRGg0qDsCEYulUoEUtpYmQRHj8Tid/9V2JiibYqTh4s0DJeAnx64CAO9K/k9EZg==",
"dependencies": {
"tslib": "^2.3.0"
},
"peerDependencies": {
"@angular/core": "^15.0.0 || ^16.0.0",
"@angular/material": "15.2.9",
"moment": "^2.18.1"
}
},
"node_modules/@angular/platform-browser": { "node_modules/@angular/platform-browser": {
"version": "15.2.9", "version": "15.2.9",
"resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-15.2.9.tgz", "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-15.2.9.tgz",
@ -5813,6 +5828,14 @@
"resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.8.29.tgz", "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.8.29.tgz",
"integrity": "sha512-mla2acNCMkWXBD+c+yeUrBUrzOxYMNFdQ6FGfigGGtEVBPJx07BQeJekjt9DmH1FtZek4E9rE1eRR9qQpxACOQ==" "integrity": "sha512-mla2acNCMkWXBD+c+yeUrBUrzOxYMNFdQ6FGfigGGtEVBPJx07BQeJekjt9DmH1FtZek4E9rE1eRR9qQpxACOQ=="
}, },
"node_modules/angular2-text-mask": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/angular2-text-mask/-/angular2-text-mask-9.0.0.tgz",
"integrity": "sha512-iALcnhJPS1zvX48d86rgUgDe/crX6XfhZrXC4Gdlo2/YwZW7u7KJZY6/b3ieSCIWVq/E6p+wDCzeo3E6leRjDA==",
"dependencies": {
"text-mask-core": "^5.0.0"
}
},
"node_modules/ansi-colors": { "node_modules/ansi-colors": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz",
@ -13564,6 +13587,11 @@
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
"integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==" "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg=="
}, },
"node_modules/text-mask-core": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/text-mask-core/-/text-mask-core-5.1.2.tgz",
"integrity": "sha512-VfkCMdmRRZqXgQZFlDMiavm3hzsMzBM23CxHZsaeAYg66ZhXCNJWrFmnJwNy8KF9f74YvAUAuQenxsMCfuvhUw=="
},
"node_modules/text-table": { "node_modules/text-table": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
@ -15118,6 +15146,14 @@
"tslib": "^2.3.0" "tslib": "^2.3.0"
} }
}, },
"@angular/material-moment-adapter": {
"version": "15.2.9",
"resolved": "https://registry.npmjs.org/@angular/material-moment-adapter/-/material-moment-adapter-15.2.9.tgz",
"integrity": "sha512-DHG8z8DG1/+oO/bRC/k+1nXwRGg0qDsCEYulUoEUtpYmQRHj8Tid/9V2JiibYqTh4s0DJeAnx64CAO9K/k9EZg==",
"requires": {
"tslib": "^2.3.0"
}
},
"@angular/platform-browser": { "@angular/platform-browser": {
"version": "15.2.9", "version": "15.2.9",
"resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-15.2.9.tgz", "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-15.2.9.tgz",
@ -18959,6 +18995,14 @@
} }
} }
}, },
"angular2-text-mask": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/angular2-text-mask/-/angular2-text-mask-9.0.0.tgz",
"integrity": "sha512-iALcnhJPS1zvX48d86rgUgDe/crX6XfhZrXC4Gdlo2/YwZW7u7KJZY6/b3ieSCIWVq/E6p+wDCzeo3E6leRjDA==",
"requires": {
"text-mask-core": "^5.0.0"
}
},
"ansi-colors": { "ansi-colors": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz",
@ -24763,6 +24807,11 @@
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
"integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==" "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg=="
}, },
"text-mask-core": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/text-mask-core/-/text-mask-core-5.1.2.tgz",
"integrity": "sha512-VfkCMdmRRZqXgQZFlDMiavm3hzsMzBM23CxHZsaeAYg66ZhXCNJWrFmnJwNy8KF9f74YvAUAuQenxsMCfuvhUw=="
},
"text-table": { "text-table": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",

View File

@ -18,6 +18,7 @@
"@angular/fire": "^7.5.0", "@angular/fire": "^7.5.0",
"@angular/forms": "^15.2.9", "@angular/forms": "^15.2.9",
"@angular/material": "^15.2.9", "@angular/material": "^15.2.9",
"@angular/material-moment-adapter": "^15.2.9",
"@angular/platform-browser": "^15.2.9", "@angular/platform-browser": "^15.2.9",
"@angular/platform-browser-dynamic": "^15.2.9", "@angular/platform-browser-dynamic": "^15.2.9",
"@angular/router": "^15.2.9", "@angular/router": "^15.2.9",
@ -29,6 +30,7 @@
"@types/uuid": "^8.3.4", "@types/uuid": "^8.3.4",
"@types/web": "^0.0.99", "@types/web": "^0.0.99",
"angular-moment-timezone": "^1.7.1", "angular-moment-timezone": "^1.7.1",
"angular2-text-mask": "^9.0.0",
"barcode-2-svg": "^0.3.3", "barcode-2-svg": "^0.3.3",
"firebase": "^9.9.3", "firebase": "^9.9.3",
"google-libphonenumber": "^3.2.30", "google-libphonenumber": "^3.2.30",

View File

@ -50,7 +50,6 @@ import {
} from '@angular/material/bottom-sheet'; } from '@angular/material/bottom-sheet';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { DirectivesModule } from './directives/directives.module'; import { DirectivesModule } from './directives/directives.module';
import { MAT_DATE_LOCALE } from '@angular/material/core';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -108,7 +107,7 @@ import { MAT_DATE_LOCALE } from '@angular/material/core';
MatSnackBarModule, MatSnackBarModule,
MatBottomSheetModule, MatBottomSheetModule,
MatProgressSpinnerModule, MatProgressSpinnerModule,
DirectivesModule DirectivesModule,
], ],
providers: [ providers: [
DialogService, DialogService,
@ -116,7 +115,6 @@ import { MAT_DATE_LOCALE } from '@angular/material/core';
MessagingService, MessagingService,
{ provide: MatBottomSheetRef, useValue: {} }, { provide: MatBottomSheetRef, useValue: {} },
{ provide: MAT_BOTTOM_SHEET_DATA, useValue: {} }, { provide: MAT_BOTTOM_SHEET_DATA, useValue: {} },
{ provide: MAT_DATE_LOCALE, useValue: 'ru-RU' }
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
}) })

View File

@ -7,9 +7,7 @@ import { SocialMediaButtonsComponent } from './components/social-media-buttons/s
import { NavbarComponent } from './components/navbar/navbar.component'; import { NavbarComponent } from './components/navbar/navbar.component';
import { MenuItemComponent } from './components/navbar/menu_item.component'; import { MenuItemComponent } from './components/navbar/menu_item.component';
import { MatIconModule } from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatSelectModule } from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select';
import { MatNativeDateModule } from '@angular/material/core';
import { GuestCardComponent } from './pages/guest-card/guest-card.component'; import { GuestCardComponent } from './pages/guest-card/guest-card.component';
import { QrCodeModule } from 'ng-qrcode'; import { QrCodeModule } from 'ng-qrcode';
import { AccordionComponent } from './components/accordion/accordion.component'; import { AccordionComponent } from './components/accordion/accordion.component';
@ -26,7 +24,7 @@ import { LoyalityProgramComponent } from './pages/loyality-program/loyality-prog
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { ToastModule } from 'primeng/toast'; import { ToastModule } from 'primeng/toast';
import { CreateUserComponent } from './pages/create_user/create_user.component'; import { CreateUserComponent } from './pages/create_user/create_user.component';
import { TextMaskModule } from 'angular2-text-mask';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -44,6 +42,7 @@ import { CreateUserComponent } from './pages/create_user/create_user.component';
CreateUserComponent, CreateUserComponent,
], ],
imports: [ imports: [
TextMaskModule,
ToastModule, ToastModule,
CommonModule, CommonModule,
DefaultOptionRoutingModule, DefaultOptionRoutingModule,
@ -57,9 +56,7 @@ import { CreateUserComponent } from './pages/create_user/create_user.component';
MatInputModule, MatInputModule,
DirectivesModule, DirectivesModule,
MatButtonModule, MatButtonModule,
MatDatepickerModule,
MatSelectModule, MatSelectModule,
MatNativeDateModule,
], ],
bootstrap: [IndexComponent], bootstrap: [IndexComponent],
}) })

View File

@ -1,5 +1,5 @@
<ng-container *ngIf="!authService.loading"> <ng-container *ngIf="!authService.loading">
<form <form
(ngSubmit)="submit()" (ngSubmit)="submit()"
[formGroup]="form" [formGroup]="form"
> >
@ -20,14 +20,12 @@
</mat-form-field> </mat-form-field>
<mat-form-field appearance="outline"> <mat-form-field appearance="outline">
<mat-label>Дата рождения</mat-label> <mat-label>Дата рождения</mat-label>
<input formControlName="date" matInput [matDatepicker]="picker"> <input (click)="focusHandler($event)" (blur)="blurHandler()" formControlName="date" matInput [textMask]="mask" type="text" inputmode="numeric">
<mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field> </mat-form-field>
<button mat-raised-button color="primary">Зарегистрироваться</button> <button mat-raised-button color="primary">Зарегистрироваться</button>
</div> </div>
</div> </div>
</form> </form>
</ng-container> </ng-container>
<ng-container *ngIf="authService.loading"> <ng-container *ngIf="authService.loading">

View File

@ -1,4 +1,4 @@
import { Component, OnInit } from "@angular/core"; import { Component } from "@angular/core";
import { FormControl, FormGroup, Validators } from "@angular/forms"; import { FormControl, FormGroup, Validators } from "@angular/forms";
import { MessageService } from "primeng/api"; import { MessageService } from "primeng/api";
import { AuthService } from "src/app/services/auth.service"; import { AuthService } from "src/app/services/auth.service";
@ -9,22 +9,42 @@ import moment from 'moment';
templateUrl: './create_user.component.html', templateUrl: './create_user.component.html',
styleUrls: ['./create_user.component.scss'], styleUrls: ['./create_user.component.scss'],
}) })
export class CreateUserComponent implements OnInit { export class CreateUserComponent {
public form = new FormGroup({ public form = new FormGroup({
name: new FormControl('', [Validators.required]), name: new FormControl('', [Validators.required]),
sex: new FormControl('', [Validators.required]), sex: new FormControl('', [Validators.required]),
date: new FormControl('', [Validators.required]), date: new FormControl('', [Validators.required]),
}); });
public mask = {
guide: true,
showMask: true,
mask: [/\d/, /\d/, '.', /\d/, /\d/, '.', /\d/, /\d/, /\d/, /\d/]
};
constructor( constructor(
public authService: AuthService, public authService: AuthService,
private messageService: MessageService, private messageService: MessageService,
) { } ) { }
ngOnInit() { } focused = false;
focusHandler(e: any) {
if (!this.focused) {
setTimeout(() => {
e.target.setSelectionRange(0, 0);
}, 0);
this.focused = true;
}
}
blurHandler() {
this.focused = false;
}
submit() { submit() {
if (this.form.invalid) { if (this.form.invalid) {
this.messageService.clear();
this.messageService.add({ this.messageService.add({
severity: 'error', severity: 'error',
summary: 'Введите имя, пол и дату рождения', summary: 'Введите имя, пол и дату рождения',
@ -36,7 +56,7 @@ export class CreateUserComponent implements OnInit {
const sex = this.form.value.sex!; const sex = this.form.value.sex!;
const date = this.form.value.date!; const date = this.form.value.date!;
const formattedDate = moment(date).format('yyyy-MM-DD'); const formattedDate = moment(date, 'DD-MM-YYYY').format('yyyy-MM-DD');
this.authService.register(name, sex, formattedDate); this.authService.register(name, sex, formattedDate);
} }

View File

@ -16,8 +16,6 @@
} }
.agree-info { .agree-info {
text-align: center; text-align: center;
margin: 0 auto;
max-width: 80%;
font-size: 12px; font-size: 12px;
margin-bottom: 20px; margin-bottom: 20px;
} }

View File

@ -127,10 +127,10 @@ body {
--main-color_hover: rgba(208, 180, 133, 0.2); --main-color_hover: rgba(208, 180, 133, 0.2);
} }
.mdc-text-field--outlined:not(.mdc-text-field--disabled, .mdc-text-field--invalid) .mdc-notched-outline__leading, .mdc-text-field--outlined:not(.mdc-text-field--disabled, .mdc-text-field--invalid, .mat-focused) .mdc-notched-outline__leading,
.mdc-text-field--outlined:not(.mdc-text-field--disabled, .mdc-text-field--invalid) .mdc-notched-outline__notch, .mdc-text-field--outlined:not(.mdc-text-field--disabled, .mdc-text-field--invalid, .mat-focused) .mdc-notched-outline__notch,
.mdc-text-field--outlined:not(.mdc-text-field--disabled, .mdc-text-field--invalid) .mdc-notched-outline__trailing { .mdc-text-field--outlined:not(.mdc-text-field--disabled, .mdc-text-field--invalid, .mat-focused) .mdc-notched-outline__trailing {
border-color: var(--text-color_2); border-color: var(--text-color_2) !important;
} }
.mat-mdc-outlined-button:not(:disabled) { .mat-mdc-outlined-button:not(:disabled) {