Skip to content

Commit

Permalink
feat: removed old my-expenses page (deprecation) - Part 2 (#2815)
Browse files Browse the repository at this point in the history
* feat: removed old my-expenses page (deprecation) - Part 2

* feat: removed old my-expenses page (deprecation) - Part 3 (#2816)

* feat: removed old my-expenses page (deprecation) - Part 3

* feat: removed old my-expenses page (deprecation) - Part 4 (#2817)

* feat: removed old my-expenses page (deprecation) - Part 4

* fix: correction in card filters logic (#2818)
  • Loading branch information
suyashpatil78 authored Mar 11, 2024
1 parent 116472a commit 25beffb
Show file tree
Hide file tree
Showing 31 changed files with 50 additions and 214 deletions.
78 changes: 0 additions & 78 deletions src/app/core/guards/my-expenses-guard.guard.spec.ts

This file was deleted.

28 changes: 0 additions & 28 deletions src/app/core/guards/my-expenses-guard.guard.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/core/mock-data/expense-filters.data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExpenseFilters } from 'src/app/fyle/my-expenses-v2/my-expenses-filters.model';
import { ExpenseFilters } from 'src/app/fyle/my-expenses/my-expenses-filters.model';
import { DateFilters } from 'src/app/shared/components/fy-filters/date-filters.enum';
import { ExpenseType } from '../enums/expense-type.enum';
import { FilterState } from '../enums/filter-state.enum';
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/mock-data/modal-controller.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CreateNewReportComponent as createReportV2 } from 'src/app/shared/compo
import { CreateNewReportComponent } from 'src/app/shared/components/create-new-report/create-new-report.component';
import { Mode } from '@ionic/core';
import { fyModalProperties } from './model-properties.data';
import { AddTxnToReportDialogComponent as v2 } from 'src/app/fyle/my-expenses-v2/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { AddTxnToReportDialogComponent as v2 } from 'src/app/fyle/my-expenses/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { PopupAlertComponent } from 'src/app/shared/components/popup-alert/popup-alert.component';
import { FilterOptions } from 'src/app/shared/components/fy-filters/filter-options.interface';
import { DateFilters } from 'src/app/shared/components/fy-filters/date-filters.enum';
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/models/platform/expense-filters.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Filters } from 'src/app/fyle/my-expenses-v2/my-expenses-filters.model';
import { Filters } from 'src/app/fyle/my-expenses/my-expenses-filters.model';

export interface ExpenseFilters extends Omit<Filters, 'state'> {
state: string | string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PaymentModeSummary } from 'src/app/core/models/payment-mode-summary.mod
import { AccountType } from 'src/app/core/models/platform/v1/account.model';
import { Expense } from 'src/app/core/models/platform/v1/expense.model';
import { GetExpenseQueryParam } from 'src/app/core/models/platform/v1/get-expenses-query.model';
import { ExpenseFilters } from 'src/app/fyle/my-expenses/expense-filters.model';
import { ExpenseFilters } from 'src/app/fyle/my-expenses/my-expenses-filters.model';
import { DateFilters } from 'src/app/shared/components/fy-filters/date-filters.enum';
import { DateService } from '../../../date.service';

Expand Down
9 changes: 3 additions & 6 deletions src/app/core/services/platform/v1/shared/expenses.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PaymentModeSummary } from 'src/app/core/models/payment-mode-summary.mod
import { AccountType } from 'src/app/core/models/platform/v1/account.model';
import { Expense } from 'src/app/core/models/platform/v1/expense.model';
import { GetExpenseQueryParam } from 'src/app/core/models/platform/v1/get-expenses-query.model';
import { ExpenseFilters } from 'src/app/fyle/my-expenses-v2/my-expenses-filters.model';
import { ExpenseFilters } from 'src/app/fyle/my-expenses/my-expenses-filters.model';
import { DateFilters } from 'src/app/shared/components/fy-filters/date-filters.enum';
import { DateService } from '../../../date.service';

