Skip to content

Commit

Permalink
Merge pull request #1796 from thebiggive/unfrozen-trunk
Browse files Browse the repository at this point in the history
Unfrozen trunk
  • Loading branch information
NoelLH authored Dec 10, 2024
2 parents 3daa03f + 7aebc60 commit cbe6f40
Show file tree
Hide file tree
Showing 52 changed files with 1,475 additions and 1,453 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"prefix": "app",
"style": "kebab-case"
}
]
],
"@typescript-eslint/no-floating-promises": "error"
}
},
{
Expand Down
22 changes: 22 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"browser-sync": "^3.0.0",
"cypress": "^13.2.0",
"eslint": "^8.57.0",
"eslint-plugin-no-floating-promise": "^2.0.0",
"jasmine-core": "^3.99.1",
"jasmine-spec-reporter": "~7.0.0",
"karma": "^6.4.2",
Expand Down
35 changes: 27 additions & 8 deletions src/app/app-routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {MandateService} from "./mandate.service";
import {RegularGivingComponent} from "./regular-giving/regular-giving.component";
import {Person} from "./person.model";
import {firstValueFrom} from "rxjs";
import {MandateComponent} from "./mandate/mandate.component";

export const registerPath = 'register';
export const myAccountPath = 'my-account';
Expand Down Expand Up @@ -135,17 +136,17 @@ const routes: Routes = [
resolve: {
campaign: CampaignResolver,
},
loadChildren: () => import('./meta-campaign/meta-campaign.module')
.then(c => c.MetaCampaignModule),
loadChildren: () => import('./explore/explore.module')
.then(c => c.ExploreModule),
},
{
path: 'metacampaign/:campaignId/:fundSlug',
pathMatch: 'full',
resolve: {
campaign: CampaignResolver,
},
loadChildren: () => import('./meta-campaign/meta-campaign.module')
.then(c => c.MetaCampaignModule),
loadChildren: () => import('./explore/explore.module')
.then(c => c.ExploreModule),
},
{
path: 'reset-password',
Expand Down Expand Up @@ -176,8 +177,8 @@ const routes: Routes = [
resolve: {
campaign: CampaignResolver,
},
loadChildren: () => import('./meta-campaign/meta-campaign.module')
.then(c => c.MetaCampaignModule),
loadChildren: () => import('./explore/explore.module')
.then(c => c.ExploreModule),
},
{
path: 'explore',
Expand Down Expand Up @@ -239,8 +240,8 @@ const routes: Routes = [
resolve: {
campaign: CampaignResolver,
},
loadChildren: () => import('./meta-campaign/meta-campaign.module')
.then(c => c.MetaCampaignModule),
loadChildren: () => import('./explore/explore.module')
.then(c => c.ExploreModule),
},
];

Expand Down Expand Up @@ -273,6 +274,24 @@ if (flags.regularGivingEnabled) {
},
},
)

routes.unshift({
path: `${myRegularGivingPath}/:mandateId`,
pathMatch: 'full',
component: MandateComponent,
canActivate: [
requireLogin,
],
resolve: {
/**
* need similar method but for one mandate
*/
// mandates: () => {
// inject(MandateService).getActiveMandate(mandateId),
// }

},
})
}

export {routes};
8 changes: 4 additions & 4 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
withInterceptorsFromDi,
} from "@angular/common/http";
import { provideHttpClientTesting } from "@angular/common/http/testing";
import { TestBed, waitForAsync } from "@angular/core/testing";
import { TestBed } from "@angular/core/testing";
import { ReactiveFormsModule } from "@angular/forms";
import { MatButtonModule } from "@angular/material/button";
import { MatIconModule } from "@angular/material/icon";
Expand All @@ -22,7 +22,7 @@ import { TBG_DONATE_ID_STORAGE } from "./identity.service";
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";

describe("AppComponent", () => {
beforeEach(waitForAsync(() => {
beforeEach(() => {
TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [AppComponent],
Expand Down Expand Up @@ -50,8 +50,8 @@ describe("AppComponent", () => {
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
],
}).compileComponents();
}));
});
});

