mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-18 13:48:58 +02:00
fix: ReportTable not updating status dynamically (#4923)
Fixes a bug with the UI where featureType comparison was using name instead of id --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
parent
d5b4933df1
commit
d13aec75f1
@ -11,7 +11,7 @@ export const formatExpiredAt = (
|
|||||||
const { type, createdAt } = feature;
|
const { type, createdAt } = feature;
|
||||||
|
|
||||||
const featureType = featureTypes.find(
|
const featureType = featureTypes.find(
|
||||||
featureType => featureType.name === type
|
featureType => featureType.id === type
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -13,12 +13,11 @@ export const formatStatus = (
|
|||||||
const { type, createdAt } = feature;
|
const { type, createdAt } = feature;
|
||||||
|
|
||||||
const featureType = featureTypes.find(
|
const featureType = featureTypes.find(
|
||||||
featureType => featureType.name === type
|
featureType => featureType.id === type
|
||||||
);
|
);
|
||||||
const date = parseISO(createdAt);
|
const date = parseISO(createdAt);
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const diff = getDiffInDays(date, now);
|
const diff = getDiffInDays(date, now);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
featureType &&
|
featureType &&
|
||||||
expired(diff, featureType) &&
|
expired(diff, featureType) &&
|
||||||
|
@ -59,21 +59,19 @@ export const ReportTable = ({ projectId, features }: IReportTableProps) => {
|
|||||||
);
|
);
|
||||||
const { featureTypes } = useFeatureTypes();
|
const { featureTypes } = useFeatureTypes();
|
||||||
|
|
||||||
const data: IReportTableRow[] = useMemo<IReportTableRow[]>(
|
const data: IReportTableRow[] = useMemo<IReportTableRow[]>(() => {
|
||||||
() =>
|
return features.map(report => ({
|
||||||
features.map(report => ({
|
project: projectId,
|
||||||
project: projectId,
|
name: report.name,
|
||||||
name: report.name,
|
type: report.type,
|
||||||
type: report.type,
|
stale: report.stale,
|
||||||
stale: report.stale,
|
environments: report.environments,
|
||||||
environments: report.environments,
|
status: formatStatus(report, featureTypes),
|
||||||
status: formatStatus(report, featureTypes),
|
lastSeenAt: report.lastSeenAt,
|
||||||
lastSeenAt: report.lastSeenAt,
|
createdAt: report.createdAt,
|
||||||
createdAt: report.createdAt,
|
expiredAt: formatExpiredAt(report, featureTypes),
|
||||||
expiredAt: formatExpiredAt(report, featureTypes),
|
}));
|
||||||
})),
|
}, [projectId, features, featureTypes]);
|
||||||
[projectId, features]
|
|
||||||
);
|
|
||||||
|
|
||||||
const initialState = useMemo(
|
const initialState = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
|
Loading…
Reference in New Issue
Block a user