<template>
	<div class="d-flex" style="gap:8px">
		<component
			:is="buttonAuth.add ? 'BtnAddRow' : null"
			:btnActionsFnc="btnActionsFnc"
		/>
		<component
			:is="buttonAuth.excel ? 'BtnExcelDownload' : null"
			:parentPrgmId="parentPrgmId"
			:gridName="bindingData"
		/>
		<component
			:is="buttonAuth.save ? 'BtnSave' : null"
			:btnActionsFnc="btnActionsFnc"
		/>
		<component
			:is="buttonAuth.remove ? 'BtnRemoveRow' : null"
			:btnActionsFnc="btnActionsFnc"
		/>
	</div>
</template>
<script>
import { mapState, mapMutations } from 'vuex';
import BtnAddRow from './BtnAddRow';
import BtnRemoveRow from './BtnRemoveRow';
import BtnSave from './BtnSave';
import BtnExcelDownload from './BtnExcelDownload';

export default {
	props: {
		parentPrgmId: {
			type: String,
			require: true,
		},
		bindingData: {
			type: String,
			require: true,
		},
		btnActionsFnc: {
			type: Function,
			required: true,
		},
	},
	components: {
		BtnAddRow,
		BtnRemoveRow,
		BtnSave,
		BtnExcelDownload,
	},
	computed: {
		...mapState({
			buttonAuth(state) {
				return state.pageData[this.parentPrgmId][this.bindingData].buttonAuth;
			},
		}),
	},
	data() {
		return {};
	},
	methods: {
		...mapMutations({ setPageData: 'setPageData' }),
		getSearch() {
			this.setPageData({ isFind: true });
		},
	},
};
</script>
