Skip to content

Commit

Permalink
Merge pull request #35 from teamq-ec/DM2-2712-implementacion-de-formu…
Browse files Browse the repository at this point in the history
…lario-de-registro-de-productos-visible-solo-despues-del-inicio-de-sesion

Dm2 2712 implementacion de formulario de registro de productos visible solo despues del inicio de sesion
  • Loading branch information
fe222004 authored Jul 26, 2024
2 parents 323dc70 + fec694e commit 19eab31
Show file tree
Hide file tree
Showing 29 changed files with 1,050 additions and 304 deletions.
2 changes: 1 addition & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const routes: Routes = [
import('./components/auth/auth.module').then((m) => m.AuthModule),
},
{
path: 'pages',
path: 'pages/:userId',
loadChildren: () =>
import('./pages/pages.module').then((m) => m.PagesModule),
canActivate : [loginGuard]
Expand Down
9 changes: 9 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';

import { AppComponent } from './app.component';
import { MenuModule } from './pages/components/menu/menu.module';
import { FooterModule } from './pages/components/footer/footer.module';

import { HomeModule } from './pages/home/home.module';
import { DashboardModule } from './pages/dashboard/dashboard.module';
import { ApplianceRegistrationModule } from './pages/appliance-registration/appliance-registration.module';
import { AlertConfirmationModule } from './pages/components/alert-confirmation/alert-confirmation.module';

export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
Expand All @@ -21,6 +28,8 @@ export function HttpLoaderFactory(http: HttpClient) {
CommonModule,
BrowserModule,
AppRoutingModule,
HomeModule,
DashboardModule,
ReactiveFormsModule,
HttpClientModule,
TranslateModule.forRoot({
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/auth/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2 class="mt-10 text-center text-2xl font-bold leading-9 tracking-tight text-gr
</div>

<div class="absolute top-20 right-325 z-10">
<button (click)="goToHome()"
<button (click)="gotoIndex()"
class="inline-flex items-center justify-center w-10 h-10 bg-indigo-600 rounded-md shadow-sm text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
title="Go to Home">
<svg class="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
Expand Down
16 changes: 14 additions & 2 deletions src/app/components/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class LoginComponent {
localStorage.setItem('token', response.accessToken);
localStorage.setItem('userName', response.user.first_name);
localStorage.setItem('userLastName', response.user.last_name);
localStorage.setItem('userId', response.user.id.toString());
this.goToHome();
},
(error) => {
Expand All @@ -77,9 +78,21 @@ export class LoginComponent {
this.router.navigate([RoutesConstants.register]);
}

gotoIndex(): void {
this.router.navigate([RoutesConstants.home]);
}

goToHome(): void {
this.router.navigate([RoutesConstants.dashboard]);
const userId = localStorage.getItem('userId');
if (userId) {
this.router.navigate([
RoutesConstants.dashboard.replace(':userId', userId),
]);
} else {
this.router.navigate([RoutesConstants.home]);
}
}

public togglePasswordVisibility(): void {
this.showPassword = !this.showPassword;
}
Expand All @@ -92,4 +105,3 @@ export class LoginComponent {
return control.invalid && (control.dirty || control.touched);
}
}

1 change: 0 additions & 1 deletion src/app/components/auth/register/register.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ <h2 class="mt-10 text-center text-2xl font-bold leading-9 tracking-tight text-gr
</div>
</div>
</div>

<div class="sm:col-span-3">
<label for="phone_number" class="block text-sm font-medium leading-6 text-gray-900">
{{ 'formProduct.PHONE_NUMBER_LABEL' | translate }} <span class="text-red-500">*</span>
Expand Down
10 changes: 5 additions & 5 deletions src/app/components/auth/register/register.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { RoutesConstants } from 'src/app/constants/routes.constants';
import { UrlsConstants } from 'src/app/constants/urls.constants';
import { DataTransferServiceService } from 'src/app/pages/services/data-transfer-service.service';
import { TranslateService } from '@ngx-translate/core';
import { ValidationConstants } from 'src/app/constants/validation.constants';

@Component({
selector: 'app-register',
Expand Down Expand Up @@ -44,16 +45,16 @@ export class RegisterComponent {
'',
[
Validators.required,
Validators.minLength(1),
Validators.maxLength(40),
Validators.minLength(ValidationConstants.NAME_MIN_LENGTH),
Validators.maxLength(ValidationConstants.NAME_MAX_LENGTH),
],
],
last_name: [
'',
[
Validators.required,
Validators.minLength(1),
Validators.maxLength(40),
Validators.minLength(ValidationConstants.NAME_MIN_LENGTH),
Validators.maxLength(ValidationConstants.NAME_MAX_LENGTH),
],
],
email: [
Expand All @@ -64,7 +65,6 @@ export class RegisterComponent {
'',
[Validators.required, Validators.pattern(RegexConstants.password)],
],
confirm_password: ['', Validators.required],
phone_number: ['', Validators.required],
address: ['', Validators.required],
});
Expand Down
13 changes: 7 additions & 6 deletions src/app/constants/routes.constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export const RoutesConstants = {
login: '/auth/login',
register: '/auth/register',
home: '',
dashboard: '/pages/home',
};
login: '/auth/login',
register: '/auth/register',
home: '',
dashboard: '/pages/:userId/home',
form: '/pages/:userId/form',
root: '/',
};


7 changes: 7 additions & 0 deletions src/app/constants/validation.constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const ValidationConstants = {
NAME_MIN_LENGTH: 1,
NAME_MAX_LENGTH: 40,
BRAND_MIN_LENGTH: 2,
BRAND_MAX_LENGTH: 50,
ADDRESSS_MAX_LENGTH: 100,
};
17 changes: 17 additions & 0 deletions src/app/models/product.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export interface ServiceRequest {
user_id: number;
first_name: string;
last_name: string;
email: string;
phone_number: string;
appliance_type: string;
brand: string;
problem_details: string;
address: string;
service_type: string;
preferred_contact_method: string;
damaged_appliance_image: string;
state: string;
application_date: string;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
body {
background: linear-gradient(to right, rgba(0, 0, 255, 0.5), rgba(255, 255, 0, 0.5));
margin: 0;
font-family: Arial, sans-serif;
}

.image-upload {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
}

.upload-area {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

.image-upload-label {
cursor: pointer;
border: 2px dashed #cccccc;
border-radius: 8px;
padding: 20px;
text-align: center;
transition: border-color 0.3s;
}

.image-upload-label:hover {
border-color: #888888;
}

.image-upload-placeholder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

.upload-icon {
width: 40px;
height: 40px;
color: #888888;
}

.upload-text {
margin-top: 10px;
color: #666666;
}

input[type="file"] {
display: none;
}

.image-preview {
position: relative;
margin-top: 20px;
display: flex;
justify-content: center;
align-items: center;
}

.image-preview img {
max-width: 100%;
max-height: 300px;
border-radius: 8px;
}

.remove-image {
position: absolute;
top: 5px;
right: 5px;
background: rgba(0, 0, 0, 0.5);
color: #ffffff;
border: none;
border-radius: 50%;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
cursor: pointer;
}

.remove-image:hover {
background: rgba(0, 0, 0, 0.7);
}
Loading

0 comments on commit 19eab31

Please sign in to comment.