Skip to content

Commit

Permalink
`Added functionality to retrieve supplier page settings and updated f…
Browse files Browse the repository at this point in the history
…orms to use select options for supplier page names.`
  • Loading branch information
vivek7315 committed Jan 1, 2025
1 parent 106065f commit b01cfcb
Show file tree
Hide file tree
Showing 25 changed files with 284 additions and 26 deletions.
25 changes: 25 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 @@ -31,6 +31,7 @@
"bootstrap-icons": "^1.11.3",
"firebaseui": "^6.1.0",
"jwt-decode": "^4.0.0",
"ngrx-store-localstorage": "^17.0.0",
"ngx-toastr": "^17.0.2",
"process": "^0.11.10",
"rxjs": "~7.8.0",
Expand Down
1 change: 1 addition & 0 deletions src/app/ClientSide/client-side.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { MatInputModule } from '@angular/material/input';
UserCheckoutComponent
],
imports: [

CommonModule,
ClientSideRoutingModule,
ReactiveFormsModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<router-outlet></router-outlet>
}
@placeholder{
<div>Loading....</div>

<div>Loading....</div>
}
@loading(minimum 1s){
<app-loder></app-loder>
Expand Down
20 changes: 17 additions & 3 deletions src/app/ClientSide/user-home/user-home.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Component, OnInit } from '@angular/core';

import { AdminSupplierServiceService } from '../../admin-side/Admin-Service/admin-supplier-service.service';
import { AdminServiceService } from '../../admin-side/Admin-Service/admin-service.service';
import { Store } from '@ngrx/store';
import {AddSupplierPageSettings,UpdateSupplierPageSettings} from '../../State/action/Pagesetting.action'
import { customerPageNames} from '../../Shared/Enums/CustomerPageNames.Enum'
@Component({
selector: 'app-user-home',
templateUrl: './user-home.component.html',
Expand All @@ -10,8 +14,18 @@ export class UserHomeComponent implements OnInit {
TreandingTitle="Trending Products"
Filter : string | undefined;
FilterData:any[]=[];
constructor(){}
allSuppplierPageData:any[]=[];
pageConfigresult:any;
allCustomerPagedata:any[]=[];
constructor(private AdminSupplierservie:AdminSupplierServiceService,private Adminservice:AdminServiceService,private store:Store){}
ngOnInit(): void {

this.AdminSupplierservie.getAllsupplierPage().subscribe((res:any) =>{
this.allSuppplierPageData.push(res.data);
console.log(this.allSuppplierPageData);
})
this.Adminservice.getAllCustomerPageSetting().subscribe((res:any) =>{
this.allCustomerPagedata.push(res.data);
this.store.dispatch(AddSupplierPageSettings({pageName: customerPageNames.Home,editConfig: false,deleteConfig:false}));
})
}
}
6 changes: 2 additions & 4 deletions src/app/Shared/Enums/SupplierPageNames.Enums.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
export enum SupplierPageNames {

Deshboards = "Deshboards",
Product_Details = "Product-Details",
Inventory_Details = "Product-Details",
Inventory_Details = "Inventory-Details",
Add_Product = "Add-Product",
Add_Inventory = "Add-Inventory",

Add_Inventory = "Add-Inventory",
}
29 changes: 29 additions & 0 deletions src/app/Shared/helpers/SupplierPageSetting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { SupplierPageNames } from "../Enums/SupplierPageNames.Enums";

export const SupplierInitialPageSetting = [
{
pageName: SupplierPageNames.Add_Inventory,
editConfig : true,
deleteConfig : true
},
{
pageName: SupplierPageNames.Add_Product,
editConfig : true,
deleteConfig : true
},
{
pageName: SupplierPageNames.Deshboards,
editConfig : true,
deleteConfig : true
},
{
pageName: SupplierPageNames.Inventory_Details,
editConfig : true,
deleteConfig : true
},
{
pageName: SupplierPageNames.Product_Details,
editConfig : true,
deleteConfig : true
}
]
34 changes: 34 additions & 0 deletions src/app/Shared/helpers/customerPagesetting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { customerPageNames } from "../Enums/CustomerPageNames.Enum";

export const CustomerPageSetting = [
{
pageName: customerPageNames.AboutUs,
editConfig : true,
deleteConfig : true
},
{
pageName: customerPageNames.AddToCart,
editConfig : true,
deleteConfig : true
},
{
pageName: customerPageNames.WhisList,
editConfig : true,
deleteConfig : true
},
{
pageName: customerPageNames.ContactUs,
editConfig : true,
deleteConfig : true
},
{
pageName: customerPageNames.Profile,
editConfig : true,
deleteConfig : true
},
{
pageName: customerPageNames.Profile,
editConfig : true,
deleteConfig : true
}
]
16 changes: 16 additions & 0 deletions src/app/State/Metareducer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ActionReducer, MetaReducer } from "@ngrx/store";
import { localStorageSync } from "ngrx-store-localstorage";

// Ensure localStorage is only accessed in a browser environment
export function localStorageSyncReducer(reducer: ActionReducer<any>): ActionReducer<any> {
return (state, action) => {
if (typeof window !== 'undefined' && window.localStorage) {
return localStorageSync({
keys: ['SupplierPageConfig','CustomerPageConfig'],
rehydrate: true,
})(reducer)(state, action);
}
return reducer(state, action);
};
}
export const metaReducers: Array<MetaReducer<any, any>> = [localStorageSyncReducer];
34 changes: 34 additions & 0 deletions src/app/State/Reducer/CustomerPageSetting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { createReducer, on, State } from "@ngrx/store";
import { CustomerPageSetting } from "../../Shared/helpers/customerPagesetting";
import { AddCustomerPageSettings } from "../action/CustomerPageSetting.action";


export interface pageSetting {
pageName: string;
editConfig: boolean,
deleteConfig: boolean
}


export interface AppState {
pageSetting: any[];
}



export const initialState: AppState = {
pageSetting: CustomerPageSetting
};

export const CustomerPageconfigrationSetting = createReducer(
initialState,
on(AddCustomerPageSettings , (state, action) =>{
const AddCustomerPageSettings = {pageName: action.pageName, editConfig: action.editConfig, deleteConfig: action.deleteConfig};
return {
...state,
}
})
)
export function pageConfigSettingReducerF(state: any, action: any) {
return CustomerPageconfigrationSetting(state, action);
}
34 changes: 34 additions & 0 deletions src/app/State/Reducer/PageSetting.Reducer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { createReducer, on, State } from "@ngrx/store";
import { SupplierInitialPageSetting} from "../../Shared/helpers/SupplierPageSetting";
import { AddSupplierPageSettings } from "../action/Pagesetting.action";


export interface pageSetting {
pageName: string;
editConfig: boolean,
deleteConfig: boolean
}


export interface AppState {
pageSetting: any[];
}



export const initialState: AppState = {
pageSetting: SupplierInitialPageSetting
};

export const configrationSetting = createReducer(
initialState,
on(AddSupplierPageSettings , (state, action) =>{
const AddCustomerPageConfigration = {pageName: action.pageName, editConfig: action.editConfig, deleteConfig: action.deleteConfig};
return {
...state,
}
})
)
export function pageConfigSettingReducerF(state: any, action: any) {
return configrationSetting(state, action);
}
5 changes: 5 additions & 0 deletions src/app/State/action/CustomerPageSetting.action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createAction, props } from "@ngrx/store";

