-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
257 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Backend/Frontend/creative/src/component/sign-component/SignDetail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from "react" | ||
import styled from "styled-components" | ||
import useSignForm from "../../hook/useSignForm.tsx"; | ||
import SignDetailGraph from "./SignDetailGraph.tsx"; | ||
import SignDetailInfo from "./SignDetailInfo.tsx"; | ||
|
||
const StyledSignDetail = styled.main` | ||
width: 90%; | ||
height: 80%; | ||
display: flex; | ||
flex-direction: column; | ||
font-family: "Pretendard-Regular"; | ||
font-style: normal; | ||
.detail{ | ||
margin-top: 1.2em; | ||
padding-bottom: 1em; | ||
border-bottom: solid 1px; | ||
} | ||
` | ||
|
||
|
||
//그래프에 필요한것 1. type 2. 시간을 준다. | ||
const SignDetail = () => { | ||
const arr = useSignForm(); | ||
return ( | ||
<StyledSignDetail> | ||
{arr[0].length!==0&&arr[0].map((ele:any)=>{ | ||
return ( | ||
<div className="detail"> | ||
<span>{ele.info.totalTime}분</span> | ||
<SignDetailGraph graph={ele}/> | ||
<SignDetailInfo graph={ele}/> | ||
</div> | ||
) | ||
})} | ||
</StyledSignDetail> | ||
) | ||
} | ||
|
||
|
||
export default SignDetail; |
61 changes: 61 additions & 0 deletions
61
Backend/Frontend/creative/src/component/sign-component/SignDetailGraph.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
|
||
|
||
interface graphItem { | ||
label:string, | ||
portion:number, | ||
sum:number | ||
} | ||
|
||
const StyleSignDetailGraph = styled.div` | ||
display: flex; | ||
width:100%; | ||
height: 3vh; | ||
background-color: #D9D9D9; | ||
justify-content: space-between; | ||
border-radius: 10px; | ||
` | ||
const StyleSignDetailGraphLi = styled.div<graphItem>` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100%; | ||
min-width: ${props => ((props.portion/props.sum)*100)}%; | ||
background-color: ${props=>(props.label)}; | ||
border-radius: 10px; | ||
margin-right: 1%; | ||
color:#F0F0F0; | ||
font-family: "Pretendard-Regular"; | ||
font-style: normal; | ||
` | ||
|
||
const SignDetailGraph = ({graph}:any) => { | ||
const idColor = ["#0052A4", "#00A84D", "#EF7C1C", "#00A5DE", "#996CAC", "#CD7C2F", "#747F00", "#E6186C","#BDB092"]; | ||
const busColor = "#70EB37" | ||
return ( | ||
<StyleSignDetailGraph> | ||
{graph.subPath.map((ele:any,index:number)=>{ | ||
if(ele.sectionTime!==0){ | ||
let color="#D9D9D9"; | ||
if(ele.trafficType===1) | ||
color = idColor[ele.lane[0].subwayCode-1] | ||
else if(ele.trafficType===2) | ||
color = busColor; | ||
return <StyleSignDetailGraphLi key={index} label={color} sum={graph.info.totalTime} portion={ele.sectionTime}> | ||
{ele.sectionTime}분 | ||
</StyleSignDetailGraphLi> | ||
} | ||
})} | ||
</StyleSignDetailGraph> | ||
) | ||
} | ||
|
||
export default SignDetailGraph; | ||
|
||
/* | ||
time:ele.info.totalTime, | ||
type:ele.pathType, | ||
*/ |
39 changes: 39 additions & 0 deletions
39
Backend/Frontend/creative/src/component/sign-component/SignDetailInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
const StyledSignDetailInfo = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
` | ||
|
||
const StyledSignDetailInfoLi = styled.div` | ||
display: flex; | ||
margin:1em 0; | ||
.SignDetail{ | ||
margin-left: 1em; | ||
} | ||
` | ||
|
||
const SignDetailInfo = ({graph}:any) => { | ||
|
||
return ( | ||
<StyledSignDetailInfo> | ||
{graph.subPath.map((ele:any)=>{ | ||
if(ele.trafficType!==3){ | ||
let name = ele.lane[0].busNo?ele.lane[0].busNo:ele.lane[0].name | ||
return ( | ||
<StyledSignDetailInfoLi> | ||
<span>{name}</span> | ||
<div className="SignDetail"> | ||
<span>{ele.endName} - </span> | ||
<span>{ele.startName}</span> | ||
</div> | ||
</StyledSignDetailInfoLi> | ||
) | ||
} | ||
})} | ||
</StyledSignDetailInfo> | ||
) | ||
} | ||
|
||
export default SignDetailInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
Backend/Frontend/creative/src/component/sign-component/signUtil.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from "react" | ||
import { api } from "../auth/Api.ts" | ||
|
||
export const submitStartAndEnd = () =>{ | ||
window.location.href = `/#/sign/detail` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React,{useEffect,useState} from "react" | ||
import { useSelector } from "react-redux"; | ||
import {wrapPromise} from "../promise/warmPromise.ts" | ||
import { api } from "../component/auth/Api.ts"; | ||
import { RootState } from "../store/index"; | ||
|
||
|
||
const useSignForm = () => { | ||
const [signArr,SetSignArr] = useState<any[]>([""]); | ||
let start = useSelector((state:RootState)=>state.sign.startPostion); | ||
let end = useSelector((state:RootState)=>state.sign.endPostion); | ||
useEffect(() => { | ||
const getArr = async () => { | ||
await api.get(`/navigation/${start.tmY}/${start.tmX}/${end.tmY}/${end.tmX}/busNsub`) | ||
.then(res=>{ | ||
const graphInfo = res.data.map((ele:any)=>{ | ||
return { | ||
time:ele.info.totalTime, | ||
type:ele.pathType, | ||
} | ||
}) | ||
const subwayLi = res.data.filter((ele:any)=>( | ||
ele.pathType===3 | ||
)) | ||
console.log(res.data) | ||
SetSignArr([res.data,subwayLi]) | ||
return res.data | ||
}) | ||
} | ||
getArr(); | ||
},[start,end]) | ||
return signArr; | ||
} | ||
|
||
|
||
|
||
export default useSignForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from "react"; | ||
import classes from "./SignDetailPage.module.css" | ||
import Header from "../component/header/Header.tsx" | ||
import MenuBar from "../component/menu/MenuBar.tsx"; | ||
import SignDetail from "../component/sign-component/SignDetail.tsx"; | ||
|
||
|
||
const SignDetailPage = () => { | ||
return ( | ||
<div className={classes.signpage}> | ||
<Header/> | ||
<SignDetail/> | ||
<MenuBar/> | ||
</div> | ||
) | ||
} | ||
|
||
export default SignDetailPage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.signpage { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export const wrapPromise = (promise:Promise<any>) => { | ||
//promise를 던지기 위한 함수 | ||
let status = "pending"; | ||
let result:any; | ||
let suspend = promise.then( | ||
(res) => { | ||
status = "success"; | ||
result = res; | ||
}, | ||
(err) => { | ||
status = "error"; | ||
result = err; | ||
} | ||
); | ||
return { | ||
read() { | ||
if (status === "pending") { | ||
throw suspend; | ||
} else if (status === "error") { | ||
throw result; | ||
} else if (status === "success") { | ||
return result; | ||
} | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters