refactor: Simplify validation logic and adjust campaign steps service parameters

This commit is contained in:
MehrdadAdabi 2025-11-26 18:45:57 +03:30
parent bbb6bfb7f7
commit 70959e878f
5 changed files with 11 additions and 23 deletions

View File

@ -6,6 +6,7 @@
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"buildOnly": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},

View File

@ -75,10 +75,10 @@ const DynamicForm: FC<DynamicFormProps> = ({ fields, processId, stepId }) => {
field.Type === FieldTypes.پول) &&
typeof value === "number"
) {
if (field && field.MinValue !== undefined && value < field?.MinValue) {
if (field && field.MinValue !== undefined) {
return `مقدار باید بزرگتر یا مساوی ${field.MinValue} باشد.`;
}
if (field && field.MaxValue !== undefined && value > field?.MaxValue) {
if (field && field.MaxValue !== undefined) {
return `مقدار باید کوچکتر یا مساوی ${field.MaxValue} باشد.`;
}
}

View File

@ -27,7 +27,7 @@ const StepFormPage: FC = () => {
useEffect(() => {
if (data && data.Fields) {
const processedFields: LocalFieldDefinition[] = data.Fields.map((el) => {
const field: LocalFieldDefinition = {
const field: any = {
ID: el.ID,
Name: el.Name,
LatinName: el.LatinName,

View File

@ -10,10 +10,9 @@ const StepsPage: FC = () => {
const { campaignId } = useParams<{ campaignId: string }>();
const navigate = useNavigate();
const [steps, setSteps] = useState<GroupedCampaign[]>([]);
const [selectedStepId, setSelectedStepId] = useState<number | null>(null);
const { data, isLoading, error } = useQuery<Record<string, any>>({
queryKey: ["dynamic-step"],
queryFn: () => getCampaignStepsService(campaignId!),
queryFn: () => getCampaignStepsService(),
});
useEffect(() => {
@ -165,11 +164,7 @@ const StepsPage: FC = () => {
focus-within:ring-2 focus-within:ring-blue-500 focus-within:ring-opacity-50
transition-all duration-300 ease-in-out transform
${
selectedStepId === step.stageID
? "bg-blue-50 border-blue-500 ring-2 ring-blue-500 ring-opacity-75 scale-105"
: "hover:scale-102"
}
`}
onClick={() => handleStepClick(step)}
tabIndex={0} // Make list item focusable
@ -180,11 +175,7 @@ const StepsPage: FC = () => {
w-10 h-10 sm:w-12 sm:h-12 rounded-full
font-bold text-lg sm:text-xl
mr-4 sm:mr-6 shrink-0
${
selectedStepId === step.stageID
? "bg-blue-600 text-white"
: "bg-gray-200 text-gray-700"
}
transition-all duration-300 ease-in-out
`}
>
@ -194,11 +185,7 @@ const StepsPage: FC = () => {
<h2
className={`
text-lg sm:text-xl font-semibold
${
selectedStepId === step.stageID
? "text-blue-800"
: "text-gray-800"
}
transition-colors duration-300 ease-in-out
`}
>

View File

@ -324,9 +324,9 @@ export const createCircleService = async (
return res.data;
};
export const getCampaignStepsService = async (
campaignId: string
): Promise<Record<string, any>> => {
export const getCampaignStepsService = async (): Promise<
Record<string, any>
> => {
const query = {
ProcessName: "run_process",
OutputFields: ["*"],