export const AddCustomerPageSettings = createAction('AddCustomerPageSettings', props<{ pageName: string, editConfig: boolean, deleteConfig: boolean }>());
export const UpdateCustomerPageSettings = createAction('UpdateCustomerPageSettings', props<{ pageName: string, editConfig: boolean, deleteConfig: boolean }>());
export const DeleteCustomerPageSettings = createAction('DeleteCustomerPageSettings', props<{ pageName: string, editConfig: boolean, deleteConfig: boolean }>());
5 changes: 5 additions & 0 deletions src/app/State/action/Pagesetting.action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createAction, props } from "@ngrx/store";

export const AddSupplierPageSettings = createAction('AddSupplierPageSettings', props<{ pageName: string, editConfig: boolean, deleteConfig: boolean }>());
export const UpdateSupplierPageSettings = createAction('UpdateSupplierPageSettings', props<{ pageName: string, editConfig: boolean, deleteConfig: boolean }>());
export const DeleteSupplierPageSettings = createAction('DeleteSupplierPageSettings', props<{ pageName: string, editConfig: boolean, deleteConfig: boolean }>());
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LiveAnnouncer } from '@angular/cdk/a11y';
import { ToastrService } from 'ngx-toastr';
import { DeleteConfirmationDialogComponent } from '../../Shared/delete-confirmation-dialog/delete-confirmation-dialog.component';
import { AdminSupplierServiceService } from '../../admin-side/Admin-Service/admin-supplier-service.service';

