mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-27 13:49:10 +02:00
Remove IConstraintWithId type.
The next move is to make id required on IConstraint.
This commit is contained in:
parent
4c358c88df
commit
c394800a19
@ -1,4 +1,4 @@
|
||||
import type { IConstraint, IConstraintWithId } from 'interfaces/strategy';
|
||||
import type { IConstraint } from 'interfaces/strategy';
|
||||
import { SegmentFormStepOne } from './SegmentFormStepOne.tsx';
|
||||
import { SegmentFormStepTwo } from './SegmentFormStepTwo.tsx';
|
||||
import type React from 'react';
|
||||
@ -14,7 +14,7 @@ interface ISegmentProps {
|
||||
name: string;
|
||||
description: string;
|
||||
project?: string;
|
||||
constraints: IConstraintWithId[];
|
||||
constraints: IConstraint[];
|
||||
setName: React.Dispatch<React.SetStateAction<string>>;
|
||||
setDescription: React.Dispatch<React.SetStateAction<string>>;
|
||||
setProject: React.Dispatch<React.SetStateAction<string | undefined>>;
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
CREATE_SEGMENT,
|
||||
UPDATE_PROJECT_SEGMENT,
|
||||
} from 'component/providers/AccessProvider/permissions';
|
||||
import type { IConstraintWithId } from 'interfaces/strategy.ts';
|
||||
import type { IConstraint } from 'interfaces/strategy.ts';
|
||||
|
||||
const server = testServerSetup();
|
||||
|
||||
@ -26,7 +26,7 @@ const setupRoutes = () => {
|
||||
|
||||
const defaultProps = {
|
||||
project: undefined,
|
||||
constraints: [] as IConstraintWithId[],
|
||||
constraints: [] as IConstraint[],
|
||||
setConstraints: vi.fn(),
|
||||
setCurrentStep: vi.fn(),
|
||||
mode: 'create' as const,
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
UPDATE_SEGMENT,
|
||||
} from 'component/providers/AccessProvider/permissions';
|
||||
import useUnleashContext from 'hooks/api/getters/useUnleashContext/useUnleashContext';
|
||||
import type { IConstraint, IConstraintWithId } from 'interfaces/strategy';
|
||||
import type { IConstraint } from 'interfaces/strategy';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { EditableConstraintsList } from 'component/common/NewConstraintAccordion/ConstraintsList/EditableConstraintsList';
|
||||
import type { IEditableConstraintsListRef } from 'component/common/NewConstraintAccordion/ConstraintsList/EditableConstraintsList';
|
||||
@ -33,7 +33,7 @@ import { GO_BACK } from 'constants/navigate';
|
||||
|
||||
interface ISegmentFormPartTwoProps {
|
||||
project?: string;
|
||||
constraints: IConstraintWithId[];
|
||||
constraints: IConstraint[];
|
||||
setConstraints: React.Dispatch<React.SetStateAction<IConstraint[]>>;
|
||||
setCurrentStep: React.Dispatch<React.SetStateAction<SegmentFormStep>>;
|
||||
mode: SegmentFormMode;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { IConstraint, IConstraintWithId } from 'interfaces/strategy';
|
||||
import type { IConstraint } from 'interfaces/strategy';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSegmentValidation } from 'hooks/api/getters/useSegmentValidation/useSegmentValidation';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
@ -17,7 +17,7 @@ export const useSegmentForm = (
|
||||
[constraintId]: uuidv4(),
|
||||
...constraint,
|
||||
}));
|
||||
const [constraints, setConstraints] = useState<IConstraintWithId[]>(
|
||||
const [constraints, setConstraints] = useState<IConstraint[]>(
|
||||
initialConstraintsWithId,
|
||||
);
|
||||
const [errors, setErrors] = useState({});
|
||||
|
@ -68,10 +68,6 @@ export interface IConstraint {
|
||||
[constraintId]?: string;
|
||||
}
|
||||
|
||||
export interface IConstraintWithId extends IConstraint {
|
||||
[constraintId]: string;
|
||||
}
|
||||
|
||||
export interface IFeatureStrategySortOrder {
|
||||
id: string;
|
||||
sortOrder: number;
|
||||
|
@ -1,12 +1,10 @@
|
||||
import { constraintId } from 'constants/constraintId';
|
||||
import { isDateOperator } from 'constants/operators';
|
||||
import type { IConstraintWithId } from 'interfaces/strategy';
|
||||
import type { IConstraint } from 'interfaces/strategy';
|
||||
import { operatorsForContext } from 'utils/operatorsForContext';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
export const createEmptyConstraint = (
|
||||
contextName: string,
|
||||
): IConstraintWithId => {
|
||||
export const createEmptyConstraint = (contextName: string): IConstraint => {
|
||||
const operator = operatorsForContext(contextName)[0];
|
||||
|
||||
const value = isDateOperator(operator) ? new Date().toISOString() : '';
|
||||
|
Loading…
Reference in New Issue
Block a user