Skip to content

Conversation

axelvuillaume
Copy link

No description provided.

Comment on lines +21 to +32
// components/OrderStatus.jsx
const OrderStatus = ({ status }) => {
let statusClass = "bg-blue-100 text-blue-800";
if (status === "completed") statusClass = "bg-green-100 text-green-800";
if (status === "processing") statusClass = "bg-yellow-100 text-yellow-800";
return( <span
className={`px-2 inline-flex text-xs leading-5 font-semibold rounded-full
${statusClass}`}
>
{status}
</span>)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Souvent on met les component enfant en dessous du parent


if (!response.ok) {
throw new Error(data.message || 'Failed to send reminder');
const {ok, data} = await api.post(`/api/orders/${orderId}/send-reminder`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orderId need to be on the body part not as an id

Comment on lines +210 to +212
const updateOrders = (newOrders) => {
setOrders(newOrders);
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autant faire passer directement le setOrders dans les params

Comment on lines +163 to +164
const {ok, data} = await api.post("/orders");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comme on veut récupérer les orders,
const status = filter
c'est un post("/orders/search", {
status : filter
})

Comment on lines +193 to +199
const filteredOrders = orders.filter((order) => {
if (filter === "all") return true;
if (filter === "completed") return order.status === "completed";
if (filter === "processing") return order.status === "processing";
if (filter === "shipped") return order.status === "shipped";
return true;
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bannir

Comment on lines +201 to +208
const sortedOrders = [...filteredOrders].sort((a, b) => {
if (sortBy === "date") {
return new Date(b.date) - new Date(a.date);
} else if (sortBy === "total") {
return b.total - a.total;
}
return 0;
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Côté back aussi

Comment on lines +32 to +45
const fetchStats = async () => {
try {
setLoading(true);
const { data, ok } = await api.get('/dashboard/stats');

if (!ok) return toast.error("Failed to fetch stats");

setStats(data);
setLoading(false);
} catch (err) {
setError(err.message);
setLoading(false);
}
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ici tu peux aussi faire un
finally {
setLoading(false)
}

en dessous du catch, ça te permet de mettre qu'une seule fois le setLoading.
(c'est du chipotage)

Comment on lines +104 to +106
const { data, ok } = await api.put(`/notifications/search`, {
id: notificationId,
read : true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ici c'est un put donc y'a forcément un id dans le chemin (cf. workshop) donc pas besoin de mettre l'id dans le body

Comment on lines +289 to +318
const NotificationItem = ({ notifications, markAsRead }) => {
return (
<>
{notifications.map(notification => (
<div
key={notification.id}
className={`p-4 border-l-4 ${
notification.read ? 'border-gray-300 bg-gray-50' : 'border-blue-500 bg-blue-50'
}`}
>
<div className="flex justify-between">
<p className={`text-sm ${notification.read ? 'text-gray-600' : 'text-gray-900 font-semibold'}`}>
{notification.message}
</p>
{!notification.read && (
<button
className="text-blue-500 text-xs hover:text-blue-700"
onClick={() => markAsRead(notification.id)}
>
Mark as read
</button>
)}
</div>
<p className="text-xs text-gray-500 mt-1">
{new Date(notification.date).toLocaleString()}
</p>
</div>
))}
</>
)};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

la t'as un composant avec aucun logique que du code html donc inutile

Comment on lines +321 to +334
const StatsCard = ({ icon, title, value, color }) => {
return (
<div className="bg-white rounded-lg shadow p-6">
<div className="flex items-center">
<div className={`p-3 rounded-full ${color} mr-4`}>
{icon}
</div>
<div>
<p className="text-gray-500 text-sm">{title}</p>
<p className="text-2xl font-bold">{value}</p>
</div>
</div>
</div>
)};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

même chose ici aucune logique que du code html donc inutile

Comment on lines 74 to 76
createdBy: {
user_id: user._id,
name: user.name,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

le createdBy dans le model dans mes souvenirs il a qu'un _id.
Si t'as pas changer le model tu peux donc pas ajouter ça comme ça

Comment on lines +117 to -137
// /comments est dans un query ducoup ?
router.put('/:id', async (req, res) => {
try {
const { text, user_id } = req.body;
const {user_id} = req.body;

const task = await Task.findById(req.params.id);
if (!task) {
return res.status(404).json({ error: 'Task not found' });
return res.status(404).send({ ok: false, code: "TASK_NOT_FOUND" });
}

const user = await User.findById(user_id);
if (!user) {
return res.status(404).json({ error: 'User not found' });
return res.status(404).send({ ok: false, code: "USER_NOT_FOUND" });
}
const comment = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas besoin d'un deuxième put ducoup ici

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants