1
0
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:
Thomas Heartman 2025-07-18 13:23:18 +02:00
parent 4c358c88df
commit c394800a19
No known key found for this signature in database
GPG Key ID: BD1F880DAED1EE78
6 changed files with 10 additions and 16 deletions

View File

@ -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>>;

View File

@ -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,

View File

@ -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;

View File

@ -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({});

View File

@ -68,10 +68,6 @@ export interface IConstraint {
[constraintId]?: string;
}
export interface IConstraintWithId extends IConstraint {
[constraintId]: string;
}
export interface IFeatureStrategySortOrder {
id: string;
sortOrder: number;

View File

@ -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() : '';