it("should create the app", () => {
const fixture = TestBed.createComponent(AppComponent);
Expand Down
4 changes: 2 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ export class AppComponent implements AfterViewInit, OnDestroy, OnInit {
}

@HostListener('preferenceModalClosed', ['$event'])
onCookieBannerPreferenceModalClosed(_event: CustomEvent) {
async onCookieBannerPreferenceModalClosed(_event: CustomEvent) {
if (this.showingDedicatedCookiePreferencesPage) {
this.router.navigateByUrl('/')
await this.router.navigateByUrl('/')
}
}

Expand Down
15 changes: 12 additions & 3 deletions src/app/campaign-details/campaign-details.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<main class="b-container">
@if (campaignInPast) {
@if(campaign.isRegularGiving) {
<div>
<p class="error">
Sorry, <b>{{ campaign.title }}</b> is a regular giving campaign.</p>
<p>If you wish to set up a regular donation, please login to your donor account and visit the regular giving <a href="/regular-giving/{{campaign.id}}">campaign page</a>.
</p>
</div>
} @else {
@if (campaignInPast) {
<biggive-page-section>
<biggive-call-to-action
class="b-mt-40"
Expand All @@ -11,7 +19,7 @@
</biggive-page-section>
}

<div class="b-back-button">
<div class="b-back-button">
<biggive-formatted-text>
@if (campaign.parentRef && fromFund) {
<a mat-icon-button [routerLink]="'/' + campaign.parentRef + '/' + campaign.championRef">
Expand All @@ -38,7 +46,7 @@
</biggive-formatted-text>
</div>

<div class="c-details-container">
<div class="c-details-container">
<div class="b-primary-column">
<biggive-branded-image
space-below="4"
Expand Down Expand Up @@ -344,4 +352,5 @@ <h4 class="b-semi-bold b-mb-0">{{ update.modifiedDate | date : 'longDate' }}</h4
</div>
</div>
</div>
}
</main>
94 changes: 47 additions & 47 deletions src/app/campaign-details/campaign-details.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatTabsModule } from '@angular/material/tabs';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { Campaign } from '../campaign.model';
import { CampaignDetailsComponent } from './campaign-details.component';
import { OptimisedImagePipe } from '../optimised-image.pipe';
import { TimeLeftPipe } from '../time-left.pipe';
Expand Down Expand Up @@ -47,62 +46,63 @@ describe('CampaignDetailsComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(CampaignDetailsComponent);
component = fixture.componentInstance;
component.campaign = new Campaign(
'testCampaignId',
['Aim 1'],
123,
[],
'https://example.com/banner.png',
['Other'],
[],
['Animals'],
'Some Champion',
{
component.campaign = {
id: 'testCampaignId',
aims: ['Aim 1'],
amountRaised: 123,
additionalImageUris: [],
bannerUri: 'https://example.com/banner.png',
beneficiaries: ['Other'],
budgetDetails: [],
categories: ['Animals'],
championName: 'Some Champion',
isRegularGiving: false,
charity: {
id: 'testCharityId',
name: 'Test Charity',
optInStatement: 'Opt in statement.',
website: 'https://www.testcharity.co.uk',
regulatorNumber: '123456',
regulatorRegion: 'Scotland',
},
['United Kingdom'],
'GBP',
4,
new Date(),
'Impact reporting plan',
'Impact overview',
true,
987,
988,
false,
'The situation',
[],
true,
'The solution',
new Date(),
'Active',
'Test campaign description',
'Test Campaign!',
[],
false,
'Some information about what happens if funds are not used',
undefined,
undefined,
undefined,
false,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
1234,
undefined,
{
countries: ['United Kingdom'],
currencyCode: 'GBP',
donationCount: 4,
endDate: new Date(),
impactReporting: 'Impact reporting plan',
impactSummary: 'Impact overview',
isMatched: true,
matchFundsRemaining: 987,
matchFundsTotal: 988,
parentUsesSharedFunds: false,
problem: 'The situation',
quotes: [],
ready: true,
solution: 'The solution',
startDate: new Date(),
status: 'Active',
summary: 'Test campaign description',
title: 'Test Campaign!',
updates: [],
usesSharedFunds: false,
alternativeFundUse: 'Some information about what happens if funds are not used',
campaignCount: undefined,
championOptInStatement: undefined,
championRef: undefined,
hidden: false,
logoUri: undefined,
parentAmountRaised: undefined,
parentDonationCount: undefined,
parentRef: undefined,
parentTarget: undefined,
surplusDonationInfo: undefined,
target: 1234,
thankYouMessage: undefined,
video: {
provider: 'youtube',
key: 'someFakeKey',
},
);
};
// For now, *don't* detect changes as ngOnInit() will clear out the fixed `campaign` trying to
// read a value from the state transfer service. TODO it would be better to mock an HTTP response
// instead so the data is loaded in a more realistic way.
Expand Down
6 changes: 3 additions & 3 deletions src/app/campaign-details/campaign-details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class CampaignDetailsComponent implements OnInit, OnDestroy {
if (params.fromFund) {
this.fromFund = true;
}
});
}).catch(console.error);
}

ngOnDestroy() {
Expand All @@ -64,15 +64,15 @@ export class CampaignDetailsComponent implements OnInit, OnDestroy {
}
}

goBackToMetacampaign() {
async goBackToMetacampaign() {
const url = `/${this.campaign.parentRef}`;

if (this.navigationService.isLastUrl(url)) {
this.location.back();
return;
}

this.router.navigateByUrl(url);
await this.router.navigateByUrl(url);
}

private setSecondaryProps(campaign: Campaign) {
Expand Down
Loading

0 comments on commit cbe6f40

Please sign in to comment.