<template>
	<div class="px-2">
		<GenericList :options="partnerMembersList" />
	</div>
</template>
<script setup>
import { computed } from 'vue';
import GenericList from '../GenericList.vue';
import { createResource } from 'jingrow-ui';

const props = defineProps({
	partnerName: String
});

const partnerMembers = createResource({
	url: 'jcloud.api.partner.get_partner_members',
	cache: 'partnerMembers',
	auto: true,
	params: {
		partner: props.partnerName
	},
	transform(data) {
		data = data.map(d => {
			return {
				full_name: d.member_name,
				email: d.member_email
			};
		});
		return data;
	}
});

const partnerMembersList = computed(() => {
	return {
		data: partnerMembers.data || [],
		selectable: false,
		columns: [
			{
				label: '姓名',
				fieldname: 'full_name'
			},
			{
				label: '邮箱',
				fieldname: 'email'
			}
		]
	};
});
</script>