Mocked imported function is not called by jest unit test

I just want to mock a function which is imported in the function, which I want to test:

content.ts

import { getFileContent } from './files' // Mock this one

export const example = async (argv) => { // This function should be tested
    let result = {}

    const { nodes } = await getFileContent(argv) // Mock this one
    console.log(nodes)

    result = nodes.type
    return result
}

file.ts

export const getFileContent = async (argv) => {
    try {
      return reader(argv.path) // reader is a function inside this file which reads files using `fs`
    } catch (error) {
      console.error(error)
    }
}

content.spec.ts

import { example } from './content'

const mockGetContent = jest.fn(() =>
    Promise.resolve({ nodes: { type: 'app' } })
)
jest.mock('./files', () => ({
    getFileContent: () => mockGetContent
}))

test('should call mock function', async () => {
    const argv = { path: './file.json'}
    await example(argv)
    expect(mockGetContent).toHaveBeenCalled()
})

But the expect fails, as mockGetContent has not been called. Also the console.log prints undefined.

What am I missing?

Firebase Hosting Authentification signInSuccessUrl not working

I have a problem that after Firebase Hosting Authentification the link to my page (signedIn.html) is not working (Failed to load resource: the server responded with a status of 404 ()).
The authentification itself seems to be working working well, and if I test it on Visual Studio Code debugger, the link to “signedIn.html” is also working, but not on firebase hosting after firebase deploy.
According firebase deploy protocol, all files are successfully uploaded to firebase.

var ui = new firebaseui.auth.AuthUI(firebase.auth());

var uiConfig = {
  callbacks: {
    signInSuccessWithAuthResult(authResult, redirectUrl) {
      return true;
    },
    uiShown() {
      document.getElementById('loader').style.display = 'none';
    },
  },
  signInFlow: 'popup',
  signInSuccessUrl: 'signedIn',
  signInOptions: [
    firebase.auth.EmailAuthProvider.PROVIDER_ID,
    firebase.auth.GoogleAuthProvider.PROVIDER_ID,
  ],
};
ui.start('#firebaseui-auth-container', uiConfig);

google sheets. transfer of data from one sheet to another (in different ranges) according to different conditions

please help with the script. I will briefly describe what is needed: there is a sheet with data, this data must be distributed to another sheet according to the condition.
in detail what needs to be done is written in the table on the “log” sheet
https://docs.google.com/spreadsheets/d/1Kw-H6hte7hriPPUQNzMKGxjiH4fQSN3gyQmNo-WZ8fc/edit?usp=sharing

(list of messages LOG telegrams chat. these messages have data about a stock market transaction

enter image description here

Chat telegram messages will be saved (written) to this list using a script. they look like the one shown above. the first column shows the date and time the message was sent. the second column contains the name of the transaction (RUB / USD / EUR and others). all other columns have additional information for column 2 (transaction date / purchase price / commission / ticker and others).

task: it is necessary to distribute these transactions into the necessary groups on the “distribution” sheet. for example: new data came to the “log” sheet (they always come in the first line, and the old data is shifted below, for more details in the table script). they look like this
enter image description here

data is sorted by color, so it’s easier to explain. column 2 (light red color, has “euro”) – the script must determine that the “euro” group is located in the range “AK: BA” on the “distribution” sheet. and transfer the first data (slightly darker red) “S:J” to the range “AL: AS” on the sheet “distribution” and the second data (dark red) “K: L” to the range “AZ:BA” also to the sheet ” distribution”

that is, everything is carried according to the color to the bottom empty line
cells on the “distribution” sheet of standard red should not change

enter image description here

by the way. column 2 should not be carried over to the “distribution” sheet. it just contains information where the data should be parsed)

Settimout use old data

I have an array of message messages from a bot and a user. First, the add Bot Message function is triggered, where a message from the user is first added, and then from the bot after 2 seconds.

What is the problem:
The message from the user (the addUserMessage function) works fine, but after 2 seconds it adds a message from the bot, but at the same time deletes the user’s message.

I understand that setTimeout uses the old data of the message array and rewrites the message from the user

How to fix it? Thanks

const [messages, addMessages]=useState([]);

const addBotMessage=async (value, callback)=>{
  addUserMessage(value, callback);
  setTimeout(()=>{
    addMessages([...messages,{content:BotContent[callback], time:getTime(), author:'bot'}]);
  },2000)
}

const addUserMessage=(value, callback)=>{
 if(!value) return;
 addMessages([...messages,{content:value, time:getTime(), author:'user'}]);
}

Flatten MongoDB nested object

I have a collection which looks like this:

[{
    productId: "c69b7701-c33f-4801-99f3-080450f2b6c7",
    createdAt: "2021-12-04T17:33:34.221Z",
    history: [{
        value: 304,
        storePrice: 50,
        date: 1638639214000,
        prevSold: {
            price: 303,
            createdAt: "2021-12-04T17:32:50.658Z"
        }
    }, ... 100+ more records]
    _id: "61aba66d9085f0044f96a700"
}, ... 100+ more records]

And I’m just calling it with a basic find ie:

    const slug = req.params.slug

    ProductPrice.find({ productId: slug}).exec((err, data) => {
        if (err){
            return res.status(400).json({
                error: errorHandler(err)
            })
        }
        res.json(data)
    })

I need to get the prev sold price into the same level as history.value

ie:

[{
    productId: "c69b7701-c33f-4801-99f3-080450f2b6c7",
    createdAt: "2021-12-04T17:33:34.221Z",
    history: [{
        value: 304,
        storePrice: 50,
        date: 1638639214000,
        prevSold: 303
    }, ... 100+ more records]
    _id: "61aba66d9085f0044f96a700"
}, ... 100+ more records]

