2023-12-12 16:09:29 +08:00
|
|
|
import React, {useEffect} from 'react';
|
2023-12-01 11:52:37 +08:00
|
|
|
import {DragDropContext} from "@hello-pangea/dnd";
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
|
2023-12-12 18:21:09 +08:00
|
|
|
import {Layout} from "./Layout";
|
|
|
|
import {Backlog} from "./Backlog";
|
|
|
|
import {OrderPanel} from "./OrderPanel";
|
2023-12-11 17:47:16 +08:00
|
|
|
import {useShopStore} from "./shop_store";
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
/**
|
2023-12-13 12:39:15 +08:00
|
|
|
* Component that renders the entire shop
|
2023-11-30 17:26:17 +08:00
|
|
|
*/
|
|
|
|
|
2023-12-11 17:05:35 +08:00
|
|
|
export function Shop() {
|
2023-12-12 16:09:29 +08:00
|
|
|
const {addCardFromBacklog, moveCard, deleteCard, cardIndexById} = useShopStore(state => ({
|
2023-12-11 17:47:16 +08:00
|
|
|
addCardFromBacklog: state.addCardFromBacklog,
|
|
|
|
moveCard: state.moveCard,
|
2023-12-12 16:09:29 +08:00
|
|
|
deleteCard: state.deleteCard,
|
|
|
|
cardIndexById: state.cardIndexById
|
2023-12-11 17:47:16 +08:00
|
|
|
}));
|
2023-12-13 12:39:15 +08:00
|
|
|
const handleOnDragEnd = (drop_result, _provided) => {
|
2023-12-11 17:47:16 +08:00
|
|
|
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-12 16:09:29 +08:00
|
|
|
useEffect(() => {
|
2023-12-13 12:39:15 +08:00
|
|
|
addCardFromBacklog(null, [cardIndexById("eem_pwr_mod"), cardIndexById("kasli")], -1);
|
2023-12-12 16:09:29 +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
|
|
|
}
|