commit changes

This commit is contained in:
João Mendes 2023-11-06 10:48:00 +00:00
parent 3c3f9ac6e8
commit e579f1b3a9
3 changed files with 79 additions and 75 deletions

View File

@ -1,5 +1,6 @@
import * as React from 'react';
import { BACKGROUND } from '../../constants/constants';
import { useLeftStyles } from './useLeftStyles';
export interface ILeftProps {}
@ -9,10 +10,7 @@ export const Left: React.FunctionComponent<ILeftProps> = (props: React.PropsWith
const styles = useLeftStyles();
return (
<>
<div
className={styles.leftContainer}
style={{ background: "linear-gradient(122.54deg, rgba(19, 29, 255, 0.2) 0%, rgba(97, 217, 149, 0.2) 100%)" }}
>
<div className={styles.leftContainer} style={{ background: BACKGROUND }}>
{children}
</div>
</>

View File

@ -0,0 +1 @@
export const BACKGROUND = "linear-gradient(122.54deg, rgba(19, 29, 255, 0.2) 0%, rgba(97, 217, 149, 0.2) 100%)";

View File

@ -23,85 +23,90 @@ export const useGraphAPI = (context: BaseComponentContext): IuseGraphAPI => {
return await context.msGraphClientFactory.getClient("3");
}, [context]);
const mappingOrders = React.useCallback(
(result: SearchHit[]): IOrder[] => {
const ordersList: IOrder[] = [];
for (const item of result) {
const { resource } = item;
if (resource) {
const { properties } = resource as any;
if (properties) {
const {
id,
custcode,
custname,
email,
state,
country,
orders,
orderdates,
ordertotals,
orderstatus,
} = properties as any;
const mappingOrders = React.useCallback((result: SearchHit[]): IOrder[] => {
const ordersList: IOrder[] = [];
for (const item of result) {
const { resource } = item;
if (resource) {
const { properties } = resource as any;
if (properties) {
const {
id,
custcode,
custname,
email,
state,
country,
orders,
orderdates,
ordertotals,
orderstatus,
} = properties as any;
for (let i = 0; i < orders.length; i++) {
const order: IOrder = {
customer: custname,
city: `${state} ${country}`,
order: orders[i],
total: ordertotals[i],
orderDate: orderdates[i],
status: orderstatus[i],
customerCode: custcode,
custmoerEmail: email,
customerState: state,
id: id,
};
ordersList.push(order);
for (let i = 0; i < orders.length; i++) {
const order: IOrder = {
customer: custname,
city: `${state} ${country}`,
order: orders[i],
total: ordertotals[i],
orderDate: orderdates[i],
status: orderstatus[i],
customerCode: custcode,
custmoerEmail: email,
customerState: state,
id: id,
};
ordersList.push(order);
}
}
}
}
}
return ordersList;
}, [ graphClient]);
return ordersList;
},
[graphClient]
);
const mappingCustomers = React.useCallback((result: SearchHit[]): ICustomer[] => {
const customersList: ICustomer[] = [];
for (const item of result) {
const { resource } = item;
if (resource) {
const { properties } = resource as any;
if (properties) {
const {
custcode,
custname,
email,
state,
country,
orders,
orderdates,
ordertotals,
orderstatus,
} = properties as any;
const mappingCustomers = React.useCallback(
(result: SearchHit[]): ICustomer[] => {
const customersList: ICustomer[] = [];
for (const item of result) {
const { resource } = item;
if (resource) {
const { properties } = resource as any;
if (properties) {
const {
custcode,
custname,
email,
state,
country,
orders,
orderdates,
ordertotals,
orderstatus,
} = properties as any;
const customer: ICustomer = {
customerName: custname,
customerCode: custcode,
customerEmail: email,
customerState: state,
customerCountry: country,
lastOrder: orders[orders.length - 1],
totalOrders: orders.length,
lastOrderDate: orderdates[orderdates.length - 1],
lastOrderTotal: ordertotals[ordertotals.length - 1],
lastOrderStatus: orderstatus[orderstatus.length - 1],
};
customersList.push(customer);
const customer: ICustomer = {
customerName: custname,
customerCode: custcode,
customerEmail: email,
customerState: state,
customerCountry: country,
lastOrder: orders[orders.length - 1],
totalOrders: orders.length,
lastOrderDate: orderdates[orderdates.length - 1],
lastOrderTotal: ordertotals[ordertotals.length - 1],
lastOrderStatus: orderstatus[orderstatus.length - 1],
};
customersList.push(customer);
}
}
}
}
return customersList;
}, [ graphClient]);
return customersList;
},
[graphClient]
);
const searchOrders = React.useCallback(
async (searchText: string): Promise<any> => {