Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: 오더 기본값 고정되는 부분 수정 #44

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pages/Home/Receipt/StatusReceipt/PendingReceipt.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ const PendingReceipt = ({ orderProps, setStatus, setOrder, fetchData }) => {
{orderProps?.foodies?.map((e, i) => (
<React.Fragment key={i}>
<div className="receiptTextBox">
<span className="receipt-FoodName">{e.name}</span>
<span className="receipt-text">{e.count}</span>
<span className="receipt-FoodName">{e.name}</span>
<span className="receipt-FoodName">{e.count}</span>
</div>
<div className="receiptOption">
{e.options.map((option) => (
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Home/StatusHome/Complete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const Complete = ({ orderInfo }) => {
setStatusSelect("null");
setOrderSelect(null);
}
}, [orderInfo, setOrderSelect, setStatusSelect, sortedOrders]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<div className="Order-wrapper">
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Home/StatusHome/Progress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const Progress = ({ orderInfo }) => {
setStatusSelect("null");
setOrderSelect(null);
}
}, [orderInfo, setOrderSelect, setStatusSelect, sortedOrders]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const onClickHandler = (selectedOrder) => {
setOrderSelect(selectedOrder);
Expand Down
65 changes: 46 additions & 19 deletions src/pages/Home/StatusHome/Wait.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ const Wait = ({ orderInfo }) => {
const [selectedOrderId, setSelectedOrderId] = useState(null);
const [isRecentFirst, setIsRecentFirst] = useRecoilState(isRecentFirstState);

useEffect(() => {
const isAudioPlay = () => {
if (playSound && orderInfo?.orders?.length !== null) {
AudioPlayer(); // 소리 재생
console.log("소리 재생");
}
};
isAudioPlay();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

/*
const sortedOrders = isRecentFirst
? [...(orderInfo?.orders || [])].sort((prev, cur) => {
Expand All @@ -28,24 +39,6 @@ const Wait = ({ orderInfo }) => {
? [...(orderInfo?.orders || [])].reverse()
: orderInfo?.orders;

useEffect(() => {
const firstOrder = sortedOrders?.length > 0 ? sortedOrders[0] : null;
setOrderSelect(firstOrder);
setSelectedOrderId(firstOrder?.idx || null);

if (firstOrder !== null) {
setStatusSelect("pending");
} else {
setStatusSelect("null");
setOrderSelect(null);
}

if (playSound && orderInfo?.orders?.length !== null) {
AudioPlayer(); // 소리 재생
console.log("소리 재생");
}
}, [orderInfo, playSound, setOrderSelect, setStatusSelect, sortedOrders]);

const onClickHandler = (selectedOrder) => {
setOrderSelect(selectedOrder);
setSelectedOrderId(selectedOrder?.idx && selectedOrder?.idx);
Expand All @@ -60,6 +53,41 @@ const Wait = ({ orderInfo }) => {
}
};

// useEffect(() => {
// const firstOrder = sortedOrders?.length > 0 ? sortedOrders[0] : null;

// if (firstOrder !== null) {
// setStatusSelect("pending");
// setOrderSelect(firstOrder);
// setSelectedOrderId(firstOrder.idx);
// } else {
// setStatusSelect("null");
// setOrderSelect(null);
// setSelectedOrderId(null);
// }

// // eslint-disable-next-line react-hooks/exhaustive-deps
// }, [sortedOrders]);

useEffect(() => {
const sortedOrders = isRecentFirst
? [...(orderInfo?.orders || [])].reverse()
: orderInfo?.orders;
const firstOrder = sortedOrders?.length > 0 ? sortedOrders[0] : null;

if (firstOrder !== null) {
setStatusSelect("pending");
setOrderSelect(firstOrder);
setSelectedOrderId(firstOrder.idx);
} else {
setStatusSelect("null");
setOrderSelect(null);
setSelectedOrderId(null);
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<div className="Order-wrapper">
<div className="Order-title__wrapper">
Expand Down Expand Up @@ -95,7 +123,6 @@ const Wait = ({ orderInfo }) => {
/>
))}
</div>
{/* <button onClick={Player}>Play Audio</button> */}
</div>
);
};
Expand Down