Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cookie disclaimer until accepted #68

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/frontend/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<app-navbar />
<router-outlet />
<div class="mb-20"></div>
<app-disclaimer />
3 changes: 2 additions & 1 deletion apps/frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component } from '@angular/core'
import { RouterModule } from '@angular/router'
import { NavbarComponent } from './shared/navigation/navbar/navbar.component'
import { DisclaimerComponent } from './shared/navigation/disclaimer/disclaimer.component'

@Component({
standalone: true,
imports: [RouterModule, NavbarComponent],
imports: [RouterModule, NavbarComponent, DisclaimerComponent],
selector: 'app-root',
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
Expand Down
11 changes: 10 additions & 1 deletion apps/frontend/src/app/features/home/home.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { ComponentFixture, inject, TestBed } from '@angular/core/testing'
import { HomeComponent } from './home.component'
import { Router } from '@angular/router'

describe('HomeComponent', () => {
let component: HomeComponent
Expand All @@ -18,4 +19,12 @@ describe('HomeComponent', () => {
it('should create', () => {
expect(component).toBeTruthy()
})

test('should search vote', inject([Router], (mockRouter: Router) => {
const spyRouter = spyOn(mockRouter, 'navigate').and.stub()

component.voteId.setValue('123')
component.searchVote()
expect(spyRouter.calls.first().args[0]).toContain('voting' && '123')
}))
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@if (!hasAcceptedCookies()) {
<div class="pointer-events-none fixed inset-x-0 bottom-0 px-6 pb-6">
<div
class="pointer-events-auto ml-auto max-w-xl rounded-xl bg-white p-6 shadow-lg ring-1 ring-gray-900/10"
>
<p class="text-sm leading-6 text-gray-900">
We use cookies to enhance your experience. Any data, such as your wallet
address, is only shared between you and the Stellar Network. By using our
site, you consent to this.
</p>
<div class="mt-4 flex items-center gap-x-5">
<button
(click)="acceptCookies()"
type="button"
class="rounded-md bg-gray-900 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-gray-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-900"
>
Accept
</button>
</div>
</div>
</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'

import { DisclaimerComponent } from './disclaimer.component'

describe('DisclaimerComponent', () => {
let component: DisclaimerComponent
let fixture: ComponentFixture<DisclaimerComponent>

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DisclaimerComponent],
}).compileComponents()

fixture = TestBed.createComponent(DisclaimerComponent)
component = fixture.componentInstance
fixture.detectChanges()
})

it('should create', () => {
expect(component).toBeTruthy()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component } from '@angular/core'
import { CookieService } from 'ngx-cookie-service'
import { RouterLink } from '@angular/router'

@Component({
selector: 'app-disclaimer',
standalone: true,
imports: [RouterLink],
templateUrl: './disclaimer.component.html',
styleUrl: './disclaimer.component.css',
})
export class DisclaimerComponent {
constructor(private cookieService: CookieService) {}
acceptCookies() {
this.cookieService.set('disclaimer', 'accepted', 365)
}

hasAcceptedCookies() {
return this.cookieService.check('disclaimer')
}
}
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.