dayjs.locale('ko');

export const formatDateTime = (dateTimeString) => {
    if (!dateTimeString) return '-';
    const date = new Date(dateTimeString);
    return dayjs(date).format("YYYY-MM-DD ddd A HH:mm:ss");
}

export const getModifiedRows = (arr1, arr2, keyField) => {
    const modifiedRows = [];
    const map1 = new Map(arr1.map(item => [item[keyField], item]));
    arr2.forEach(item2 => {
        const item1 = map1.get(item2[keyField]);
        if (item1 && !deepEqualSelectedFields(item1, item2)) {
            modifiedRows.push(item2);
        }
    });
    return modifiedRows;
}

export const deepEqualSelectedFields = (obj1, obj2) => {
    const keysToCompare = Object.keys(obj2);
    return keysToCompare.every(key => obj1[key] === obj2[key]);
}