Skip to content

Commit

Permalink
#166 hide unnecessary card footer data
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreezag authored and Kreezag committed Jun 13, 2024
1 parent bac10ab commit 42653d8
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/shared/ui/preview-card/preview-card-footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { withDefaults, defineProps, computed } from "vue";
import { IconSvg } from "../icon-svg";
// TODO: Move this to a shared file
const KEY_MAP = {
const KEY_MAP: { [key: string]: string } = {
php_version: "php",
laravel_version: "laravel",
symfony_version: "symfony",
Expand All @@ -25,16 +25,25 @@ const props = withDefaults(defineProps<Props>(), {
});
const mappedOrigins = computed(() =>
props.originConfig
? Object.entries(props.originConfig).reduce((acc, [key, value]) => {
// Filter out empty values
if (!value || value === "undefined") return acc;
const mappedKey = KEY_MAP[key] || key;
acc[mappedKey] = value;
return acc;
}, {} as { [key: string]: string })
: {}
Object.entries(props.originConfig || {}).reduce((acc, [key, value]) => {
const fileName = props.originConfig?.file || "";
if (
key === "name" &&
fileName.includes(value, fileName.length - value.length)
) {
return acc;
}
if (!value || value === "undefined") {
return acc;
}
const mappedKey = KEY_MAP[key] || key;
acc[mappedKey] = value;
return acc;
}, {} as { [key: string]: string })
);
</script>

Expand Down

0 comments on commit 42653d8

Please sign in to comment.