-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] 홈 화면 API 연결, 주행 중 Toast UI (#23)
* feat: 홈 화면 코멘트 API 연결 * feat: 주행 중 알림 Toast UI * 홈 화면 API 추가 * 홈 화면 API 연결
- Loading branch information
Showing
9 changed files
with
180 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { HomeRecentType, LatestScoresType } from "src/types/home"; | ||
import { axiosInstance } from "./instance"; | ||
|
||
//최근 주행 점수 | ||
export const homeScoreAPI = async () => { | ||
try { | ||
const response = await axiosInstance.get("/home/score"); | ||
return response.data; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
||
export const homeLatestScoreAPI = async () => { | ||
try { | ||
const response = await axiosInstance.get("/home/latestScores"); | ||
return response.data as LatestScoresType; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
||
//최근 주행 피드백 | ||
export const homeFeedbackAPI = async () => { | ||
try { | ||
const response = await axiosInstance.get("/home/feedback"); | ||
return response.data; | ||
} catch { | ||
return null; | ||
} | ||
}; | ||
|
||
//주의해야 할 운전 습관 | ||
export const homeRecentsAPI = async () => { | ||
try { | ||
const response = await axiosInstance.get("/home/recentRisks"); | ||
return response.data as HomeRecentType; | ||
} catch { | ||
return null; | ||
} | ||
}; |
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { useEffect } from "react"; | ||
import styled from "styled-components"; | ||
import alarm_sound from "@assets/sound/alram.mp3"; | ||
|
||
interface ToastProps { | ||
message: string; | ||
setToast: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
export const Toast = ({ message, setToast }: ToastProps) => { | ||
useEffect(() => { | ||
const timer = setTimeout(() => { | ||
setToast(false); | ||
}, 3000); | ||
return () => { | ||
clearTimeout(timer); | ||
}; | ||
}, []); | ||
return ( | ||
<ToastContainer> | ||
<audio src={alarm_sound} autoPlay /> | ||
{message} | ||
</ToastContainer> | ||
); | ||
}; | ||
|
||
const ToastContainer = styled.div` | ||
width: 280px; | ||
height: 42px; | ||
padding: 0 12px; | ||
border-radius: 4px; | ||
background-color: #f86d60; | ||
color: white; | ||
font-family: "Pretendard"; | ||
font-weight: 500; | ||
line-height: 42px; | ||
position: absolute; | ||
left: 10px; | ||
top: 40px; | ||
animation: fadeout 2s ease-in-out; | ||
opacity: 0; | ||
@keyframes fadeout { | ||
0% { | ||
opacity: 0; | ||
} | ||
25% { | ||
opacity: 1; | ||
} | ||
75% { | ||
opacity: 1; | ||
} | ||
100% { | ||
opacity: 0; | ||
} | ||
} | ||
`; |
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,13 @@ | ||
import { ScenarioType } from "./driving"; | ||
|
||
interface ScoreType { | ||
reportId: number; | ||
score: number; | ||
} | ||
export interface LatestScoresType { | ||
latestScores: ScoreType[]; | ||
} | ||
|
||
export interface HomeRecentType { | ||
recentRisks: ScenarioType[]; | ||
} |
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