saw-zer0 / HRMS

0 stars 0 forks source link

clock in error in attendance #6

Closed snehaos closed 5 months ago

snehaos commented 5 months ago

A bug was found in "clock-in" of attendance even if there is error in database it sends a successful message. The clock in logic `server.post("/clock-in", async (req, res) => { try { const currentTime = new Date().toLocaleString('en-US', { timeZone: 'Asia/Kathmandu' });

    const query = "INSERT INTO attendance (clock_in) VALUES ($1)";
    const values = [currentTime];

    await client.query(query, values);
    console.log("Clock-in time inserted successfully");

    res.sendStatus(200);
} catch (error) {
    console.error("Error inserting clock-in time:", error);

    res.sendStatus(500);
}

});`

Saina2105 commented 5 months ago

Please try this code

server.post("/clock-in", async (req, res) => { try {

        const currentTime = new Date().toLocaleString('en-US', { timeZone: 'Asia/Kathmandu' });

        const query = "INSERT INTO attendance (clock_in) VALUES ($1)";
        const values = [currentTime];

        await client.query(query, values);
        console.log("Clock-in time inserted successfully");

        res.sendStatus(200);
    } catch (error) {
        console.error("Error inserting clock-in time:", error);
        res.sendStatus(500);
    }
});