Skip to content

Commit

Permalink
refactor: main 페이지까지 연결
Browse files Browse the repository at this point in the history
(dispenserId는 하드코딩되어있음)
  • Loading branch information
Charmull committed Nov 11, 2022
1 parent 88517cd commit 3f4ef29
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
7 changes: 3 additions & 4 deletions src/main/components/RegisteredUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ const RegisteredUser = ({
drinkerName,
detail,
}: {
glassId: number;
glassId: string;
totalCapacity: number;
drinkerName: string;
detail: string;
}) => {
const id = String(glassId);
return (
<div className="card shadow-md">
<div className="card-body flex flex-row p-3">
Expand All @@ -29,7 +28,7 @@ const RegisteredUser = ({
</div>
<div className="card-action">
<label
htmlFor={`modal-${id}`}
htmlFor={`modal-${glassId}`}
className="btn modal-button btn-secondary ml-1 rounded-lg w-14 h-14 shrink-0"
>
<BiEditAlt className="text-2xl" />
Expand All @@ -38,7 +37,7 @@ const RegisteredUser = ({
</div>

<MainEdit
id={id}
id={glassId}
totalCapacity={totalCapacity}
drinkerName={drinkerName}
detail={detail}
Expand Down
10 changes: 4 additions & 6 deletions src/main/hooks/useMainViewModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ const useMainViewModel = () => {
console.log(msg);
};
ws.current.onmessage = (msg: MessageEvent) => {
console.log(msg);
switch (msg.data) {
case "술자리가 시작되었습니다!":
// native 연결
console.log("페이지 변화");
navigate("/main");
const data = JSON.parse(msg.data);
switch (data.eventType) {
case "change":
navigate("/drink");
break;
case "dispenser01에 술잔이 등록되었습니다":
refetch();
Expand Down
7 changes: 4 additions & 3 deletions src/main/interfaces/drinker.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
interface Drinker {
glassId: number;
totalCapacity: number;
currentDrink: number;
glassId: string;
drinkerName: string;
detail: string;
totalCapacity: number;
currentDrink: number;
lastDrinkTimeStamp: number;
dispenserId: string;
}

export default Drinker;
2 changes: 1 addition & 1 deletion src/mainEdit/hooks/useMainEditModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const useMainEditModel = ({
const { data: updateData } = await customAxios.patch(
`/glass/${id}`,
{
totalCapacity: inputCapacity,
drinkerName: inputName,
totalCapacity: inputCapacity,
detail: inputDetail,
},
{
Expand Down

0 comments on commit 3f4ef29

Please sign in to comment.