28 lines
803 B
TypeScript
28 lines
803 B
TypeScript
import type * as CRMTypes from '@/graphql/crm.types';
|
|
|
|
type SystemUser = NonNullable<CRMTypes.GetSystemUserQuery['systemusers']>[number];
|
|
|
|
function evo_baseproducts(baseproducts: CRMTypes.GetProductsQuery['evo_baseproducts']) {
|
|
return {
|
|
filterBy: {
|
|
systemuser(systemuser: SystemUser) {
|
|
if (!baseproducts?.length || !systemuser) return [];
|
|
|
|
return baseproducts?.filter(
|
|
(evo_baseproduct) =>
|
|
!evo_baseproduct?.systemusers?.length ||
|
|
evo_baseproduct?.systemusers?.some(
|
|
(evo_baseproduct_systemuser) =>
|
|
systemuser?.systemuserid &&
|
|
evo_baseproduct_systemuser?.systemuserid === systemuser?.systemuserid
|
|
)
|
|
);
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
export const crmTools = {
|
|
evo_baseproducts,
|
|
};
|