import React, { useMemo } from 'react';
import { Grid } from '@material-ui/core';
import { AmbientGridTemplate } from '../../../UI/templates/deprecated/AmbientGridTemplate/AmbientGridTemplate';
import { TableColumnDefs } from '../utils/TableColumnDefs';
import { fluentLibraryIcons } from '../../../assets/unityIcons/LibraryData';
import { useReadMetaData } from '../hooks/useReadMetaData';
import { ActionsRenderer } from '../../../UI/templates/ui/renderers/ActionsRenderer';
// Demonstrative purpose
export const data = [
    {
        id: 1,
        name: 'Pre-School Swim Lessons',
        tags: 'Child',
        deferredGL: 'General Programs Deferred',
        earnedGL: `Registered Swim Programs`,
        start_date: '2022-07-23 13:10:11',
        end_date: '2022-07-23 13:10:11',
        status: 'Published',
        instructors: 'Liam Atchison'
    },
    {
        id: 2,
        name: 'Skating Lessons',
        tags: 'Child',
        deferredGL: 'General Programs Deferred',
        earnedGL: `Registered Swim Programs`,
        start_date: '2022-07-23 13:10:11',
        end_date: '2022-07-23 13:10:11',
        status: 'Published',
        instructors: 'Luca Thomas'
    },
    {
        id: 3,
        name: 'Skating Lessons',
        tags: 'Adult',
        deferredGL: 'General Programs Deferred',
        earnedGL: `Registered Swim Programs`,
        start_date: '2022-07-23 13:10:11',
        end_date: '2022-07-23 13:10:11',
        status: 'Published',
        instructors: 'John Smith'
    },
    {
        id: 4,
        name: 'Pre-School Swim Lessons',
        tags: 'Self-Pace',
        deferredGL: 'General Programs Deferred',
        earnedGL: `Registered Swim Programs`,
        start_date: '2022-07-23 13:10:11',
        end_date: '2022-07-23 13:10:11',
        status: 'In Progress',
        instructors: 'Lucy May'
    },
    {
        id: 5,
        name: 'Pre-School Swim Lessons',
        tags: 'Child',
        deferredGL: 'General Programs Deferred',
        earnedGL: `Registered Swim Programs`,
        start_date: '2022-08-23 13:10:11',
        end_date: '2022-07-23 13:10:11',
        status: 'Pending',
        instructors: 'Matteo Thomas'
    }
];
// Demonstrative purpose
const groupData = [
    { groupItem: 'instructors', label: 'Instructors', value: 'instructors' },
    { groupItem: 'tabs', label: 'Tabs', value: 'tabs' },
    { groupItem: 'name', label: 'Course Name', value: 'name' },
    { groupItem: 'status', label: 'Status', value: 'status' },
    { groupItem: 'start', label: 'Start Date', value: 'start' }
];
export const AgGridSimpleWrapper = (props) => {
    const { propsComponent } = props;
    const { id, columnSize, columnDefs, actionsList, values } = useReadMetaData(propsComponent);
    const columnDefinitions = useMemo(() => {
        if (columnDefs === null || columnDefs === void 0 ? void 0 : columnDefs.length) {
            const newActionsList = actionsList === null || actionsList === void 0 ? void 0 : actionsList.map((actionItem) => {
                var _a;
                return Object.assign(Object.assign({}, actionItem), { icon: ((_a = fluentLibraryIcons.find((x) => x.id === actionItem.icon)) === null || _a === void 0 ? void 0 : _a.icon) ||
                        actionItem.icon, onClick: () => { } });
            });
            return TableColumnDefs(columnDefs, newActionsList);
        }
        return [];
    }, [actionsList, columnDefs]);
    return (React.createElement(Grid, { item: true, xs: columnSize === null || columnSize === void 0 ? void 0 : columnSize.xs, sm: columnSize === null || columnSize === void 0 ? void 0 : columnSize.sm, md: columnSize === null || columnSize === void 0 ? void 0 : columnSize.md, key: id }, React.createElement(AmbientGridTemplate, { title: "Course List", data: values, columnDefs: columnDefinitions, frameworkComponents: { actionsRenderer: ActionsRenderer }, groupingData: groupData })));
};
//# sourceMappingURL=AgGridSimpleWrapper.js.map