<script setup lang="ts">
import Fieldset from 'primevue/fieldset';
import ModListEntry from './ModListEntry.vue';
import { usePkgStore } from '../stores';
import { Profile } from '../types';

defineProps({
    profile: Object as () => Profile,
});

const pkgs = usePkgStore();

const group = () => {
    const a = Object.assign(
        {},
        Object.groupBy(pkgs.allLocal, ({ namespace }) => namespace)
    );
    return a;
};

pkgs.reloadProfile();
</script>

<template>
    <Fieldset v-for="(namespace, key) in group()" :legend="key.toString()">
        <ModListEntry v-for="p in namespace" :pkg="p" />
    </Fieldset>
</template>
