2023-12-13 12:39:15 +08:00
|
|
|
import {useShopStore} from "./shop_store";
|
|
|
|
import {useClickAway} from "./options/useClickAway";
|
|
|
|
import {Modal} from "react-bootstrap";
|
|
|
|
import {Validation} from "./validate";
|
|
|
|
import React from "react";
|
2023-12-14 16:29:32 +08:00
|
|
|
// #!render_count
|
2023-12-14 16:09:33 +08:00
|
|
|
import {useRenderCount} from "@uidotdev/usehooks";
|
2023-12-13 12:39:15 +08:00
|
|
|
|
|
|
|
export function RFQFeedback() {
|
2023-12-14 16:29:32 +08:00
|
|
|
// #!render_count
|
2023-12-14 16:09:33 +08:00
|
|
|
const renderCount = useRenderCount();
|
|
|
|
|
|
|
|
const closeRFQ = useShopStore((state) => state.closeRFQFeedback);
|
|
|
|
const shouldShow = useShopStore((state) => state.shouldShowRFQFeedback);
|
|
|
|
const status = useShopStore((state) => state.processingResult);
|
|
|
|
|
2023-12-14 16:29:32 +08:00
|
|
|
// #!render_count
|
2023-12-14 16:09:33 +08:00
|
|
|
console.log("RFQFeedback renders: ", renderCount)
|
2023-12-13 12:39:15 +08:00
|
|
|
|
|
|
|
const ref = useClickAway((e) => {
|
|
|
|
if (e.type === "mousedown") // ignore touchstart
|
|
|
|
closeRFQ()
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal show={shouldShow} animation={true} centered>
|
2023-12-14 14:17:18 +08:00
|
|
|
<Modal.Body ref={ref} className="rfqFeedback">
|
2023-12-13 12:39:15 +08:00
|
|
|
<div className="d-flex">
|
|
|
|
<div>
|
|
|
|
{status.status === Validation.OK ?
|
|
|
|
<img width="30px" src="/images/shop/icon-done.svg" alt="close"/>
|
|
|
|
: <img width="30px" src="/images/shop/icon-warning.svg" alt="close"/>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
<div style={{'padding': '0 .5em'}}>
|
|
|
|
{status.message}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Modal.Body>
|
|
|
|
</Modal>
|
|
|
|
)
|
|
|
|
}
|