-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
235 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { computed, Injectable, Signal, signal, WritableSignal } from '@angular/core'; | ||
import { RecentTransaction } from '../../shared/model/buxx.model'; | ||
import { Subject } from 'rxjs'; | ||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
|
||
export type RecentActivityState = { | ||
data: RecentTransaction[]; | ||
} | ||
|
||
@Injectable() | ||
export class RecentActivityStore { | ||
|
||
private state: WritableSignal<RecentActivityState> = signal({data: []}); | ||
readonly data: Signal<RecentTransaction[]> = computed(() => this.state().data); | ||
|
||
reset$: Subject<void> = new Subject<void>(); | ||
add$: Subject<RecentTransaction> = new Subject<RecentTransaction>(); | ||
|
||
constructor() { | ||
this.reset$.pipe(takeUntilDestroyed()) | ||
.subscribe(() => this.state.set({data: []})); | ||
|
||
this.add$.pipe(takeUntilDestroyed()) | ||
.subscribe((transaction: RecentTransaction) => this.state.update(state => ({ | ||
data: [...state.data, transaction] | ||
}))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/app/buxx/ui/recent-activity/recent-activity.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@if (transactions().length) { | ||
<mat-accordion class="flex flex-col w-full mb-4 sm:min-w-11/12 sm:mx-14"> | ||
<mat-expansion-panel [hideToggle]="true"> | ||
<mat-expansion-panel-header> | ||
<mat-panel-title class="text-lg"> | ||
<mat-icon class="mr-2">layers</mat-icon> | ||
Recent Activity | ||
</mat-panel-title> | ||
</mat-expansion-panel-header> | ||
</mat-expansion-panel> | ||
|
||
@for (transaction of transactions(); track transaction.id) { | ||
<mat-expansion-panel class="w-full"> | ||
<mat-expansion-panel-header> | ||
<mat-panel-title> | ||
<span class="mr-4 font-bold"> | ||
@if (transaction.isExpense) { | ||
<mat-icon class="negative">trending_down</mat-icon> | ||
} @else { | ||
<mat-icon class="positive">trending_up</mat-icon> | ||
} | ||
</span> | ||
{{ transaction.name }} | ||
<span class="ml-2"> | ||
@if (transaction.action === 'DELETED') { | ||
<mat-chip style="background: #6f1a07">deleted</mat-chip> | ||
} @else if (transaction.action === 'SAVED') { | ||
<mat-chip style="background: #607d8b">saved</mat-chip> | ||
} | ||
</span> | ||
</mat-panel-title> | ||
<mat-panel-description>Rs. {{ transaction.amount }}</mat-panel-description> | ||
<mat-panel-description>{{ transaction.date | date: 'mediumDate' }}</mat-panel-description> | ||
</mat-expansion-panel-header> | ||
<p>{{ transaction.details }}</p> | ||
</mat-expansion-panel> | ||
} | ||
</mat-accordion> | ||
} |
Empty file.
21 changes: 21 additions & 0 deletions
21
src/app/buxx/ui/recent-activity/recent-activity.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { RecentActivityComponent } from './recent-activity.component'; | ||
|
||
describe('RecentTransactionComponent', () => { | ||
let component: RecentActivityComponent; | ||
let fixture: ComponentFixture<RecentActivityComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [RecentActivityComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(RecentActivityComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
49 changes: 49 additions & 0 deletions
49
src/app/buxx/ui/recent-activity/recent-activity.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Component, input } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatExpansionModule } from '@angular/material/expansion'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { RecentTransaction } from '../../../shared/model/buxx.model'; | ||
import { MatChipsModule } from '@angular/material/chips'; | ||
import { DatePipe } from '@angular/common'; | ||
import { MatCardModule } from '@angular/material/card'; | ||
|
||
@Component({ | ||
selector: 'as-recent-activity', | ||
standalone: true, | ||
imports: [ | ||
MatButtonModule, | ||
MatExpansionModule, | ||
MatIconModule, | ||
MatChipsModule, | ||
DatePipe, | ||
MatCardModule | ||
], | ||
templateUrl: './recent-activity.component.html', | ||
styleUrl: './recent-activity.component.scss', | ||
}) | ||
export class RecentActivityComponent { | ||
|
||
transactions = input.required<RecentTransaction[]>(); | ||
// transactions: RecentTransaction[] = [ | ||
// { | ||
// action: 'DELETED', | ||
// date: (new Date()).toString(), | ||
// id: 'sds', | ||
// name: 'Test Name', | ||
// isExpense: true, | ||
// details: 'sdfd', | ||
// amount: 222, | ||
// userId: 'sdfsdf' | ||
// }, | ||
// { | ||
// action: 'SAVED', | ||
// date: (new Date()).toString(), | ||
// id: 'sds', | ||
// name: 'Test Name Again', | ||
// isExpense: true, | ||
// details: 'sdfd', | ||
// amount: 222, | ||
// userId: 'sdfsdf' | ||
// } | ||
// ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.