Skip to content

Commit

Permalink
add back url to contact page
Browse files Browse the repository at this point in the history
  • Loading branch information
fxmontigny committed Jul 19, 2023
1 parent 19d332e commit 530c824
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
15 changes: 12 additions & 3 deletions front/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AfterViewInit, Component } from '@angular/core'
import { Router } from '@angular/router'
import { NavigationEnd, Router } from '@angular/router'
import { environment } from 'src/environments/environment'
import { USER_ACCESS_AVERAGE_TIME } from './constants/user-access'
import { AlertInterface } from './interfaces/alert'
Expand All @@ -8,6 +8,7 @@ import { ContentieuxOptionsService } from './services/contentieux-options/conten
import { UserService } from './services/user/user.service'
import { iIOS } from './utils/system'
import { copy } from './utils'
import { filter } from 'rxjs'

/**
* Variable d'environement en global
Expand Down Expand Up @@ -50,6 +51,15 @@ export class AppComponent implements AfterViewInit {
}

this.onControlSSL()

router.events
.pipe(filter((event) => event instanceof NavigationEnd))
// @ts-ignore
.subscribe((event: NavigationEnd) => {
this.appService.previousUrl = this.appService.currentUrl
this.appService.currentUrl = event.url
})

router.events.subscribe(() => {
const user = this.userService.user.getValue()
if (user && this.dbReady === false) {
Expand Down Expand Up @@ -106,7 +116,7 @@ export class AppComponent implements AfterViewInit {
onCloseAlert(clickToOk = false) {
const alertObject = this.appService.alert.getValue()
this.appService.alert.next(null)
if(clickToOk && alertObject && alertObject.callback) {
if (clickToOk && alertObject && alertObject.callback) {
alertObject.callback()
}
}
Expand Down Expand Up @@ -135,7 +145,6 @@ export class AppComponent implements AfterViewInit {
observer.observe(elementToObserve, { subtree: true, childList: true });
*/

/* document.addEventListener(
'DOMNodeInserted',
() => {
Expand Down
2 changes: 1 addition & 1 deletion front/src/app/components/wrapper/wrapper.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h6>{{ hrBackup && hrBackup.label }}</h6>
</ul>
</div>
<div class="menu-item">
<a [routerLink]="['/contact']">
<a [routerLink]="['/contact']" [queryParams]="{backUrl: true}">
<p>Nous contacter</p>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion front/src/app/routes/contact/contact.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<img src="/assets/icons/bloc-marque/bloc-marque-white@2x.svg" alt="ministère de la justice" />
<img src="/assets/icons/logos/white-192x192@1x.svg" alt="a-just" />
</div>
<p class="back-link"><a routerLink="/">Retour</a></p>
<p class="back-link"><a [routerLink]="routerLinkToGoBack">Retour</a></p>
<h3>Contact</h3>

<div id="hubspotForm"></div>
Expand Down
30 changes: 23 additions & 7 deletions front/src/app/routes/contact/contact.page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { AfterViewInit, Component } from '@angular/core'
import { Title } from '@angular/platform-browser'
import { ActivatedRoute } from '@angular/router'
import { AppService } from 'src/app/services/app/app.service'

declare const hbspt: any

Expand All @@ -12,20 +14,34 @@ declare const hbspt: any
styleUrls: ['./contact.page.scss'],
})
export class ContactPage implements AfterViewInit {
/**
* Get Link to back
*/
routerLinkToGoBack: string[] = ['/']

/**
* Constructeur
* @param title
* @param title
*/
constructor(private title: Title) {
constructor(
private title: Title,
private route: ActivatedRoute,
private appService: AppService
) {
this.title.setTitle('Contact | A-Just')
}

ngAfterViewInit() {
hbspt.forms.create({
region: "eu1",
portalId: "26493393",
formId: "0f776962-cddf-4ccb-b2a8-100936289ebb",
target: "#hubspotForm"
});
region: 'eu1',
portalId: '26493393',
formId: '0f776962-cddf-4ccb-b2a8-100936289ebb',
target: '#hubspotForm',
})

const { backUrl } = this.route.snapshot.queryParams
if (backUrl && backUrl === 'true' && this.appService.previousUrl) {
this.routerLinkToGoBack = [this.appService.previousUrl]
}
}
}
8 changes: 8 additions & 0 deletions front/src/app/services/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ export class AppService {
alert: BehaviorSubject<AlertInterface | null> = new BehaviorSubject<AlertInterface | null>(
null
)
/**
* Cache previous URL
*/
previousUrl: string | null = null
/**
* Cache current URL
*/
currentUrl: string | null = null
}

0 comments on commit 530c824

Please sign in to comment.