diff --git a/src/admin/components/elements/WhereBuilder/Condition/Relationship/index.scss b/src/admin/components/elements/WhereBuilder/Condition/Relationship/index.scss new file mode 100644 index 0000000000..a8e4cbf5f7 --- /dev/null +++ b/src/admin/components/elements/WhereBuilder/Condition/Relationship/index.scss @@ -0,0 +1,5 @@ +@import '../../../../../scss/styles.scss'; + +.condition-value-relationship { + @include formInput; +} diff --git a/src/admin/components/elements/WhereBuilder/Condition/Relationship/index.tsx b/src/admin/components/elements/WhereBuilder/Condition/Relationship/index.tsx new file mode 100644 index 0000000000..c4a6e3b50b --- /dev/null +++ b/src/admin/components/elements/WhereBuilder/Condition/Relationship/index.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { Props } from './types'; + +import './index.scss'; + +const baseClass = 'condition-value-relationship'; + +const RelationshipField: React.FC = (props) => { + const { onChange, value } = props; + console.log(props); + return ( + onChange(e.target.value)} + value={value} + /> + ); +}; + +export default RelationshipField; diff --git a/src/admin/components/elements/WhereBuilder/Condition/Relationship/types.ts b/src/admin/components/elements/WhereBuilder/Condition/Relationship/types.ts new file mode 100644 index 0000000000..b2abc4c5cd --- /dev/null +++ b/src/admin/components/elements/WhereBuilder/Condition/Relationship/types.ts @@ -0,0 +1,4 @@ +export type Props = { + onChange: (val: string) => void, + value: string, +} diff --git a/src/admin/components/elements/WhereBuilder/Condition/index.tsx b/src/admin/components/elements/WhereBuilder/Condition/index.tsx index 4cb96043b5..8763f979ca 100644 --- a/src/admin/components/elements/WhereBuilder/Condition/index.tsx +++ b/src/admin/components/elements/WhereBuilder/Condition/index.tsx @@ -6,6 +6,7 @@ import Button from '../../Button'; import Date from './Date'; import Number from './Number'; import Text from './Text'; +import Relationship from './Relationship'; import useDebounce from '../../../../hooks/useDebounce'; import { FieldCondition } from '../types'; @@ -15,6 +16,7 @@ const valueFields = { Date, Number, Text, + Relationship, }; const baseClass = 'condition'; @@ -93,6 +95,7 @@ const Condition: React.FC = (props) => { DefaultComponent={ValueComponent} componentProps={{ ...activeField?.props, + operator: operatorValue, value: internalValue, onChange: setInternalValue, }} diff --git a/src/admin/components/elements/WhereBuilder/field-types.tsx b/src/admin/components/elements/WhereBuilder/field-types.tsx index 6839f7829e..92c6b6c52f 100644 --- a/src/admin/components/elements/WhereBuilder/field-types.tsx +++ b/src/admin/components/elements/WhereBuilder/field-types.tsx @@ -100,7 +100,7 @@ const fieldTypeConditions = { operators: [...base], }, relationship: { - component: 'Text', + component: 'Relationship', operators: [...base], }, select: {