Expand Down Expand Up @@ -200,11 +200,8 @@ export class ExpensesService {
): Record<string, string | string[] | boolean> {
const newQueryParamsCopy = cloneDeep(newQueryParams);
if (filters.cardNumbers?.length > 0) {
let cardNumberString = '';
cardNumberString = filters.cardNumbers.join(',');
cardNumberString = cardNumberString.slice(0, cardNumberString.length);
newQueryParamsCopy['matched_corporate_card_transactions->0->corporate_card_number'] =
'in.(' + cardNumberString + ')';
const cardNumberString = filters.cardNumbers.map((cardNumber) => `"${cardNumber}"`).join(',');
newQueryParamsCopy['matched_corporate_card_transactions->0->corporate_card_number'] = `in.(${cardNumberString})`;
}

return newQueryParamsCopy;
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/tracking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import {
EnrollingNonRTFCardProperties,
} from '../models/tracking-properties.model';
import { ExpenseView } from '../models/expense-view.enum';
import { ExpenseFilters } from 'src/app/fyle/my-expenses-v2/my-expenses-filters.model';
import { ReportFilters } from 'src/app/fyle/my-expenses-v2/my-expenses-filters.model';
import { ExpenseFilters } from 'src/app/fyle/my-expenses/my-expenses-filters.model';
import { ReportFilters } from 'src/app/fyle/my-expenses/my-expenses-filters.model';
import { TaskFilters } from '../models/task-filters.model';
import { OrgCategory } from '../models/v1/org-category.model';
import { TeamReportsFilters } from '../models/team-reports-filters.model';
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/transaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { UserEventService } from './user-event.service';
import { UndoMerge } from '../models/undo-merge.model';
import { cloneDeep } from 'lodash';
import { DateFilters } from 'src/app/shared/components/fy-filters/date-filters.enum';
import { ExpenseFilters } from 'src/app/fyle/my-expenses-v2/my-expenses-filters.model';
import { ExpenseFilters } from 'src/app/fyle/my-expenses/my-expenses-filters.model';
import { PAGINATION_SIZE } from 'src/app/constants';
import { PaymentModesService } from './payment-modes.service';
import { OrgSettingsService } from './org-settings.service';
Expand Down
26 changes: 0 additions & 26 deletions src/app/fyle/dashboard/stats/stats.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ describe('StatsComponent', () => {

describe('goToExpensesPage():', () => {
it('goToExpensesPage(): should navigate to expenses page with query params', () => {
component.redirectToNewPage$ = of(false);
component.goToExpensesPage('COMPLETE');

expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_expenses'], {
Expand All @@ -368,7 +367,6 @@ describe('StatsComponent', () => {
});

it('goToExpensesPage(): should navigate to expenses page with query params', () => {
component.redirectToNewPage$ = of(false);
component.goToExpensesPage('INCOMPLETE');

expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_expenses'], {
Expand All @@ -378,30 +376,6 @@ describe('StatsComponent', () => {
});
expect(trackingService.dashboardOnIncompleteExpensesClick).toHaveBeenCalledTimes(1);
});

it('goToExpensesPage(): should navigate to v2 expenses page with query params', () => {
component.redirectToNewPage$ = of(true);
component.goToExpensesPage('COMPLETE');

expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_expenses_v2'], {
queryParams: {
filters: JSON.stringify({ state: ['READY_TO_REPORT'] }),
},
});
expect(trackingService.dashboardOnUnreportedExpensesClick).toHaveBeenCalledTimes(1);
});

it('goToExpensesPage(): should navigate to v2 expenses page with query params', () => {
component.redirectToNewPage$ = of(true);
component.goToExpensesPage('INCOMPLETE');

expect(router.navigate).toHaveBeenCalledOnceWith(['/', 'enterprise', 'my_expenses_v2'], {
queryParams: {
filters: JSON.stringify({ state: ['DRAFT'] }),
},
});
expect(trackingService.dashboardOnIncompleteExpensesClick).toHaveBeenCalledTimes(1);
});
});

describe('trackDashboardLaunchTime():', () => {
Expand Down
29 changes: 13 additions & 16 deletions src/app/fyle/dashboard/stats/stats.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,23 +200,20 @@ export class StatsComponent implements OnInit {
}

goToExpensesPage(state: string): void {
this.redirectToNewPage$.subscribe((redirect) => {
const endpoint = redirect ? 'my_expenses_v2' : 'my_expenses';
if (state === 'COMPLETE') {
const queryParams: Params = { filters: JSON.stringify({ state: ['READY_TO_REPORT'] }) };
this.router.navigate(['/', 'enterprise', endpoint], {
queryParams,
});
if (state === 'COMPLETE') {
const queryParams: Params = { filters: JSON.stringify({ state: ['READY_TO_REPORT'] }) };
this.router.navigate(['/', 'enterprise', 'my_expenses'], {
queryParams,
});

this.trackingService.dashboardOnUnreportedExpensesClick();
} else {
const queryParams: Params = { filters: JSON.stringify({ state: ['DRAFT'] }) };
this.router.navigate(['/', 'enterprise', endpoint], {
queryParams,
});
this.trackingService.dashboardOnIncompleteExpensesClick();
}
});
this.trackingService.dashboardOnUnreportedExpensesClick();
} else {
const queryParams: Params = { filters: JSON.stringify({ state: ['DRAFT'] }) };
this.router.navigate(['/', 'enterprise', 'my_expenses'], {
queryParams,
});
this.trackingService.dashboardOnIncompleteExpensesClick();
}
}

private trackDashboardLaunchTime(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/fyle/dashboard/tasks/tasks-3.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { cloneDeep, noop } from 'lodash';
import { snackbarPropertiesRes2 } from 'src/app/core/mock-data/snackbar-properties.data';
import { ToastMessageComponent } from 'src/app/shared/components/toast-message/toast-message.component';
import { ToastType } from 'src/app/core/enums/toast-type.enum';
import { AddTxnToReportDialogComponent } from '../../my-expenses-v2/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { AddTxnToReportDialogComponent } from '../../my-expenses/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { ExpensesService } from 'src/app/core/services/platform/v1/spender/expenses.service';
import { expenseData } from 'src/app/core/mock-data/platform/v1/expense.data';
import { unreportedExpensesQueryParams } from 'src/app/core/mock-data/platform/v1/expenses-query-params.data';
Expand Down
2 changes: 1 addition & 1 deletion src/app/fyle/dashboard/tasks/tasks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { FilterOptionType } from 'src/app/shared/components/fy-filters/filter-op
import { FilterOptions } from 'src/app/shared/components/fy-filters/filter-options.interface';
import { FyFiltersComponent } from 'src/app/shared/components/fy-filters/fy-filters.component';
import { ToastMessageComponent } from 'src/app/shared/components/toast-message/toast-message.component';
import { AddTxnToReportDialogComponent } from '../../my-expenses-v2/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { AddTxnToReportDialogComponent } from '../../my-expenses/add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { FilterPill } from 'src/app/shared/components/fy-filter-pills/filter-pill.interface';
import { SelectedFilters } from 'src/app/shared/components/fy-filters/selected-filters.interface';
import { ExpensesService } from 'src/app/core/services/platform/v1/spender/expenses.service';
Expand Down
6 changes: 2 additions & 4 deletions src/app/fyle/fyle-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MyExpensesGuardGuard } from '../core/guards/my-expenses-guard.guard';
import { BetaPageFeatureFlagGuard } from '../core/guards/beta-page-feature-flag.guard';

const routes: Routes = [
{
path: 'my_dashboard',
loadChildren: () => import('./dashboard/dashboard.module').then((m) => m.DashboardPageModule),
},
{
path: 'my_expenses_v2',
loadChildren: () => import('./my-expenses-v2/my-expenses-v2.module').then((m) => m.MyExpensesV2PageModule),
path: 'my_expenses',
loadChildren: () => import('./my-expenses/my-expenses.module').then((m) => m.MyExpensesPageModule),
},
{
path: 'my_advances',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { MyExpensesV2Page } from './my-expenses-v2.page';
import { MyExpensesPage } from './my-expenses.page';

const routes: Routes = [
{
path: '',
component: MyExpensesV2Page,
component: MyExpensesPage,
},
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class MyExpensesV2PageRoutingModule {}
export class MyExpensesPageRoutingModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { MyExpensesV2PageRoutingModule } from './my-expenses-routing.module';
import { MyExpensesV2Page } from './my-expenses-v2.page';
import { MyExpensesPageRoutingModule } from './my-expenses-routing.module';
import { MyExpensesPage } from './my-expenses.page';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
Expand All @@ -22,7 +22,7 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
CommonModule,
FormsModule,
IonicModule,
MyExpensesV2PageRoutingModule,
MyExpensesPageRoutingModule,
MatInputModule,
MatFormFieldModule,
MatButtonModule,
Expand All @@ -40,6 +40,6 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
SharedModule,
MatCheckboxModule,
],
declarations: [MyExpensesV2Page, AddTxnToReportDialogComponent],
declarations: [MyExpensesPage, AddTxnToReportDialogComponent],
})
export class MyExpensesV2PageModule {}
export class MyExpensesPageModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ import { MaskNumber } from 'src/app/shared/pipes/mask-number.pipe';
import { ReportState } from 'src/app/shared/pipes/report-state.pipe';
import { environment } from 'src/environments/environment';
import { AddTxnToReportDialogComponent } from './add-txn-to-report-dialog/add-txn-to-report-dialog.component';
import { MyExpensesV2Page } from './my-expenses-v2.page';
import { MyExpensesPage } from './my-expenses.page';
import { MyExpensesService } from './my-expenses.service';
import { completeStats, incompleteStats } from 'src/app/core/mock-data/platform/v1/expenses-stats.data';

describe('MyExpensesV2Page', () => {
let component: MyExpensesV2Page;
let fixture: ComponentFixture<MyExpensesV2Page>;
let component: MyExpensesPage;
let fixture: ComponentFixture<MyExpensesPage>;
let tasksService: jasmine.SpyObj<TasksService>;
let currencyService: jasmine.SpyObj<CurrencyService>;
let reportService: jasmine.SpyObj<ReportService>;
Expand Down Expand Up @@ -286,7 +286,7 @@ describe('MyExpensesV2Page', () => {
]);

TestBed.configureTestingModule({
declarations: [MyExpensesV2Page, ReportState, MaskNumber],
declarations: [MyExpensesPage, ReportState, MaskNumber],
imports: [IonicModule.forRoot(), RouterTestingModule, HttpClientTestingModule],
providers: [
{ provide: TasksService, useValue: tasksServiceSpy },
Expand Down Expand Up @@ -395,7 +395,7 @@ describe('MyExpensesV2Page', () => {
schemas: [NO_ERRORS_SCHEMA],
}).compileComponents();

fixture = TestBed.createComponent(MyExpensesV2Page);
fixture = TestBed.createComponent(MyExpensesPage);
component = fixture.componentInstance;

activatedRoute = TestBed.inject(ActivatedRoute) as jasmine.SpyObj<ActivatedRoute>;
Expand Down
Loading

0 comments on commit 25beffb

Please sign in to comment.