1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-22 11:18:20 +02:00
unleash.unleash/frontend/src/hooks/useReleasePlanPreview.ts
Gastón Fournier abe160eb7d
feat: Unleash v7 ESM migration (#9877)
We're migrating to ESM, which will allow us to import the latest
versions of our dependencies.

Co-Authored-By: Christopher Kolstad <chriswk@getunleash.io>
2025-05-14 09:47:12 +02:00

34 lines
1.1 KiB
TypeScript

import type { IReleasePlan } from 'interfaces/releasePlans';
import { useReleasePlanTemplate } from './api/getters/useReleasePlanTemplates/useReleasePlanTemplate.js';
export const useReleasePlanPreview = (
templateId: string,
featureName: string,
environment: string,
): IReleasePlan => {
const { template } = useReleasePlanTemplate(templateId);
return {
...template,
featureName,
environment,
milestones: template.milestones.map((milestone) => ({
...milestone,
releasePlanDefinitionId: template.id,
strategies: (milestone.strategies || []).map((strategy) => ({
...strategy,
parameters: {
...strategy.parameters,
...(strategy.parameters.groupId && {
groupId: String(strategy.parameters.groupId).replaceAll(
'{{featureName}}',
featureName,
),
}),
},
milestoneId: milestone.id,
})),
})),
};
};