import { SupplierPageNames } from '../../Shared/Enums/SupplierPageNames.Enums';
@Component({
selector: 'app-inventory-details',
templateUrl: './inventory-details.component.html',
Expand All @@ -32,13 +32,18 @@ export class InventoryDetailsComponent {

ngOnInit(): void {
this.displayInventoryData();
this.getPageSettingValue();
}

displayedColumns: string[] = ['Product Image','Product Name','quantity','warehouse Name','location','Action'];

pagename:any;

getPageSettingValue(){
// this.pageSettings = this.adminSupplierPageService.
this.pagename = SupplierPageNames.Inventory_Details;
this.adminSupplierPageService.getAllsupplierPage(this.pagename).subscribe((res:any) => {
this.pageSettings = res.data;
console.log("pages",this.pageSettings)
})
}
announceSortChange(sortState: Sort) {
if (sortState.direction) {
Expand Down
5 changes: 5 additions & 0 deletions src/app/action/Pagesetting.action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createAction, props } from "@ngrx/store";

export const AddCustomerPageConfigration = createAction('AddCustomerPageConfigration', props<{ Pagename:string, editConfig:boolean ,deleteConfig:boolean}>());
export const editCustomerPageConfigration = createAction('EditCustomerPageConfigration', props<{ Pagename:string,editConfig:boolean ,deleteConfig:boolean}>());
export const DeleteCustomerPageConfigration = createAction('DeleteCustomerPageConfigration', props<{ Pagename:string,editConfig:boolean ,deleteConfig:boolean}>());
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ export class AdminSupplierServiceService {
return this.httpclient.post<supplierPageSetting>(`${this.supplierSettingUrl}/SupplierPageAdd`, supplierPageSetting);
}

getAllsupplierPage(): Observable<supplierPageSetting[]> {
return this.httpclient.get<supplierPageSetting[]>(`${this.supplierSettingUrl}/GetAllSupplierPage`);
getAllsupplierPage(search?:string): Observable<supplierPageSetting[]> {
return this.httpclient.get<supplierPageSetting[]>(`${this.supplierSettingUrl}/GetAllSupplierPage?SerchString=${search}`);
}
getsupplierPagebyId(id:number) :Observable<supplierPageSetting>
{
return this.httpclient.get<supplierPageSetting>(`${this.supplierSettingUrl}/GetCustomerPageById/${id}`);
return this.httpclient.get<supplierPageSetting>(`${this.supplierSettingUrl}/GetSupplierPageById/${id}`);
}
deletesupplierPage(id:number) :Observable<supplierPageSetting>{
return this.httpclient.delete<supplierPageSetting>(`${this.supplierSettingUrl}/DeleteCustomerPage/${id}`);
return this.httpclient.delete<supplierPageSetting>(`${this.supplierSettingUrl}/DeleteSupplierPage/${id}`);
}
updatesupplierPage(customerPageSetting:supplierPageSetting) :Observable<supplierPageSetting>{
return this.httpclient.put<supplierPageSetting>(`${this.supplierSettingUrl}/UpdateCustomerPage`, customerPageSetting);
updatesupplierPage(supplierPageSetting:supplierPageSetting) :Observable<supplierPageSetting>{
return this.httpclient.put<supplierPageSetting>(`${this.supplierSettingUrl}/UpdateSupplierPage`, supplierPageSetting);
}
// SearchSupllerPage(search:string) :Observable<supplierPageSetting>{
// return this.httpclient.get<supplierPageSetting>(`${this.supplierSettingUrl}/SearchSupplierPage?search=${search}`);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@

<div class="contact">
<form [formGroup]="AddsupplierPageForm">
<h1 class="Dialog-Title">Add Supplier Page</h1><h1 style="display: flex; justify-content: end;"><i class="bi bi-x" (click)="CloseAddSupplierPageDailog()"></i></h1>

<input type="text" formControlName="PageName" placeholder="Product Name">
<select formControlName="PageName">
<option value="" disabled selected>Select Product</option>
<option *ngFor="let supplierPage of SupplierPagesData" [value]="supplierPage">
{{ supplierPage }}
</option>
</select>

<p>IsLoderActive
<mat-button-toggle-group formControlName="IsLoderActive" name="fontStyle" aria-label="Font Style">
<mat-button-toggle class="left-toggle" value="On">On</mat-button-toggle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { ToastrService } from 'ngx-toastr';
import { AdminSupplierServiceService } from '../Admin-Service/admin-supplier-service.service';

import { SupplierPageNames } from '../../Shared/Enums/SupplierPageNames.Enums';
@Component({
selector: 'app-add-supplier-pages',
templateUrl: './add-supplier-pages.component.html',
styleUrl: './add-supplier-pages.component.css'
})
export class AddSupplierPagesComponent implements OnInit {
supplierData:any
SupplierPagesData:any[]=[];


AddsupplierPageForm!: FormGroup;
constructor(
private adminService:AdminSupplierServiceService,
Expand All @@ -27,6 +29,8 @@ supplierData:any
IsTosterActive: [],
IsDeleteDialogActive: [],
});
this.SupplierPagesData=Object.keys(SupplierPageNames);
console.log(this.SupplierPagesData);
}

async AddSupplierPage() {
Expand Down
Loading

0 comments on commit b01cfcb

Please sign in to comment.