So far I’ve tried the following aggregate call but it’s just returning an empty array. Can anyone point me in the right direction please?

    ProductPrice.aggregate([
        {$match: { productId: slug }},
        {$unwind: "$history.prevSold"},
        {$addFields: {
            "prevSold.value": "$price",
        }},
        {$replaceRoot: {
            newRoot: "$prevSold"
        }}

Thanks,

How to add tooltip to all the dynamically loaded column in material-table

so I am using React material Table in like 70 different components, so I’ve went and made my custom component that contains the material-table so the shared props are in one place and the different ones are passed as props through my customMaterialTable component

in my different components where I’m using the customMaterialTable comp. the columns prop look like this

columns={[{
            title: 'Internal CODE',
            field: 'mat_code',
            render: (rowData) => (
                <Tooltip title={'Internal CODE'}>
                    <p>{rowData.mat_code}</p>
                </Tooltip>
                ),
                },
                {
                title: 'External CODE',
                field: 'external_mat_code',
                editable: 'never',
                },
                {
                title: 'ENGLISH DESCRIPTION',
                field: 'descr_en',
    }]}

and in my customMaterialComponent I’m passing the props to the original Mateiral-Table like this

columns={columns.map((column) => {
        return {
            ...column,
            cellStyle: {
                backgroundColor: 
                       column?.editable === 'never'
                        ? 'rgba(235, 235, 228, 0.54)'
                        : 'inherit',
                },
            };
       })}

and it is working great
but what I want to do is give all the columns a toolTip like in the first one up there

render: (rowData) => (
          <Tooltip title={'Internal CODE'}>
            <p>{rowData.mat_code}</p>
          </Tooltip>
        ),

the problem is if I do it that way, it means I have to do it like 300 times or so in 300 different places or more, I have access to the text that will be in the tooltip title, but I’m not sure how to render the return method:

return {
      ...column,
      cellStyle: {
      backgroundColor: 
      column?.editable === 'never'
      ? 'rgba(235, 235, 228, 0.54)'
      : 'inherit',
            },
      };
    }

inside of it
when I console log each column all I found is something like this:

{
    "title": "External CODE",
    "field": "external_mat_code",
    "editable": "never"
}

I’m sorry the question is a bit long and please don’t downvote it I have been blocked before and I need to be part of this community

if anyone have suggestions on how to do it please share with me

I think it’s more react related than Material-table

MySQL Can not open connection after call connection.end() => Error: Pool is closed

config.js

const mysql = require('mysql2');

const config = {
    host: 'localhost',
    port: '3306',
    user: 'root',
    password: 'root',
    database: 'krometal',
    charset: "utf8mb4_bin",
    multipleStatements: true
};
const connection = mysql.createPool(config);

connection.getConnection(function (err, connection) {
    //connecting to database
    if (err) {
        logger.log('error', err);
        console.log("MYSQL CONNECT ERROR: " + err);
    } else {
        logger.log('info', "MYSQL CONNECTED SUCCESSFULLY.");
        console.log("MYSQL CONNECTED SUCCESSFULLY.");
    }
});

module.exports = {
    connection
}

login.js

const loginUser = async (req, callback) => {
  connection.query(sql, async function (err, rows) => {
      // logic
      callback(result, 401, connection);
  })
}

route.js

users.post('/users/login', async (req, res) => {
    await loginUser(req, async (response, code, connection) => {
        await connection.end();
        res.status(code).send(response);
    });
});

The problem is the first time I try login worked fine, but if I try the same login API again throw the error Error: Pool is closed.

Should I use the

connection.end()

method every time I open connection or mysql2 automatically end connection?

Does anyone recognize this JavaScript protection? (obfuscated, packed)

I’m trying to write a userscript, and encountered this beastly contraption. It has clearly been obfuscated, but so far the tool used is unknown. I’m wondering if:

  • anybody could identify the tool used, and, if there is any joy left in the world, a corresponding tool to undo its madness.
  • anyone has some thoughts on how to otherwise tame the beast a bit; I was thinking that some sort of JS → JS static analyis optimizer could perhaps reduce the nonsense to more manageable proportions.

Recommendations regarding either course of action or indeed something completely novel would all be lovely.

The creature is question is too corpulent to put in an SO post, so it’s here: https://pastebin.com/2dpPd6WU

For your amusement, here is a preview:

var _0x2f4f = ['yxbWzw5Kq2HPBa', 'DxnJqxa', 'CMvHzhK', 'AMHdrhu', 'pgrPDIbPzd0IBW', 'C3HrDNq', 'C2HVDW', 'Cgf1C2u', 'BwX1Axe', 'ihrVCdOGlte1Ca', 'ENnqzMu', 'B25JBgLJAZ0IyW', 'Bfz1DwK', 'l2fQyxGVCgXHEq', 'p3y9', 'uLP6Dw0', 'AhrTBa', 'zgLYzwn0', 'wgDmCfC', 'rgv2vg9VBhm', 'yKTiAKu', 'C3rVCa', 'EwvY', 'yMLUza', 'tfrbEwO', 'CwDOCvi', 'sg1Iqxi', 'BgvUz3rO', 'A3vjBNe', 'vKDpuxC', 'sgXvBKi', 'rLvvtKO', 'CMv0DxjUicHMDq', 'ywn0Aw9U', 'C3LSA2u', 'ywrKq2XHC3m', 'sgvryvG', 'y2fZDa', 'l2nSB3nLlNbUzW', 'mhW1', 'DMTjrLa', 'D3b1zuS', 'z3nJsMS', 's0v1reW', 'qLHdCeW', 'y0HmzxK', 'AxbMDfO', 'zM9UDfnPEMu', 'qKXzyxq', 'D2f0y2GTCgXHEq', 'oYb0B3a6idmWjq', 'qK5bAwy', 'vKHjEve', 'wKHHDu8', 'A21nt1q', 'vvrkz1K', 'AwDODdOZmhb4oW', 'zxiTyMfUBMvY', 'qKXkwg0', 'sevJt24', 'sgvSDMv0AwnH', 'weHvEhi', 'BhrHC3O', 'z3HfuMO', 'mxj5DhLhDa', 'DgfIBgu', 'ugj5CNu', 'Bg9N', 'rurgtge', 'n3b4oYiGC3jJpq', 'DKDTree', 'Dw5KzwzPBMvK', 'v2vsD0O', 'y2fWDgLVBNm', 'mtK4mMfqA3DKCq', 'ChjVDg90ExbL', 'qMzsugq', 'yNjVD3nLCG', 'DgnzyK8', 'z2v0', 'zgHQqvm', 'kYb0AgLZicSGiG', 'lMXPBMSTAxrLBq', 'yMHgB3e', 'vhfjwvK', 'vfbVBLq', 'BgvMDdOGlte1ma', 'kcKIigHYzwy9iG', 'psjWB3nPDgLVBG', 'rhjpru4', 'CgfYzw50', 'DKzXDM8', 'zvHpvKK', 'ze5xr3G', 'oYbSzwz0oIa1ma', 'AMLdu2S', 'AuXiy2i', 'AMf2yxnJCMLWDa', 'BgLUAW', 'C0fhvem', 'svLwv2u', 'B2foALK', 'oJSIihn0EwXLpq', 'zNb2ywG', 'CgXHEq', 'DNbutgu', 'v0HHshq', 'EuvXuuu', 'uNrbrNK', 'DfvZr0i', 'zw50zxi', 'zKPbAwy', 'qvvpuMG', 'r2j6yKu', 'mJK0ELnWB2XH', 'vKngA24', 'r1boBfO', 'AwDOvfu', 'D2fYBG', 'Dw1VA3i', 'm3W2Fdr8mxWYFa', 'tLf6C0q', 'DhjHy2TZ', 'BMv4Da', 'yMzhteq', 'v2T2sMu', 'DgHLBG', 'y1z3C2O', 'DgL0Bgu', 'z2nLq3C', 'ufnJtgq', 'Eu1mzge', 'ww1swxq', 'DxaGzxjYB3i6ia', 'DMvYBgf5lwnLBG', 'yMfJA2DYB3vUza', 'CMvTB3zL', 'i3DHDgnOlwLMCG', 'mZq3rK9pELns', 'C3rHDhvZ', 'oInMzMy7ihDPza', 'CLDnENK', 'vMfAv1e', 'lMfJDgL2zq', 't3vrC1i', 'CMv0DxjUic8Iia', 'zxjYB3i', 'ChG7ihOTAw5Kzq', 'CgXHEwvYihnLDa', 'i2LMCMfTzs1LBq', 'xIHBxIbDkYGGkW', 'Bw9IAwXL', 'yLf0vhy', 'tvLHu0W', 'Eu9etfO', 'C1PVwfi', 'z3bPufi', 'zxHJzxb0Aw9U', 'y29UC3rYDwn0BW', 'BLflAxC', 'CgXSsxe', 'yxr0CG', 'y3rVCIGICMv0Dq', 'A3rdt2W', 'igfIC29SDxrLoW', 'CwDkB1i', 'suHADw4', 'jtSGBwfYz2LUlq', 'ALLeyvy', 'ChjLCgvUza', 'DeHlt2y', 'rKzAC28', 'EuLruK8', 'yxbWBhK', 'zxHLy3v0zq', 'EdOGotSIpJXHia', 'oIbHyNnVBhv0zq', 'EdSGCMLNAhq6ia', 'Dg9tDhjPBMC', 'BMn0Aw9UkcKG', 't0v4AvO', 'twfWCgLUz1vsta', 'y2XPy2S', 'tMLSDvu', 'rwjxz20', 'Bwjgtvi', 'i3DHDgnOlxbSyq', 'we9kELq', 'wxvbAu4', 'AxvZoJuWjtSGDa', 'zgL2pG', 'sKTzDvC', 'ugzdr1C', 'C2v0Dxa', 'yM9YzgvYlxjHza', 'DgLnv2i', 'y2vUDgvYo2jVCG', 'yvHqDKS', 'y29UC29Szq', 'wNDxCwi', 'lte1ChG7ihOTAq', 'v29ItLi', 'lY8JihnVDxjJzq', 'Aw50rfC', 'lNDHDgnOAw5NxW', 'zgvYoNnVBgLKia', 'iI8+pc9HpG', 'yw1L', 'yxjNAw4TDg9WoG', 'rLPes3q', 'muT3whDTsq', 'BuzrsLm', 'twLuC0u', 'BujtzKG', 'CMfPC2vK', 'AhjLzG', 'q21XANy', 'zxH0lwfSAwDUoG', 'sxbIqKi', 'C3jJ', 'rfjqtLe', 'vxjkq3q', 't0LmBK8', 'tNLOuvm', 'zLPwAKu', 't3bHy2L0Eq', 'BKXguMe', 't25dChm', 'p190B2TLBJ0', 'i2yZzJm3oa', 'BNjoyvu', 'Aw5MBW', 'ywr4DLu', 'thbLvMy', 'BhbWtNa', 'BMrLEdOGotK7ia', 'Cen3wMS', 'CgXHEwvYigvYCG', 'EgTeBLK', 'zM1YBMS', 'iNbVC2L0Aw9UoG', 'z1Pnzwm', 'DgvYiIbZDhLSzq', 'Au9Yuva', 'BuTevei', 'zhrOoJe2ChG7Bq', 'zejeueq', 'E30Uy29UC3rYDq', 'BxHutLe', 'ihn0EwXLpsj3Aq', 'zNjPrfG', 'tfnOs1G', 'rgTbr0O', 'EffzDe8', 'i3DHDgnOlq', 'Bg5UrMu', 'AfvkvLO', 'AgLKzq', 'Bg9JyxrPB24', 'z2TbwLK', 'nxW2Fdr8mNWWFa', 'txvhrfe', 'ruDLy1i', 'Bg9ZzujHBM5LCG', 'y2DpsKW', 'C3bSAxq', 'odm5odqYzuPMv1rW', 'mJq4ndbVwLvbsKy', 'mxb4oYi+pgLTzW', 'y1PbBLy', 't2HqsLe', 'zK5Jv2G', 'i21HC2STCgXHEq', 'mJG0nJzdshnbDu4', 'zvn6B2y', 't0HyEfi', 'nJm0m3HsyNDrBq', 'DgLTzq', 'tujxvMu', 'zMLUza', 'B250ywLUzxi', 'AgfxzwC', 'C291CMnLCW', 'z2zZvxC', 'zvLNrui', 'DgvZDa', 'i292zxjSyxKTyW', 'zM9UDgzHBwLSEq', 'q0vwy2K', 'BLvIrem', 'yxv0B3n0yxj0', 'AfzHse4', 'DevxzMe', 'z2v0x2XPBMS', 'CuzgA2u', 'DhLWzq', 'ntu5nteYt1PRqMDJ', 'iI4Ul2LTywDLCW', 'w14GxsSPkYKRwW', 'mZe5mdmXy3bou1Lr', 'CgXHEwvYlwfYzq', 'CKLTCKi', 'z2DdDfe', 'DgG6mZbWEdTOzq', 'B2Toufy', 'CgvUyLG', 'y3jLyxrLrwXLBq', 'tNH4zwW', 'sgvkBxa', 'zNjRuhq', 'DxHqAva', 'yMvK', 'uLPcCxK', 'EKfJrLK', 'u1HPCfi', 'ywn0AxzL', 'z05HC0q', 'zwrNzvn0EwXL', 'C3rYAw5NAwz5'];
var _0x2296b6 = function(_0x47da52, _0x554f21, _0xa3910d, _0x39f033) {
        return _0x3729(_0x47da52 - 0x2d4, _0xa3910d);
    },
    _0x359e43 = function(_0xec3c7f, _0xf29ea9, _0x52378d, _0x35151c) {
        return _0x3729(_0xec3c7f - 0x2d4, _0x52378d);
    };
(function(_0x1bd7a0, _0x692db4) {
    var _0xc969bd = function(_0x1cad4d, _0x539b5a, _0x76b270, _0x4291d3) {
            return _0x3729(_0x76b270 - 0x112, _0x1cad4d);
        },
        _0x53a766 = function(_0x381881, _0x49fd22, _0x4b348c, _0x2e0648) {
            return _0x3729(_0x4b348c - 0x112, _0x381881);
        };
    while (!![]) {
        try {
            var _0x1b2623 = -parseInt(_0xc969bd(0x41a, 0x3ac, 0x39b, 0x30a)) * -parseInt(_0xc969bd(0x326, 0x236, 0x29c, 0x2cf)) + parseInt(_0x53a766(0x343, 0x2c5, 0x33a, 0x2e3)) + -parseInt(_0xc969bd(0x2a4, 0x342, 0x323, 0x2b4)) + parseInt(_0x53a766(0x35f, 0x2ee, 0x31d, 0x2d3)) + -parseInt(_0xc969bd(0x354, 0x38e, 0x31c, 0x312)) * -parseInt(_0xc969bd(0x2ee, 0x2a8, 0x2e4, 0x34a)) + -parseInt(_0x53a766(0x34a, 0x36a, 0x391, 0x318)) * -parseInt(_0x53a766(0x2f3, 0x2dc, 0x33d, 0x3a6)) + -parseInt(_0xc969bd(0x206, 0x2de, 0x284, 0x202)) * parseInt(_0xc969bd(0x2be, 0x2a0, 0x326, 0x2c1));
            if (_0x1b2623 === _0x692db4) break;
            else _0x1bd7a0['push'](_0x1bd7a0['shift']());
        } catch (_0x491393) {
            _0x1bd7a0['push'](_0x1bd7a0['shift']());
        }
    }
}(_0x2f4f, -0x445bd + 0x1c5 * 0x63a + 0xbab1 * 0x2));
var player = jwplayer(_0x2296b6(0x544, 0x4b3, 0x555, 0x4ef) + 'er'),
    sources, tracks, player_title = '',
    retried = ![],
    watchId;

function setup_player() {
    var _0x40b349 = function(_0x13d3e4, _0xac56fd, _0x4ade94, _0x8f794e) {
            return _0x2296b6(_0xac56fd - 0x8f, _0xac56fd - 0xcc, _0x13d3e4, _0x8f794e - 0x14);
        },
        _0x5273c4 = function(_0x1fd334, _0x2b9d8f, _0x44c1dc, _0x55739a) {
            return _0x2296b6(_0x2b9d8f - 0x8f, _0x2b9d8f - 0x178, _0x1fd334, _0x55739a - 0x1de);
        },
        _0x5e67c3 = {};
    _0x5e67c3[_0x40b349(0x5bc, 0x526, 0x4b4, 0x538)] = function(_0x1f2e0f, _0xad02a) {
        return _0x1f2e0f(_0xad02a);
    }, _0x5e67c3[_0x5273c4(0x5a3, 0x5c6, 0x65d, 0x5c0)] = _0x5273c4(0x5b2, 0x581, 0x4f1, 0x5d1) + _0x5273c4(0x5b0, 0x57b, 0x606, 0x59e), _0x5e67c3['yIQRO'] = function(_0x5c5422, _0x3e943f) {
        return _0x5c5422 + _0x3e943f;
    }, _0x5e67c3['intDW'] = _0x5273c4(0x563, 0x5a6, 0x5f8, 0x50f) + 'verlay-cen' + _0x40b349(0x551, 0x555, 0x5ab, 0x51d) + _0x40b349(0x584, 0x5fa, 0x5c0, 0x57a) + _0x5273c4(0x522, 0x513, 0x4a3, 0x495) + _0x5273c4(0x55d, 0x5d4, 0x5f4, 0x5ae) + _0x40b349(0x586, 0x600, 0x5a5, 0x637) + _0x40b349(0x4b6, 0x50a, 0x4e6, 0x473) + 'left:x20-150' + 'px;x20z-inde' + _0x5273c4(0x536, 0x512, 0x4e9, 0x4fd) + _0x40b349(0x56c, 0x5ad, 0x5a2, 0x570) + _0x5273c4(0x544, 0x56a, 0x560, 0x51c) + _0x5273c4(0x5af, 0x5f9, 0x617, 0x56b) + 'javascript' + _0x40b349(0x56e, 0x608, 0x5fc, 0x641) + 'x22position:' + _0x5273c4(0x54f, 0x507, 0x59e, 0x595) + 'x20top:x20-15p' + 'x;x20right:x20' + _0x5273c4(0x4ad, 0x52b, 0x4d9, 0x4b1) + _0x5273c4(0x5d3, 0x54e, 0x5b7, 0x52b) + _0x5273c4(0x4e7, 0x4ea, 0x531, 0x44e) + _0x40b349(0x4e1, 0x4ef, 0x461, 0x534) + _0x40b349(0x4ff, 0x592, 0x576, 0x5a1) + 'ight:30px;' + 'border-rad' + _0x40b349(0x4aa, 0x520, 0x5bd, 0x48b) + 'ext-align:' + 'center;bor' + _0x40b349(0x518, 0x530, 0x5a1, 0x58a) + _0x5273c4(0x605, 0x56f, 0x5cd, 0x4ff) + _0x40b349(0x512, 0x55c, 0x509, 0x5d8) + 'dth:16px;m' + _0x40b349(0x5c9, 0x533, 0x4eb, 0x55a) + _0x5273c4(0x64c, 0x5e7, 0x63f, 0x57b) + 'x22../images' + _0x40b349(0x54f, 0x5c8, 0x5a8, 0x5c0) + _0x5273c4(0x55d, 0x531, 0x4b7, 0x567), _0x5e67c3['frkPt'] = '</div>', _0x5e67c3[_0x5273c4(0x438, 0x4d0, 0x509, 0x4e0)] = '.link-item' + '.active', _0x5e67c3[_0x5273c4(0x4f7, 0x55b, 0x528, 0x540)] = _0x5273c4(0x5d4, 0x5f4, 0x651, 0x65f), _0x5e67c3[_0x40b349(0x5cc, 0x5b4, 0x5c7, 0x5c0)] = function(_0x352f11, _0x3fc163) {
        return _0x352f11 === _0x3fc163;
    }, _0x5e67c3[_0x5273c4(0x562, 0x5ce, 0x64b, 0x5b6)] = _0x5273c4(0x61e, 0x5cb, 0x628, 0x645), _0x5e67c3[_0x40b349(0x5e7, 0x57e, 0x56e, 0x56e)] = _0x40b349(0x618, 0x5d6, 0x544, 0x587), _0x5e67c3[_0x5273c4(0x523, 0x4e4, 0x50f, 0x540)] = function(_0x3feaa2, _0x447fd2) {
        return _0x3feaa2 == _0x447fd2;
    }, _0x5e67c3[_0x5273c4(0x65c, 0x5e4, 0x5e5, 0x605)] = function(_0x4092bd, _0x421b1f, _0x130c0a) {
        return _0x4092bd(_0x421b1f, _0x130c0a);
    }, _0x5e67c3['IHZun'] = _0x40b349(0x55d, 0x573, 0x60d, 0x5b3) + 'er', _0x5e67c3[_0x40b349(0x54d, 0x53d, 0x5b6, 0x4a9)] = function(_0x1a845a, _0x18f38f) {
        return _0x1a845a == _0x18f38f;
    }, _0x5e67c3[_0x5273c4(0x5c3, 0x52a, 0x51d, 0x521)] = _0x40b349(0x509, 0x4db, 0x533, 0x4aa) + _0x5273c4(0x5a0, 0x5c9, 0x52e, 0x65c), _0x5e67c3[_0x40b349(0x672, 0x5ea, 0x557, 0x5c4)] = _0x5273c4(0x4ac, 0x4ec, 0x478, 0x564) + _0x40b349(0x4bd, 0x532, 0x595, 0x5b7), _0x5e67c3[_0x5273c4(0x4de, 0x4e2, 0x4e4, 0x57b)] = function(_0x15092c) {
        return _0x15092c();
    }, _0x5e67c3[_0x5273c4(0x593, 0x5f5, 0x5d7, 0x64e)] = _0x5273c4(0x53a, 0x4f8, 0x557, 0x52a) + _0x5273c4(0x53e, 0x59a, 0x55b, 0x5f7), _0x5e67c3[_0x5273c4(0x50f, 0x52c, 0x492, 0x4aa)] = function(_0x524315, _0x45db3d) {
        return _0x524315 == _0x45db3d;
    }, _0x5e67c3[_0x40b349(0x464, 0x4d3, 0x47c, 0x4c1)] = function(_0x3393b3, _0x2632fe) {
        return _0x3393b3(_0x2632fe);
    }, _0x5e67c3[_0x40b349(0x4c1, 0x51b, 0x4ae, 0x543)] = _0x40b349(0x565, 0x4fd, 0x48a, 0x496), _0x5e67c3[_0x40b349(0x59d, 0x5b6, 0x5b0, 0x604)] = 'hMNIB', _0x5e67c3[_0x5273c4(0x591, 0x5e6, 0x639, 0x56c)] = function(_0x494ce9, _0x39bf2f) {
        return _0x494ce9(_0x39bf2f);
    }, _0x5e67c3[_0x40b349(0x51d, 0x4fe, 0x593, 0x4dc)] = function(_0x43a03a, _0x4c110e) {
        return _0x43a03a + _0x4c110e;
    }, _0x5e67c3['ighTU'] = _0x5273c4(0x561, 0x5a6, 0x532, 0x5cc) + 'verlay-con' + 'tainerx22></' + _0x40b349(0x4b9, 0x521, 0x4ac, 0x52a), _0x5e67c3[_0x5273c4(0x678, 0x5fb, 0x678, 0x62c)] = _0x5273c4(0x5bc, 0x5af, 0x61e, 0x57e) + _0x40b349(0x659, 0x5db, 0x5aa, 0x5b4), _0x5e67c3[_0x5273c4(0x60f, 0x5f6, 0x592, 0x667)] = _0x40b349(0x5d7, 0x53e, 0x511, 0x591), _0x5e67c3[_0x5273c4(0x5d9, 0x5a7, 0x5ae, 0x5e4)] = _0x5273c4(0x557, 0x51d, 0x57a, 0x59f) + _0x40b349(0x5c8, 0x5b8, 0x59f, 0x625), _0x5e67c3[_0x5273c4(0x5e7, 0x55e, 0x52b, 0x5df)] = _0x40b349(0x4d9, 0x554, 0x53f, 0x4c2), _0x5e67c3[_0x5273c4(0x456, 0x4df, 0x4ee, 0x483)] = function(_0x402333, _0x5d7e91) {
        return _0x402333 > _0x5d7e91;
    }, _0x5e67c3[_0x40b349(0x520, 0x4d2, 0x4ea, 0x4fa)] = _0x40b349(0x51b, 0x581, 0x563, 0x5f8) + 'enter', _0x5e67c3[_0x40b349(0x4a8, 0x51c, 0x505, 0x4ab)] = function(_0x376ae9, _0x3c3332) {
        return _0x376ae9(_0x3c3332);
    }, _0x5e67c3[_0x5273c4(0x680, 0x609, 0x5b7, 0x5cc)] = function(_0x4497ac, _0x17c6af) {
        return _0x4497ac(_0x17c6af);
    }, _0x5e67c3['eYgEB'] = function(_0x436506, _0x16bc57) {
        return _0x436506 + _0x16bc57;
    }, _0x5e67c3[_0x40b349(0x645, 0x5d7, 0x609, 0x577)] = function(_0x38b488, _0x2f8379) {
        return _0x38b488 === _0x2f8379;
    }, _0x5e67c3['uxPiP'] = _0x5273c4(0x523, 0x4e0, 0x4ab, 0x50f), _0x5e67c3[_0x40b349(0x5d9, 0x5c0, 0x5ef, 0x60f)] = _0x40b349(0x4ea, 0x550, 0x54a, 0x4ef) + 'or', _0x5e67c3[_0x5273c4(0x4b2, 0x4dc, 0x541, 0x461)] = function(_0x5ae62a, _0x387d53) {
        return _0x5ae62a(_0x387d53);
    }, _0x5e67c3[_0x5273c4(0x5dd, 0x57c, 0x5b5, 0x618)] = function(_0x3b7de4, _0x358222) {
        return _0x3b7de4 + _0x358222;
    }, _0x5e67c3[_0x40b349(0x677, 0x5ee, 0x60c, 0x606)] = function(_0x17f5d6, _0x22eb32) {
        return _0x17f5d6 + _0x22eb32;
    }, _0x5e67c3['eXOVI'] = _0x40b349(0x59b, 0x5c2, 0x571, 0x529) + _0x5273c4(0x48b, 0x516, 0x4e9, 0x49b), _0x5e67c3[_0x40b349(0x50e, 0x590, 0x629, 0x60a)] = _0x5273c4(0x56b, 0x575, 0x4f0, 0x54b), _0x5e67c3[_0x5273c4(0x4dc, 0x4ce, 0x448, 0x451)] = _0x40b349(0x48a, 0x4f7, 0x514, 0x464) + _0x40b349(0x535, 0x4e8, 0x455, 0x505), _0x5e67c3[_0x40b349(0x5d8, 0x560, 0x5e9, 0x4d3)] = function(_0x4a8d33) {
        return _0x4a8d33();
    }, _0x5e67c3['RZzum'] = _0x5273c4(0x536, 0x548, 0x53a, 0x4df), _0x5e67c3[_0x5273c4(0x572, 0x4e7, 0x568, 0x486)] = 'complete', _0x5e67c3[_0x5273c4(0x4f8, 0x551, 0x56e, 0x5c9)] = _0x5273c4(0x65b, 0x60a, 0x67f, 0x58b), _0x5e67c3[_0x40b349(0x548, 0x522, 0x4fc, 0x572)] = _0x40b349(0x5b4, 0x5a4, 0x5d5, 0x60b), _0x5e67c3['XOJzT'] = _0x40b349(0x59d, 0x578, 0x578, 0x60d), _0x5e67c3[_0x40b349(0x4bb, 0x54d, 0x4cf, 0x4e0)] = 'setupError';
    var _0x54f3a7 = _0x5e67c3,
        _0x356df3 = {};
    _0x356df3['color'] = _0x54f3a7[_0x40b349(0x5fa, 0x5b1, 0x60e, 0x63d)], _0x356df3[_0x40b349(0x583, 0x5d1, 0x5a3, 0x533)] = 0xe, _0x356df3[_0x5273c4(0x4ee, 0x4ea, 0x572, 0x543) + _0x5273c4(0x578, 0x544, 0x513, 0x5de)] = 0x0, _0x356df3[_0x40b349(0x559, 0x582, 0x57e, 0x4ec)] = _0x5273c4(0x5c3, 0x5de, 0x54d, 0x619), _0x356df3[_0x40b349(0x5af, 0x5a0, 0x5c7, 0x534)] = _0x40b349(0x56c, 0x539, 0x5a4, 0x517);
    var _0x5222a9 = {};
    _0x5222a9[_0x40b349(0x543, 0x585, 0x525, 0x532)] = ![], _0x5222a9['displaytit' + 'le'] = !![], _0x5222a9['title'] = player_title, _0x5222a9[_0x40b349(0x51a, 0x57d, 0x55d, 0x61c)] = sources, _0x5222a9[_0x5273c4(0x4ef, 0x4dd, 0x49c, 0x4ae)] = tracks, _0x5222a9[_0x5273c4(0x5c6, 0x5c7, 0x63c, 0x5b1)] = {}, _0x5222a9[_0x5273c4(0x570, 0x5eb, 0x5e7, 0x5a6)] = _0x356df3;
    var _0x5c25f5 = _0x5222a9;
    player[_0x40b349(0x4fe, 0x524, 0x487, 0x55c)](_0x5c25f5), player['on'](_0x54f3a7['YmRYt'], function() {
        var _0x22c4d8 = function(_0x10547d, _0xeec799, _0x2a26f9, _0x199c13) {
                return _0x40b349(_0x199c13, _0x10547d - -0x298, _0x2a26f9 - 0x9d, _0x199c13 - 0x15a);
            },
            _0xffde40 = function(_0x41aa16, _0x3b72e5, _0x266822, _0x145a4a) {
                return _0x5273c4(_0x145a4a, _0x41aa16 - -0x298, _0x266822 - 0x2d, _0x145a4a - 0xbe);
            },
            _0x32b6c5 = {};
        _0x32b6c5['dBDPD'] = function(_0x21b2d6, _0x41b2d1) {
            return _0x21b2d6(_0x41b2d1);
        }, _0x32b6c5[_0x22c4d8(0x2ef, 0x2c5, 0x2c5, 0x32a)] = _0x54f3a7['tUsGB'], _0x32b6c5[_0xffde40(0x32c, 0x32a, 0x311, 0x313)] = _0x54f3a7[_0xffde40(0x2c3, 0x22b, 0x280, 0x2fa)];
        var _0x2bbc1f = _0x32b6c5;
        if (_0x54f3a7[_0x22c4d8(0x31c, 0x2f8, 0x2b1, 0x2bc)](_0x54f3a7['BXCpL'], _0x54f3a7[_0xffde40(0x2e6, 0x255, 0x311, 0x2ad)])) {
            function _0x173d7b() {
                var _0x53c5b6 = function(_0x3465df, _0x103d4a, _0x471fd9, _0x2d3295) {
                        return _0xffde40(_0x2d3295 - -0x13a, _0x103d4a - 0x105, _0x471fd9 - 0xb1, _0x103d4a);
                    },
                    _0x2533ef = function(_0x384538, _0x53e852, _0x4be96a, _0x33ddc4) {
                        return _0x22c4d8(_0x33ddc4 - -0x13a, _0x53e852 - 0x1a0, _0x4be96a - 0x163, _0x53e852);
                    };
                _0x2b7b6c['status'] && _0x54f3a7['tiMWb'](_0xd6fc96, _0x54f3a7[_0x53c5b6(0x28e, 0x216, 0x24a, 0x1f4)])['prepend'](_0x54f3a7[_0x2533ef(0x18c, 0x17e, 0x13d, 0x13d)](_0x54f3a7[_0x53c5b6(0x15e, 0x13a, 0x14b, 0x15c)], _0x12e6f2[_0x2533ef(0x1e1, 0x234, 0x1b7, 0x1e0)]) + _0x54f3a7[_0x2533ef(0x23d, 0x1bc, 0x173, 0x1c6)]);
            }
        } else _0x54f3a7['gceCw'](movie['type'], 0x1 * -0x7e7 + -0xb * 0x141 + -0x4 * -0x56d) && _0x54f3a7[_0xffde40(0x34c, 0x3e2, 0x3b3, 0x321)](setTimeout, function() {
            var _0x530f33 = function(_0x64e8ed, _0x227c2d, _0x401155, _0x4d9c51) {
                    return _0xffde40(_0x227c2d - -0x36c, _0x227c2d - 0x138, _0x401155 - 0x1d4, _0x401155);
                },
                _0x27c3a1 = function(_0x1423d3, _0x2cbc9a, _0x371720, _0x33f329) {
                    return _0xffde40(_0x2cbc9a - -0x36c, _0x2cbc9a - 0xcf, _0x371720 - 0x118, _0x371720);
                };
            _0x2bbc1f[_0x530f33(-0x15, -0xab, -0x116, -0xe4)]($, _0x2bbc1f[_0x27c3a1(-0x8e, -0x7d, -0x92, 0xc)])[_0x27c3a1(0x3d, -0x8, -0x7a, -0xb)]()[_0x27c3a1(-0xf9, -0x126, -0x103, -0x119)]()[_0x27c3a1(-0xae, -0x8a, -0x5, 0x6)](_0x2bbc1f['sylke'])[_0x27c3a1(-0xc6, -0xeb, -0x180, -0xdf)]();
        }, 0x70 * 0x8 + 0xf63 + 0x3b * -0x41);
    }), player['on'](_0x54f3a7[_0x40b349(0x5ca, 0x551, 0x5d9, 0x5a5)], function() {}), player['on'](_0x54f3a7[_0x5273c4(0x578, 0x522, 0x4e0, 0x54b)], function() {
        var _0x1b8bb5 = function(_0x3ab794, _0x10aaf5, _0x1478b6, _0x5db214) {
                return _0x5273c4(_0x10aaf5, _0x5db214 - -0x301, _0x1478b6 - 0xe5, _0x5db214 - 0x10d);
            },
            _0x105b9d = function(_0x5cd015, _0x3d6640, _0x15c14c, _0x389d03) {
                return _0x5273c4(_0x3d6640, _0x389d03 - -0x301, _0x15c14c - 0x10c, _0x389d03 - 0x138);
            },
            _0x49cef3 = {};
        _0x49cef3['vGmDA'] = _0x54f3a7[_0x1b8bb5(0x233, 0x25a, 0x246, 0x208)], _0x49cef3[_0x1b8bb5(0x2ea, 0x211, 0x23f, 0x292)] = function(_0x38bcc1, _0x53e307) {
            var _0x2e373b = function(_0xca7be1, _0x40f36e, _0x198ba4, _0x1b278e) {
                return _0x105b9d(_0xca7be1 - 0xf7, _0x198ba4, _0x198ba4 - 0xcb, _0x40f36e - -0x230);
            };
            return _0x54f3a7[_0x2e373b(0x6a, 0xc, 0x60, -0x5c)](_0x38bcc1, _0x53e307);
        }, _0x49cef3[_0x105b9d(0x214, 0x1cb, 0x1fc, 0x202)] = 'direct', _0x49cef3['LTAyj'] = _0x54f3a7[_0x1b8bb5(0x24e, 0x240, 0x1e5, 0x229)], _0x49cef3[_0x1b8bb5(0x2e4, 0x256, 0x27a, 0x2ad)] = function(_0x215fc2, _0x4ceed1) {
            return _0x215fc2(_0x4ceed1);
        }, _0x49cef3[_0x105b9d(0x21d, 0x260, 0x1fe, 0x255)] = _0x54f3a7[_0x1b8bb5(0x27f, 0x2d9, 0x321, 0x2e9)], _0x49cef3['DRPNQ'] = function(_0x556742) {
            var _0xa8f0bc = function(_0x34557d, _0x452bf3, _0x4a3742, _0x3a0ac4) {
                return _0x1b8bb5(_0x34557d - 0x41, _0x3a0ac4, _0x4a3742 - 0xc1, _0x4a3742 - -0x317);
            };
            return _0x54f3a7[_0xa8f0bc(-0x181, -0xe3, -0x136, -0x197)](_0x556742);
        }, _0x49cef3[_0x1b8bb5(0x230, 0x362, 0x275, 0x2c9)] = _0x54f3a7[_0x105b9d(0x260, 0x261, 0x2e5, 0x2f4)], _0x49cef3[_0x105b9d(0x1cf, 0x1ff, 0x255, 0x1fa)] = _0x105b9d(0x206, 0x266, 0x2b7, 0x23d), _0x49cef3[_0x1b8bb5(0x366, 0x36a, 0x376, 0x2f1)] = function(_0x2de192, _0xeddc31) {
            var _0x2639e3 = function(_0x2e0298, _0x572f8a, _0x2ea8a4, _0xb486c1) {
                return _0x105b9d(_0x2e0298 - 0xe0, _0xb486c1, _0x2ea8a4 - 0x188, _0x2e0298 - 0x3b9);
            };
            return _0x54f3a7[_0x2639e3(0x5e4, 0x64b, 0x5b5, 0x672)](_0x2de192, _0xeddc31);
        }, _0x49cef3['Cmqjv'] = '#watch-pla' + _0x1b8bb5(0x2ed, 0x275, 0x264, 0x2b7), _0x49cef3[_0x105b9d(0x1b5, 0x2c7, 0x243, 0x24b)] = function(_0x32a5d6, _0x11787a) {
            var _0x46b717 = function(_0x207717, _0x452187, _0x44ed18, _0x1bd552) {
                return _0x105b9d(_0x207717 - 0x1ad, _0x1bd552, _0x44ed18 - 0x180, _0x207717 - 0x21b);
            };
            return _0x54f3a7[_0x46b717(0x3ed, 0x451, 0x451, 0x34d)](_0x32a5d6, _0x11787a);
        }, _0x49cef3[_0x1b8bb5(0x1d7, 0x2da, 0x2f9, 0x26a)] = function(_0x363c6a, _0x52320d) {
            var _0x28ba76 = function(_0x300f1a, _0x465b96, _0x39126f, _0x3dcc82) {
                return _0x1b8bb5(_0x300f1a - 0x78, _0x3dcc82, _0x39126f - 0x1e8, _0x300f1a - -0x34e);
            };
            return _0x54f3a7[_0x28ba76(-0x17c, -0x1c9, -0xf8, -0x103)](_0x363c6a, _0x52320d);
        }, _0x49cef3[_0x105b9d(0x1f7, 0x298, 0x202, 0x20c)] = function(_0x1c7a13, _0x578f2b) {
            return _0x1c7a13 === _0x578f2b;
        }, _0x49cef3[_0x105b9d(0x2d3, 0x280, 0x246, 0x271)] = _0x54f3a7[_0x105b9d(0x1a6, 0x23d, 0x226, 0x21a)], _0x49cef3['GbzbE'] = _0x54f3a7[_0x1b8bb5(0x28c, 0x332, 0x244, 0x2b5)], _0x49cef3[_0x105b9d(0x205, 0x2db, 0x203, 0x275)] = function(_0x19bade, _0x1a1374) {
            var _0x58f062 = function(_0x40d20d, _0xb9cb9a, _0x318958, _0x226ab0) {
                return _0x105b9d(_0x40d20d - 0xcd, _0x318958, _0x318958 - 0x1f2, _0x226ab0 - -0x18);
            };
            return _0x54f3a7[_0x58f062(0x29f, 0x358, 0x307, 0x2cd)](_0x19bade, _0x1a1374);

Replacing main.js with index.js, Error: ENOENT?

I’m confused with why is this bot now functioning, I think it’s as I don’t have a “index.js” I use “main.js” How can I some how switch from “main.js” to “index.js”?

I’ll add all the main codes that may help you spot an error 😀

Here is the code in “main.js”:

const { Client, Collection, Intents } = require('discord.js');
const client = new Client({ disableMentions: 'everyone', partials: 
['MESSAGE', 'CHANNEL', 'REACTION'], ws: { intents: Intents.ALL } });


client.commands = new Collection();
client.aliases = new Collection();

['command', 'event'].forEach(handler => {
    require(`./handlers/${handler}`)(client);
});


client.login(process.env.BOT_TOKEN);

Error:

internal/fs/utils.js:269
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/home/runner/DwaCraft-Ticket-bot/index.js'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at Object.<anonymous> (/run_dir/interp.js:195:19)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/home/runner/DwaCraft-Ticket-bot/index.js'
}
repl process died unexpectedly: exit status 1
îș§ 

Package.json:

{
    "name": "ticket-bot",
    "version": "1.0.0",
    "description": "A simple ticket bot",
    "main": "main.js",
    "scripts": {
        "test": "echo "Error: no test specified" && exit 1",
        "start": "node main.js"
    },
    "author": "hamoodi",
    "license": "ISC",
    "dependencies": {
        "better": "^0.1.0",
        "cpu-stat": "^2.0.1",
        "discord.js": "^12.5.3",
        "dotenv": "^8.6.0",
        "express": "^4.17.1",
        "moment": "^2.29.1",
        "os": "^0.1.2",
        "sourcebin_js": "0.0.3-ignore"
    }
}

How to do filtering on the basis of checkboxes checked with data coming from API

I want to filter the dealer on the basis of selected rating checkboxes value. When user select the one star ,want the dealers with one star only and if user selects the two star, then dealers with two star and one star. I am storing the checboxes value using useState and getting an array.How to unfiltered data if the checkbox that is selected is unchecked.

 const [dealersData, setDealersData] = useState<Dealer[]>([]);
    const [filteredData, setFilteredData] = useState<Dealer[]>(dealersData);
    const [activeFilter, setactiveFilter] = useState<number[]>([]);
    
    const onFilterChange = (e: React.ChangeEvent<HTMLInputElement>) => {
           console.log(e.target.value);
        if(e.target.checked){
        let data = activeFilter;
        activeFilter.push(Number(e.target.value));
        setactiveFilter(data);
        }else{
            let data=activeFilter.filter((value) =>(Number(e.target.value) != value));
            console.log('inactivedata',data);
            setactiveFilter(data);
            console.log(activeFilter);
        }
        let ratingResult: React.SetStateAction<Dealer[]> = [];
        activeFilter.forEach((item)=>{
            switch(item){
                case 1:
                   ratingResult= dealersData.filter((dealerData) =>{
                   return dealerData.dealer_history.some(dataItem =>(dataItem.rating >= 1 && dataItem.rating < 5));
                 });
                 break;
                 case 2:
                   ratingResult= dealersData.filter((dealerData) =>{
                   return dealerData.dealer_history.some(dataItem =>(dataItem.rating >= 2 && dataItem.rating < 5));
                 });
                 break;
                 case 3:
                    ratingResult= dealersData.filter((dealerData) =>{
                    return dealerData.dealer_history.some(dataItem =>(dataItem.rating == 3 && dataItem.rating < 5));
                  });
                  break;
                  case 4:
                    ratingResult= dealersData.filter((dealerData) =>{
                    return dealerData.dealer_history.some(dataItem =>(dataItem.rating == 4 && dataItem.rating < 5));
                  });
                  break;
                  case 5:
                    ratingResult= dealersData.filter((dealerData) =>{
                    return dealerData.dealer_history.some(dataItem =>(dataItem.rating == 5));
                  });
                  break;
                };
        });
        setFilteredData(ratingResult);
        }
    
      <div><Checkbox color="primary" value="5" onChange={(e) => onFilterChange(e)} /><Rating name="size-small" size="small" value={5} readOnly /></div>
                                            <div><Checkbox color="primary" value="4" onChange={(e) => onFilterChange(e)} /><Rating name="size-small" size="small" value={4} readOnly /></div>
                                            <div><Checkbox color="primary" value="3" onChange={(e) => onFilterChange(e)} /><Rating name="size-small" size="small" value={3} readOnly /></div>
                                            <div><Checkbox color="primary" value="2" onChange={(e) => onFilterChange(e)} /><Rating name="size-small" size="small" value={2} readOnly /></div>
                                            <div><Checkbox color="primary" value="1" onChange={(e) => onFilterChange(e)} /><Rating name="size-small" size="small" value={1} readOnly /></div>
    
    export interface Dealer{
        dealer_id:number,
        name:string,
        mobile:number,
        email:string,
        gst_no:string,
        locality:string,
        city:string,
        state:string,
        pincode:string,
        vehicle_type_id:number,
        Vehicletype:{
            vehicle_type:string
        };
        Services:[
            {
                discription:string,
                cost:number
            }
        ],
        dealer_history:[
            {
                rating:number,
                comments:string
            }
        ]
    }

expression not in aggregate or GROUP BY columns

I have a table that contains the following columns:
ProductID, ProductName, Price, CategoryID.

The goal is to print all the details (ProductID, ProductName, Price, and Category) about the most expensive product.

I executed the following query:

str = "SELECT ProductID, ProductName, MAX(Price) AS MaxPrice, CategoryID FROM Products;";   

However, the exception mentioned in the title appears, and I do not find a reason for the exception appearance. I searched for explanations on the following links:

I have also read and practiced in SQL Lesson 10: Queries with aggregates (Pt. 1)
According to my checking in SQLBolt, the way I wrote the query is acceptable.

After reading and practicing, I still do not understand why I need to use the GROUP BY here. It’s not that I need to present the maximum price of each group…

Thank you very much beforehand!