Skip to content

Commit

Permalink
Modified Quotation and Purchase section
Browse files Browse the repository at this point in the history
  • Loading branch information
shabeelashraf5 committed Jan 19, 2025
1 parent bc78463 commit 92953b8
Show file tree
Hide file tree
Showing 29 changed files with 262 additions and 105 deletions.
28 changes: 14 additions & 14 deletions client/package-lock.json

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

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"private": true,
"dependencies": {
"@amcharts/amcharts4": "^4.10.38",
"@angular/animations": "^17.1.0",
"@angular/animations": "^17.3.8",
"@angular/cdk": "^17.1.2",
"@angular/common": "^17.1.0",
"@angular/compiler": "^17.1.0",
Expand Down
105 changes: 67 additions & 38 deletions client/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ import { SuccessPaymentComponent } from './portal/employee/accounting/success-pa
import { NotFoundComponent } from './layouts/not-found/not-found.component';
import { ExcelComponent } from './layouts/excel/excel.component';
import { AdminRouterComponent } from './portal/admin/admin-router.component';




import { dashboardResolverResolver } from './service/dashboard/dashboard-resolver.resolver';
import { profileResolver } from './service/profile/profile.resolver';


const routes: Routes = [
Expand All @@ -61,7 +59,7 @@ const routes: Routes = [
children: [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{path: 'portal' , loadChildren: () => import('./portal/admin/admin-portal/admin-portal.module').then( m => m.AdminPortalModule) },
{path: 'dashboard' , loadChildren: () => import('./portal/admin/dashboard/ad-dashboard/ad-dashboard.module').then( m => m.AdDashboardModule)},
{path: 'dashboard' , loadChildren: () => import('./portal/admin/dashboard/ad-dashboard/ad-dashboard.module').then( m => m.AdDashboardModule) },
{path: 'employee' , loadChildren: () => import('./portal/admin/employee/ad-employee/ad-employee.module').then( m => m.AdEmployeeModule) },
{path: 'product' , loadChildren: () => import('./portal/admin/product/ad-product/ad-product.module').then( m => m.AdProductModule) },
{path: 'category' , loadChildren: () => import('./portal/admin/category/ad-category/ad-category.module').then( m => m.AdCategoryModule) },
Expand All @@ -71,62 +69,93 @@ const routes: Routes = [
]
},

{
path: 'portal',
children: [

{ path: 'dashboard' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule), resolve: {profileData: profileResolver}},

{ path: 'portal/dashboard' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },
{
path: 'sales',
children: [

{ path: 'portal/sales' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },
{ path: 'portal/sales/customer' , loadChildren: () => import('./portal/employee/sales/customer/customer.module').then( m => m.CustomerModule) },
{ path: 'portal/sales/quotations' , loadChildren: () => import('./portal/employee/sales/quotation/quotation.module').then( m => m.QuotationModule) },
{ path: 'portal/sales/quotations/:id' , loadChildren: () => import('./portal/employee/sales/add-quotation/add-quotation.module').then( m => m.AddQuotationModule) },
{ path: 'portal/sales/sales-order' , loadChildren: () => import('./portal/employee/sales/sales-order/sales-order.module').then( m => m.SalesOrderModule) },
{ path: 'portal/sales/sales-order/:id' , loadChildren: () => import('./portal/employee/sales/client-po/client-po.module').then( m => m.ClientPoModule) },
{ path: 'portal/sales/sales-analysis' , loadChildren: () => import('./portal/employee/sales/sales-analysis/sales-analysis.module').then( m => m.SalesAnalysisModule) },
// { path: 'sales' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },
{ path: 'customer' , loadChildren: () => import('./portal/employee/sales/customer/customer.module').then( m => m.CustomerModule) },
{ path: 'quotations' , loadChildren: () => import('./portal/employee/sales/quotation/quotation.module').then( m => m.QuotationModule) },
{ path: 'quotations/:id' , loadChildren: () => import('./portal/employee/sales/add-quotation/add-quotation.module').then( m => m.AddQuotationModule) },
{ path: 'sales-order' , loadChildren: () => import('./portal/employee/sales/sales-order/sales-order.module').then( m => m.SalesOrderModule) },
{ path: 'sales-order/:id' , loadChildren: () => import('./portal/employee/sales/client-po/client-po.module').then( m => m.ClientPoModule) },
{ path: 'sales-analysis' , loadChildren: () => import('./portal/employee/sales/sales-analysis/sales-analysis.module').then( m => m.SalesAnalysisModule) },

]
},

// { path: 'purchase' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },

{
path: 'purchase',
children: [

{ path: 'portal/purchase' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },
{ path: 'supplier' , loadChildren: () => import('./portal/employee/purchase/supplier/supplier.module').then( m => m.SupplierModule) },
{ path: 'purchase-order' , loadChildren: () => import('./portal/employee/purchase/purchase-order/purchase-order.module').then( m => m.PurchaseOrderModule) },

{ path: 'portal/purchase/supplier' , loadChildren: () => import('./portal/employee/purchase/supplier/supplier.module').then( m => m.SupplierModule) },
{ path: 'portal/purchase/purchase-order' , loadChildren: () => import('./portal/employee/purchase/purchase-order/purchase-order.module').then( m => m.PurchaseOrderModule) },
//{ path: 'portal/purchase/vendor-evaluation' , component: EvaluationComponent, canActivate: [CanEmployeeLogged] },
{ path: 'portal/purchase/purchase-order/:id' , loadChildren: () => import('./portal/employee/purchase/add-po/add-po.module').then( m => m.AddPoModule) },
{ path: 'portal/purchase/purchase-history' , loadChildren: () => import('./portal/employee/purchase/purchase-history/purchase-history.module').then( m => m.PurchaseHistoryModule) },
{ path: 'purchase-order/:id' , loadChildren: () => import('./portal/employee/purchase/add-po/add-po.module').then( m => m.AddPoModule) },
{ path: 'purchase-history' , loadChildren: () => import('./portal/employee/purchase/purchase-history/purchase-history.module').then( m => m.PurchaseHistoryModule) },

]
},

{
path: 'warehouse',
children: [
// { path: 'warehouse' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },
{ path: 'inventory-list' , loadChildren: () => import('./portal/employee/warehouse/inventory-list/inventory-list.module').then( m => m.InventoryListModule) },

{ path: 'portal/warehouse' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },
{ path: 'portal/warehouse/inventory-list' , loadChildren: () => import('./portal/employee/warehouse/inventory-list/inventory-list.module').then( m => m.InventoryListModule) },
]
},

{
path: 'shipment',
children: [

{ path: 'portal/shipment' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },
{ path: 'portal/shipment/shipment-history' , loadChildren: () => import('./portal/employee/shipment/shipment-history/shipment-history.module').then( m => m.ShipmentHistoryModule) },
// { path: 'shipment' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },
{ path: 'shipment-history' , loadChildren: () => import('./portal/employee/shipment/shipment-history/shipment-history.module').then( m => m.ShipmentHistoryModule) },
]

},

{ path: 'portal/accounting' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },
{ path: 'portal/accounting/invoicing' , loadChildren: () => import('./portal/employee/accounting/invoicing/invoicing.module').then( m => m.InvoicingModule)},
{ path: 'portal/accounting/invoicing/:id' , loadChildren: () => import('./portal/employee/accounting/invoice-details/invoice-details.module').then( m => m.InvoiceDetailsModule) },
{ path: 'portal/accounting/financial-transaction' , loadChildren: () => import('./portal/employee/accounting/financial-transaction/financial-transaction.module').then( m => m.FinancialTransactionModule) },
{ path: 'portal/accounting/financial-reports' , component: FinancialReportComponent, canActivate: [CanEmployeeLogged] },
{ path: 'portal/accounting/financial-transaction/:id' , loadChildren: () => import('./portal/employee/accounting/payment/payment.module').then( m => m.PaymentModule) },
{
path: 'accounting',
children: [

// { path: 'accounting' , loadChildren: () => import('./portal/employee/dashboard/em-dashboard/em-dashboard.module').then(m => m.EmDashboardModule) },
{ path: 'invoicing' , loadChildren: () => import('./portal/employee/accounting/invoicing/invoicing.module').then( m => m.InvoicingModule)},
{ path: 'invoicing/:id' , loadChildren: () => import('./portal/employee/accounting/invoice-details/invoice-details.module').then( m => m.InvoiceDetailsModule) },
{ path: 'financial-transaction' , loadChildren: () => import('./portal/employee/accounting/financial-transaction/financial-transaction.module').then( m => m.FinancialTransactionModule) },
{ path: 'financial-reports' , component: FinancialReportComponent, canActivate: [CanEmployeeLogged] },
{ path: 'financial-transaction/:id' , loadChildren: () => import('./portal/employee/accounting/payment/payment.module').then( m => m.PaymentModule) },

]

},
//{ path: 'success' , component: SuccessComponent, canActivate: [CanEmployeeLogged] },

{ path: 'portal/profile' , loadChildren: () => import('./portal/employee/profile/profile/em-profile.module').then( m => m.EmProfileModule) },
{ path: 'profile' , loadChildren: () => import('./portal/employee/profile/profile/em-profile.module').then( m => m.EmProfileModule) },

{ path: 'reset-password' , loadChildren: () => import('./portal/employee/reset-password/reset-password.module').then( m => m.ResetPasswordModule) },

{ path: 'portal/video-conference' , loadChildren: () => import('./layouts/video-chat/video-chat.module').then( m => m.VideoChatModule) },
{ path: 'video-conference' , loadChildren: () => import('./layouts/video-chat/video-chat.module').then( m => m.VideoChatModule) },

{ path: 'portal/messenger', loadChildren: () => import('./layouts/message/message.module').then( m => m.MessageModule) },
{ path: 'messenger', loadChildren: () => import('./layouts/message/message.module').then( m => m.MessageModule) },

{ path: 'portal/success' , component: SuccessPaymentComponent, canActivate: [CanEmployeeLogged] },
{ path: 'success' , component: SuccessPaymentComponent, canActivate: [CanEmployeeLogged] },

]


},
{ path: 'reset-password' , loadChildren: () => import('./portal/employee/reset-password/reset-password.module').then( m => m.ResetPasswordModule) },
{ path: '**', component: NotFoundComponent, canActivate: [CanEmployeeLogged] },





];

@NgModule({
Expand Down
12 changes: 10 additions & 2 deletions client/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ import { NgxPaginationModule } from 'ngx-pagination';
import { AdminRouterComponent } from './portal/admin/admin-router.component';
import { ArticleComponent } from './portal/admin/article/article.component';
import { ArticleModule } from './portal/admin/article/article.module';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatOptionModule } from '@angular/material/core';



Expand Down Expand Up @@ -133,8 +137,7 @@ import { ArticleModule } from './portal/admin/article/article.module';
NotFoundComponent,
ExcelComponent,
AdminRouterComponent,




],
imports: [
Expand All @@ -143,6 +146,11 @@ import { ArticleModule } from './portal/admin/article/article.module';
HttpClientModule,
FormsModule,
CommonModule,
MatFormFieldModule,
MatInputModule,
MatAutocompleteModule,
MatOptionModule,

ReactiveFormsModule,
HttpClientModule,
PlotlyViaCDNModule,
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/model/ad-product.model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mongoose from 'mongoose';
import { Category } from './ad-category.model';

export interface Product {
export interface Products {

_id: string;
category_id: Category | string ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, ViewChild, ElementRef, OnInit, OnDestroy,} from '@angular/core';
import { Store, select } from '@ngrx/store';
import * as AdProductActions from '../ad-product/store/ad-product.action';
import { Product } from '../../../../model/ad-product.model';
import { Products } from '../../../../model/ad-product.model';
import { Observable, map, Subject, takeUntil } from 'rxjs';
import { AppState } from '../../../../state/app.state';
import { AdCategoryService } from '../../category/ad-category/ad-category.service';
Expand Down Expand Up @@ -30,15 +30,15 @@ export class AdProductComponent implements OnInit, OnDestroy {
itemsPerPage: number = 5;
totalPages: number = 1;

selectedProduct: Product | null = null;
selectedProduct: Products | null = null;
categories$!: Observable<Category[]>;
product$: Observable<Product[]>;
product$: Observable<Products[]>;

categories: Category[] = [];



productToEdit: Partial<Product> = {};
productToEdit: Partial<Products> = {};


private destroy$ = new Subject<void>();
Expand Down Expand Up @@ -102,7 +102,7 @@ export class AdProductComponent implements OnInit, OnDestroy {



editProducts(product: Partial<Product>) {
editProducts(product: Partial<Products>) {

this.productToEdit = {
...product,
Expand All @@ -115,12 +115,12 @@ export class AdProductComponent implements OnInit, OnDestroy {
this.modal2.nativeElement.showModal();
}

editProduct(product: Partial<Product>) {
editProduct(product: Partial<Products>) {
this.store.dispatch(AdProductActions.updateProduct({ product }));
this.modal2.nativeElement.close();
}

deleteProduct(product: Product): void {
deleteProduct(product: Products): void {
if (product._id) {
this.store.dispatch(AdProductActions.deleteProduct({ productId: product._id }));
console.log(`Deleted product with ID: ${product._id}`);
Expand All @@ -129,7 +129,7 @@ export class AdProductComponent implements OnInit, OnDestroy {
}
}

confirmDelete(product: Product): void {
confirmDelete(product: Products): void {
if (confirm('Are you sure you want to delete this product?')) {
this.deleteProduct(product);
}
Expand All @@ -139,7 +139,7 @@ export class AdProductComponent implements OnInit, OnDestroy {
this.modal.nativeElement.showModal();
}

get filteredRecords(): Observable<Product[]> {
get filteredRecords(): Observable<Products[]> {
const searchTermLower = this.searchTerm.toLowerCase();
return this.product$.pipe(
map(records => records.filter(record =>
Expand All @@ -163,7 +163,7 @@ export class AdProductComponent implements OnInit, OnDestroy {
return category._id
}

trackByProduct(index: number, product: Product): string {
trackByProduct(index: number, product: Products): string {
return product._id;
}

Expand All @@ -173,7 +173,7 @@ export class AdProductComponent implements OnInit, OnDestroy {
});
}

getCurrentPageRecords(): Observable<Product[]> {
getCurrentPageRecords(): Observable<Products[]> {
return this.filteredRecords.pipe(
map(records => {
const startIndex = (this.currentPage - 1) * this.itemsPerPage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Product } from '../../../../model/ad-product.model';
import { Products } from '../../../../model/ad-product.model';
import { environment } from '../../../../../environment/environment';

@Injectable({
Expand All @@ -13,21 +13,23 @@ export class AdProductService {

constructor(private http: HttpClient) { }

getProducts(): Observable<Product[]> {
getProducts(): Observable<Products[]> {
const headers = { 'Cache-Control': 'no-cache' };
return this.http.get<Product[]>(`${this.apiUrl}/product`, { headers });
return this.http.get<Products[]>(`${this.apiUrl}/product`, { headers });
}

addProduct(product: Product): Observable<any> {
addProduct(product: Products): Observable<any> {
return this.http.post<any>(`${this.apiUrl}/product/add`, product);
}

updateProduct(product: Partial<Product>): Observable<any> {
updateProduct(product: Partial<Products>): Observable<any> {
return this.http.put<any>(`${this.apiUrl}/product/update/${product._id}`, product);
}

deleteProduct(id: string): Observable<any> {
return this.http.delete<any>(`${this.apiUrl}/product/delete/${id}`);
}



}
Loading

0 comments on commit 92953b8

Please sign in to comment.