/**
 *
 * @param {Event} e
 * @param {Object[]} records
 * @param {Object[]} selected
 * @returns {Object[]}
 */
export const toggleAll = (e,records, selected) => {
    if (selected.length === records.length) {
        return [];
    }
    e.currentTarget.checked = selected.length > 0;
    return records;
};

/**
 * @param {Object} record
 * @param {Object[]} selected
 * @returns {Object[]}
 */
export const selectRecord = (record, selected) => {
    let recordExists = selected.find((r) => r.id === record.id);
    if (recordExists) {
        return selected.filter((r) => r.id !== record.id);
    }
    return [...selected, record];

};