fix(ui): gracefully handle default initial baseline mappings and job runs in ChannelMappingTab and SyndicationHistoryTab

This commit is contained in:
Inamul-hasan-tec
2026-08-12 15:40:14 +05:30
parent 3c3dab9d26
commit be1d12072f
2 changed files with 20 additions and 9 deletions
@@ -44,21 +44,27 @@ export function ChannelMappingTab({ channelId }: { channelId: string }) {
const loadMappings = async () => {
setLoading(true);
const defaultBaseline = [
{ pim_attribute_code: "name", channel_field_code: "title", transformation_rule: "none", default_value: "", is_required: true },
{ pim_attribute_code: "code", channel_field_code: "variant_sku", transformation_rule: "uppercase", default_value: "", is_required: true },
{ pim_attribute_code: "status", channel_field_code: "published_status", transformation_rule: "lowercase", default_value: "published", is_required: false },
];
if (!channelId || channelId === "demo-channel-id") {
setMappings(defaultBaseline);
setLoading(false);
return;
}
try {
const data = await channelsApi.getMappings(channelId);
if (data && data.length > 0) {
setMappings(data);
} else {
// Default initial baseline mappings
setMappings([
{ pim_attribute_code: "name", channel_field_code: "title", transformation_rule: "none", default_value: "", is_required: true },
{ pim_attribute_code: "sku", channel_field_code: "variant_sku", transformation_rule: "uppercase", default_value: "", is_required: true },
{ pim_attribute_code: "price", channel_field_code: "price", transformation_rule: "currency_format", default_value: "0.00", is_required: true },
{ pim_attribute_code: "brand", channel_field_code: "vendor", transformation_rule: "none", default_value: "Generic", is_required: false },
]);
setMappings(defaultBaseline);
}
} catch {
notify.error("Failed to load channel mapping rules");
setMappings(defaultBaseline);
} finally {
setLoading(false);
}
@@ -15,12 +15,17 @@ export function SyndicationHistoryTab({ channelId }: { channelId: string }) {
}, [channelId]);
const loadJobs = async () => {
if (!channelId || channelId === "demo-channel-id") {
setJobs([]);
setLoading(false);
return;
}
setLoading(true);
try {
const data = await channelsApi.getJobs(channelId);
setJobs(data || []);
} catch {
notify.error("Failed to load syndication history");
setJobs([]);
} finally {
setLoading(false);
}