create success page and route

This commit is contained in:
Tykayn 2020-12-16 17:21:01 +01:00 committed by tykayn
parent b46b57eeba
commit 03f7c49c51
10 changed files with 73 additions and 4 deletions

View File

@ -10,9 +10,10 @@ import { StepperComponent } from './stepper/stepper.component';
import { NamingComponent } from './naming/naming.component'; import { NamingComponent } from './naming/naming.component';
import { FormComponent } from './form/form.component'; import { FormComponent } from './form/form.component';
import { DateValueAccessorModule } from 'angular-date-value-accessor'; import { DateValueAccessorModule } from 'angular-date-value-accessor';
import { SuccessComponent } from './success/success.component';
@NgModule({ @NgModule({
declarations: [AdministrationComponent, StepperComponent, NamingComponent, FormComponent], declarations: [AdministrationComponent, StepperComponent, NamingComponent, FormComponent, SuccessComponent],
imports: [ imports: [
AdministrationRoutingModule, AdministrationRoutingModule,
CommonModule, CommonModule,

View File

@ -9,6 +9,7 @@ import { DateUtilities } from '../../old-stuff/config/DateUtilities';
import { DOCUMENT } from '@angular/common'; import { DOCUMENT } from '@angular/common';
import { DateChoice, otherDefaultDates } from '../../old-stuff/config/defaultConfigs'; import { DateChoice, otherDefaultDates } from '../../old-stuff/config/defaultConfigs';
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop'; import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'app-admin-form', selector: 'app-admin-form',
@ -39,6 +40,7 @@ export class FormComponent implements OnInit {
private pollService: PollService, private pollService: PollService,
public dateUtilities: DateUtilities, public dateUtilities: DateUtilities,
private apiService: ApiService, private apiService: ApiService,
private router: Router,
@Inject(DOCUMENT) private document: any @Inject(DOCUMENT) private document: any
) {} ) {}
drop(event: CdkDragDrop<string[]>) { drop(event: CdkDragDrop<string[]>) {
@ -60,7 +62,13 @@ export class FormComponent implements OnInit {
console.log('this.form', this.form); console.log('this.form', this.form);
const newpoll = this.pollService.newPollFromForm(this.form); const newpoll = this.pollService.newPollFromForm(this.form);
console.log('newpoll', newpoll); console.log('newpoll', newpoll);
this.apiService.createPoll(newpoll); let self = this;
this.apiService.createPoll(newpoll).then((resp) => {
console.log('resp', resp);
self.router.navigate(['success']);
});
// this.router
// if (this.form.valid) { // if (this.form.valid) {
// console.log('Le sondage est correctement rempli, prêt à enregistrer.'); // console.log('Le sondage est correctement rempli, prêt à enregistrer.');
// const newpoll = this.pollService.newPollFromForm(this.form); // const newpoll = this.pollService.newPollFromForm(this.form);

View File

@ -0,0 +1,16 @@
<section class="hero is-medium is-success">
<div class="hero-body">
<div class="container">
<h1 class="title">
Création de sondage réussie
</h1>
<h2 class="subtitle">
Bravo! partagez le lien de votre sondage. Un récapitulatif a été envoyé à votre adresse email.
</h2>
</div>
</div>
</section>
<br />
<section class="text-center">
<img src="assets/img/undraw_group_selfie_ijc6.svg" alt="image succès" />
</section>

View File

@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SuccessComponent } from './success.component';
describe('SuccessComponent', () => {
let component: SuccessComponent;
let fixture: ComponentFixture<SuccessComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [SuccessComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SuccessComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,12 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-success',
templateUrl: './success.component.html',
styleUrls: ['./success.component.scss'],
})
export class SuccessComponent implements OnInit {
constructor() {}
ngOnInit(): void {}
}

View File

@ -2,6 +2,7 @@ import { Routes } from '@angular/router';
import { HomeComponent } from './core/components/home/home.component'; import { HomeComponent } from './core/components/home/home.component';
import { PollService } from './core/services/poll.service'; import { PollService } from './core/services/poll.service';
import { PageNotFoundComponent } from './shared/components/page-not-found/page-not-found.component'; import { PageNotFoundComponent } from './shared/components/page-not-found/page-not-found.component';
import { SuccessComponent } from './features/administration/success/success.component';
export const routes: Routes = [ export const routes: Routes = [
{ path: '', component: HomeComponent }, { path: '', component: HomeComponent },
@ -35,6 +36,10 @@ export const routes: Routes = [
path: 'oldstuff', path: 'oldstuff',
loadChildren: () => import('./features/old-stuff/old-stuff.module').then((m) => m.OldStuffModule), loadChildren: () => import('./features/old-stuff/old-stuff.module').then((m) => m.OldStuffModule),
}, },
{
path: 'success',
component: SuccessComponent,
},
{ path: 'page-not-found', component: PageNotFoundComponent }, { path: 'page-not-found', component: PageNotFoundComponent },
{ path: '**', redirectTo: 'page-not-found', pathMatch: 'full' }, { path: '**', redirectTo: 'page-not-found', pathMatch: 'full' },
]; ];

View File

@ -1,6 +1,6 @@
{ {
"/api/*": { "/api/*": {
"target": "http://localhost:8000", "target": "http://localhost:3001",
"secure": false, "secure": false,
"logLevel": "debug" "logLevel": "debug"
} }

View File

@ -2,6 +2,7 @@
background: $primary; background: $primary;
main { main {
padding: 0;
margin-bottom: 2em; margin-bottom: 2em;
padding-bottom: 5em; padding-bottom: 5em;
padding-top: 1em; padding-top: 1em;

View File

@ -11,7 +11,9 @@
} }
main { main {
.container { padding-top: 0;
> .container {
background: #fff; background: #fff;
padding-bottom: 10em; padding-bottom: 10em;
} }