Add inPlaylist and notInPlaylist operators

This commit is contained in:
jeffvli 2024-05-02 21:35:23 -07:00 committed by Jeff
parent 7bfdbb5d92
commit 785f0ef77f
4 changed files with 46 additions and 10 deletions

View file

@ -28,9 +28,10 @@ interface QueryOptionProps {
number: { label: string; value: string }[];
string: { label: string; value: string }[];
};
selectData?: { label: string; value: string }[];
}
const QueryValueInput = ({ onChange, type, ...props }: any) => {
const QueryValueInput = ({ onChange, type, data, ...props }: any) => {
const [numberRange, setNumberRange] = useState([0, 0]);
switch (type) {
@ -59,7 +60,6 @@ const QueryValueInput = ({ onChange, type, ...props }: any) => {
{...props}
/>
);
case 'dateRange':
return (
<>
@ -87,7 +87,6 @@ const QueryValueInput = ({ onChange, type, ...props }: any) => {
/>
</>
);
case 'boolean':
return (
<Select
@ -99,6 +98,14 @@ const QueryValueInput = ({ onChange, type, ...props }: any) => {
{...props}
/>
);
case 'playlist':
return (
<Select
data={data}
onChange={onChange}
{...props}
/>
);
default:
return <></>;
@ -116,6 +123,7 @@ export const QueryBuilderOption = ({
onChangeField,
onChangeOperator,
onChangeValue,
selectData,
}: QueryOptionProps) => {
const { field, operator, uniqueId, value } = data;
@ -133,10 +141,7 @@ export const QueryBuilderOption = ({
const handleChangeValue = (e: any) => {
const isDirectValue =
typeof e === 'string' ||
typeof e === 'number' ||
typeof e === 'undefined' ||
typeof e === null;
typeof e === 'string' || typeof e === 'number' || typeof e === 'undefined';
if (isDirectValue) {
return onChangeValue({
@ -207,6 +212,7 @@ export const QueryBuilderOption = ({
/>
{field ? (
<QueryValueInput
data={selectData || []}
defaultValue={value}
maxWidth={170}
size="sm"