2023-12-11 17:47:16 +08:00
|
|
|
import React from 'react';
|
2023-12-01 11:52:37 +08:00
|
|
|
import {DragDropContext} from "@hello-pangea/dnd";
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
import {Layout} from "./Layout.jsx";
|
|
|
|
import {Backlog} from "./Backlog.jsx";
|
|
|
|
import {OrderPanel} from "./OrderPanel.jsx";
|
2023-12-11 17:47:16 +08:00
|
|
|
import {useShopStore} from "./shop_store";
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that render the entire shop
|
|
|
|
*/
|
|
|
|
|
2023-12-11 17:05:35 +08:00
|
|
|
export function Shop() {
|
2023-12-11 17:47:16 +08:00
|
|
|
const {addCardFromBacklog, moveCard, deleteCard} = useShopStore(state => ({
|
|
|
|
addCardFromBacklog: state.addCardFromBacklog,
|
|
|
|
moveCard: state.moveCard,
|
|
|
|
deleteCard: state.deleteCard
|
|
|
|
}));
|
|
|
|
const handleOnDragEnd = (drop_result, provided) => {
|
|
|
|
console.log(drop_result, provided)
|
|
|
|
//{
|
|
|
|
// "draggableId": "42dc17e9-9e75-45ee-ad27-2233b6f07a5e",
|
|
|
|
// "type": "DEFAULT",
|
|
|
|
// "source": {
|
|
|
|
// "index": 17,
|
|
|
|
// "droppableId": "backlog"
|
|
|
|
// },
|
|
|
|
// "reason": "DROP",
|
|
|
|
// "mode": "FLUID",
|
|
|
|
// "destination": {
|
|
|
|
// "droppableId": "crate0",
|
|
|
|
// "index": 0
|
|
|
|
// },
|
|
|
|
// "combine": null
|
|
|
|
// }
|
|
|
|
if (drop_result.source.droppableId === "backlog")
|
|
|
|
addCardFromBacklog(drop_result.destination.droppableId, drop_result.source.index, drop_result.destination.index);
|
|
|
|
else if(drop_result.destination.droppableId === "backlog")
|
|
|
|
deleteCard(drop_result.destination.droppableId, drop_result.destination.index);
|
|
|
|
else
|
|
|
|
moveCard(drop_result.source.droppableId, drop_result.source.index, drop_result.destination.droppableId, drop_result.destination.index)
|
2023-11-30 17:26:17 +08:00
|
|
|
}
|
|
|
|
|
2023-12-11 17:05:35 +08:00
|
|
|
return (
|
2023-12-11 17:47:16 +08:00
|
|
|
<DragDropContext onDragEnd={handleOnDragEnd}>
|
2023-12-11 17:05:35 +08:00
|
|
|
<Layout
|
|
|
|
aside={
|
|
|
|
<Backlog/>
|
|
|
|
}
|
|
|
|
main={(
|
|
|
|
<OrderPanel
|
|
|
|
title="Order hardware"
|
|
|
|
description={(<p className="description">Drag and drop the cards you want into the crate below to see how the combination would look like. Setup card's configuration by tapping at the top of the card, most of the options can be modified after shipment. If you have any issues with this ordering system, or if you need other configurations, email us directly anytime at <a href="mailto:sales@m-labs.hk">sales@m-labs.hk</a>. The price is estimated and must be confirmed by a quote.</p>)}
|
|
|
|
/>
|
|
|
|
)}>
|
|
|
|
</Layout>
|
|
|
|
</DragDropContext>
|
|
|
|
);
|
|
|
|
|
2023-11-30 17:26:17 +08:00
|
|
|
}
|