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#7 jisoo/alarm #17

Open
wants to merge 97 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
8d3d0e4
[ fix ] eslint 문제 해결
seojisoosoo Jun 29, 2023
28373c4
[ feat ] react-calendar로 달력 띄우기 성공
seojisoosoo Jun 30, 2023
41fe24e
[ feat ] 달력 데이터 상수 파일 추가
seojisoosoo Jul 1, 2023
b6bf860
[ fix ] 허스키 삭제
seojisoosoo Jul 1, 2023
0e8f660
[ feat ] 달력 뼈대 구현
seojisoosoo Jul 1, 2023
7ba45f1
[ etc ] 상수 파일 수정
seojisoosoo Jul 1, 2023
d8520d1
[ feat ] 상수 파일 데이터 달력에 띄우기 성공
seojisoosoo Jul 1, 2023
6d9bc03
[ design ] 일정 박스 스타일링
seojisoosoo Jul 1, 2023
b02ec96
[ etc ] 불필요 코드 삭제
seojisoosoo Jul 1, 2023
9e80de0
[ design ] 캘린더 제목 스타일링
seojisoosoo Jul 1, 2023
2e1eeb7
[ fix ] theme 에러 수정
seojisoosoo Jul 1, 2023
17783d0
[ design ] 타일 크기 조정
seojisoosoo Jul 1, 2023
d8f0cef
[ feat ] 달력 데이터 타입과 내용 수정
seojisoosoo Jul 1, 2023
c17127c
[ etc ] 상수 파일 오류 수정
seojisoosoo Jul 1, 2023
f2fba41
[ etc ] 상수 파일 오류 수정
seojisoosoo Jul 1, 2023
aeb619c
[ etc ] 상수 파일 오류 수정
seojisoosoo Jul 1, 2023
b269711
[ etc ] 불필요 라벨 삭제
seojisoosoo Jul 1, 2023
f47728d
[ etc ] any 타입 삭제
seojisoosoo Jul 1, 2023
009b49b
[ reverse ] any 타입되돌리기
seojisoosoo Jul 1, 2023
c56d3cc
[ etc ] 불필요 코드 삭제
seojisoosoo Jul 1, 2023
6c84bb3
[ etc ] 변수명 변경
seojisoosoo Jul 1, 2023
c199cb4
[ feat ] 클릭된 날짜 보여지도록 값 가져오기
seojisoosoo Jul 2, 2023
934d685
[ feat ] 모달 창 구현
seojisoosoo Jul 2, 2023
ebed86e
[ feat ] 모달 개폐 구현
seojisoosoo Jul 2, 2023
46ca26e
[ style ] 모달 개폐 함수 두 개로 분리
seojisoosoo Jul 2, 2023
8f0b151
[ design ] 모달 스타일링
seojisoosoo Jul 2, 2023
f4dbe23
[ etc ] 패키지 설치
seojisoosoo Jul 3, 2023
2360935
[ design ] 리액트 타임피커 스타일링
seojisoosoo Jul 3, 2023
4490e2e
[ feat ] 시작과 끝시간 구현
seojisoosoo Jul 3, 2023
70e202f
[ design ] 타임피커 모달 flex로 위치 수정
seojisoosoo Jul 3, 2023
197258e
[ feat ] AM, PM인지에 따라 오전, 오후 다르게 표기되도록 구현
seojisoosoo Jul 3, 2023
0e7a1f4
[ etc ] 불필요 코드 삭제 및 파일 생성
seojisoosoo Jul 3, 2023
0383644
[ design ] 취소 확인 영어 한국어로 변경
seojisoosoo Jul 3, 2023
56a1794
[ feat ] 확인 버튼 구현
seojisoosoo Jul 3, 2023
2566d3a
[ feat ] 학생 이름 입력 버튼 구현
seojisoosoo Jul 3, 2023
d870e24
[ feat ] 캘린더 데이터 변경
seojisoosoo Jul 3, 2023
70b432c
[ feat ] 변경된 데이터로 달력 데이터 반영
seojisoosoo Jul 3, 2023
0a8f84b
[ etc ] 불필요 코드 삭제
seojisoosoo Jul 3, 2023
2d4a356
[ feat ] 입력한 시간대로 데이터 추가되기 구현 성공
seojisoosoo Jul 3, 2023
47e9afc
[ style ] 날짜 변환되는 방식 변경
seojisoosoo Jul 3, 2023
f74e5e7
[ design ] 기타 스타일링 수정
seojisoosoo Jul 3, 2023
7514965
[ style ] 구조분해 할당 삭제
seojisoosoo Jul 3, 2023
a22e758
[ refactor ] 타입 설정
seojisoosoo Jul 3, 2023
bb4e834
[ etc ] 타입 수정
seojisoosoo Jul 3, 2023
6e2a1fa
[ feat ] 출석 버튼 구현
seojisoosoo Jul 3, 2023
82a98f0
[ assets ] 튜티스 이미지 추가
seojisoosoo Jul 6, 2023
4377cd0
[ feat ] FCM 연결
seojisoosoo Jul 6, 2023
7003ad4
[ feat ] 알림 vapidKey 포함 api 임시 구현
seojisoosoo Jul 6, 2023
392bb07
[ feat ] 알림 허용 로직 구현
seojisoosoo Jul 6, 2023
80ff87e
[ feat ] 알림 pull 로직 구현
seojisoosoo Jul 6, 2023
6b5923a
[ revert ] 새로운 마음으로 시작
seojisoosoo Jul 7, 2023
d5f46e0
[ feat ] 알림 시도
seojisoosoo Jul 7, 2023
6cba057
[ fix ] 컴포넌트 open 안 한 문제 해결
seojisoosoo Jul 7, 2023
79784d5
[ fix ] tsconfig 임시 수정
seojisoosoo Jul 7, 2023
39db1d2
[ revert ] tsconfig 되돌리기
seojisoosoo Jul 7, 2023
c9c326f
[ etc ] 임시로 캘린더 지우기
seojisoosoo Jul 7, 2023
04d69c4
[ design ] 버튼 임시 스타일링
seojisoosoo Jul 7, 2023
330f68e
[ feat ] manifest 파일 추가
seojisoosoo Jul 7, 2023
133b402
[ etc ] 수정 중
seojisoosoo Jul 7, 2023
b324b84
[ feat ] messaging 파일 수정
seojisoosoo Jul 7, 2023
8d8359e
[ etc ] 콘솔 메시지 수정
seojisoosoo Jul 7, 2023
52d69ae
[ etc ] push이벤트 수정
seojisoosoo Jul 7, 2023
8fceb4a
[ etc ] push이벤트 수정
seojisoosoo Jul 7, 2023
748b19e
[ feat ] 내용 변경
seojisoosoo Jul 7, 2023
abf895f
[ feat ] 서버 통신 성공
seojisoosoo Jul 7, 2023
485f2c1
[ feat ] 디바이스 토큰 노출
seojisoosoo Jul 7, 2023
4a73b35
[ feat ] 토큰 복사 로직 구현
seojisoosoo Jul 7, 2023
8201b9d
[ style ] 서비스 워커 경로 변경
seojisoosoo Jul 7, 2023
559333b
[ style ] manifest 위치 변경
seojisoosoo Jul 7, 2023
19d2b62
[ feat ] resultData 확인
seojisoosoo Jul 7, 2023
9a94237
[ feat ] 콘솔에 토큰 찍히도록
seojisoosoo Jul 7, 2023
6c1e7af
[ etc ] 제발 되라 좀
seojisoosoo Jul 7, 2023
ac76449
[ etc ] 위치 다시 변경
seojisoosoo Jul 7, 2023
c1c6a0e
[ etc ] 콘솔 다시 찍기....
seojisoosoo Jul 7, 2023
07ad1f6
[ feat ] 기다리는 로직 추가
seojisoosoo Jul 7, 2023
6730005
[ etc ] 들어오는지 확인
seojisoosoo Jul 7, 2023
cc4292d
[ feat ] 서비스 워커 등록 과정 추가
seojisoosoo Jul 7, 2023
6bc6bd0
[ feat ] 서비스 워커 등록 과정 추가
seojisoosoo Jul 7, 2023
5dcda81
[ style ] 파일명 변경
seojisoosoo Jul 7, 2023
7b1627d
[ feat ] 서비스 워커 삭 다 명칭 바꿈
seojisoosoo Jul 7, 2023
c5d2ce4
[ feat ] 토큰 콘솔에 찍기 진자 그만...
seojisoosoo Jul 7, 2023
1b5261f
[ feat ] 서비스 워커 이름 변경
seojisoosoo Jul 7, 2023
73b035e
[ fix ] 경로 수정
seojisoosoo Jul 7, 2023
de7a16c
[ feat ] 되는지 확인
seojisoosoo Jul 7, 2023
164501a
[ style ] 변수명으로 변경
seojisoosoo Jul 7, 2023
cb2481c
[ feat ] 클릭하면 푸시되게
seojisoosoo Jul 7, 2023
fe0f9a7
[ feat ] 알람 허용 버튼 로직 추가
seojisoosoo Jul 7, 2023
59f2070
[ feat ] 토큰이 안 보여..
seojisoosoo Jul 7, 2023
e578e85
[ feat ] 제목 수정
seojisoosoo Jul 7, 2023
5cd0430
[ feat ] 이미지 경로 수정
seojisoosoo Jul 7, 2023
daffc9f
[ feat ] 튜티스 이미지 경로 수정
seojisoosoo Jul 7, 2023
7e58e79
[ feat ] 경로 재수정
seojisoosoo Jul 7, 2023
cf41152
[ feat ] 이미지가 왜 안 될까...
seojisoosoo Jul 7, 2023
41b234b
[ fix ] 이미지 경로 수정중
seojisoosoo Jul 7, 2023
99bf3d8
[ feat ] 아이콘 이미지 추가
seojisoosoo Jul 7, 2023
8b8241e
[ feat ] 사운드 추가
seojisoosoo Jul 11, 2023
8b501b3
[ feat ] 사운드 수정
seojisoosoo Jul 11, 2023
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 .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
"plugin:import/warnings",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
// "prettier/@typescript-eslint",
],
rules: {
"linebreak-style": 0,
Expand All @@ -22,6 +22,6 @@ module.exports = {
"eol-last": ["error", "always"], // line의 가장 마지막 줄에는 개행 넣기
"react/react-in-jsx-scope": "off",
"no-multi-spaces": "error", // 스페이스 여러개 금지
"simple-import-sort/imports": "error",
// "simple-import-sort/imports": "error",
},
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

.env
node_modules
dist
dist-ssr
Expand Down
4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

9 changes: 7 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/fruit.png" />
<link rel="icon" type="image/svg+xml" href="/tutice.png" />
<link rel="apple-touch-icon" href="/tutice.png" />
<link rel="shortcut icon" href="/tutice.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link
rel="stylesheet"
as="style"
crossorigin="anonymous"
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.css" />
<link href="https://webfontworld.github.io/kt/YDestreet.css" rel="stylesheet" />
<title>web-pre-task</title>
<link rel="stylesheet" href="src/index.css" />

<title>튜티스</title>
</head>
<body>
<div id="root"></div>
Expand Down
20 changes: 20 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"short_name": "Tutice",
"name": "튜티스",
"icons": [
{
"src": "tutice.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "tutice.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#FF5D5D",
"background_color": "#FF5D5D"
}
23 changes: 18 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,48 @@
"format": "prettier --write --cache ."
},
"dependencies": {
"antd": "^5.6.4",
"axios": "^1.4.0",
"date-fns": "^2.30.0",
"dayjs": "^1.11.9",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"firebase": "^10.0.0",
"http-proxy-middleware": "^2.0.6",
"moment": "^2.29.4",
"react": "^18.2.0",
"react-calendar": "^4.3.0",
"react-datepicker": "^4.14.1",
"react-day-picker": "^8.8.0",
"react-dom": "^18.2.0",
"react-ios-time-picker": "^0.2.2",
"react-query": "^3.39.3",
"react-router-dom": "^6.14.0",
"recoil": "^0.7.7",
"styled-components": "^6.0.0",
"vite-plugin-svgr": "^3.2.0",
"vite-tsconfig-paths": "^4.2.0"
"vite-tsconfig-paths": "^4.2.0",
"workbox-core": "^7.0.0",
"workbox-precaching": "^7.0.0"
},
"devDependencies": {
"@types/react": "^18.0.37",
"@types/react-datepicker": "^4.11.2",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"@typescript-eslint/eslint-plugin": "5",
"@typescript-eslint/parser": "5",
"@vitejs/plugin-react": "^4.0.1",
"eslint": "^8.38.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
"husky": "^8.0.3",
"lint-staged": "^13.2.3",
"prettier": "^2.8.8",
"typescript": "^5.0.2",
"typescript": "^5.1.6",
"vite": "^4.3.9"
},
"lint-staged": {
Expand Down
1 change: 1 addition & 0 deletions public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
Binary file added public/clock.mp3
Binary file not shown.
Binary file added public/ditto.mp3
Binary file not shown.
54 changes: 54 additions & 0 deletions public/firebase-messaging-sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* eslint-disable no-restricted-globals */
/* eslint-disable no-undef */
self.addEventListener("install", function (e) {
console.log("fcm sw install..");
self.skipWaiting();
});

self.addEventListener("activate", function (e) {
console.log("fcm sw activate..");
});

self.addEventListener("push", function (e) {
// console.log("push: ", e.data.json());
if (!e.data.json()) return;

const resultData = e.data.json().notification;
const notificationTitle = resultData.title;

const notificationOptions = {
body: resultData.body,
icon: "/tutice.png",
vibrate: [500, 110, 500, 110, 450, 110, 200, 110, 170, 40, 450, 110, 200, 110, 170, 40, 500],
sound: "/clock.mp3",
// tag: resultData.tag,
// ...resultData,
};
// console.log(resultData.title, { body: resultData.body, icon: "./tutice.png" });

// self.registration.showNotification(notificationTitle, notificationOptions);
e.waitUntil(
console.log("아니 들어는오냐?"),
self.registration.showNotification(notificationTitle, notificationOptions),
console.log("되냐고"),
);
});

// self.addEventListener("push", (event) => {
// console.log(event.data?.json());

// const message = event.data?.json();
// event.waitUntil(
// self.registration.showNotification(message.title, {
// body: message.body,
// icon: "/tutice.png",
// }),
// );
// });

self.addEventListener("notificationclick", function (event) {
console.log("notification click");
const url = "/";
event.notification.close();
event.waitUntil(clients.openWindow(url));
});
Binary file added public/tutice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { RecoilRoot } from "recoil";
import { ThemeProvider } from "styled-components";
import Router from "./Router";
import "./firebase-messaging-sw.js";
import { GlobalStyle } from "./style/globalStyle";
import { theme } from "./style/theme";

Expand Down
Empty file removed src/api/.keep
Empty file.
9 changes: 9 additions & 0 deletions src/api/postToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import axios from "axios";

export async function postToken(token: string) {
console.log(token);
const data = await axios.post("/api", { deviceToken: token });

console.log(data);
return data;
}
1 change: 1 addition & 0 deletions src/assets/assets.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ declare module "*.jpg";
declare module "*.png";
declare module "*.jpeg";
declare module "*.gif";
declare module "*.mp3";

declare module "*.svg" {
import React = require("react");
Expand Down
Empty file removed src/components/.keep
Empty file.
Empty file removed src/components/jisoo/.keep
Empty file.
101 changes: 101 additions & 0 deletions src/components/jisoo/JisooAlarm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { initializeApp } from "firebase/app";
import { getMessaging, getToken } from "firebase/messaging";
import { useEffect, useState } from "react";
import { useMutation } from "react-query";
import styled from "styled-components";
import { postToken } from "../../api/postToken";

interface DeviceTokenType {
deviceToken: string;
}

export default function JisooAlarm() {
const [deviceToken, setDeviceToken] = useState("");

const firebaseConfig = {
apiKey: import.meta.env.VITE_APP_API_KEY,
authDomain: import.meta.env.VITE_APP_AUTH_DOMAIN,
projectId: import.meta.env.VITE_APP_PROJECT_ID,
storageBucket: import.meta.env.VITE_APP_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_APP_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_APP_APP_ID,
measurementId: import.meta.env.VITE_APP_MEASUREMENT_ID,
};

const app = initializeApp(firebaseConfig);
const messaging = getMessaging(app);
// const firebaseConfig = {
// apiKey: import.meta.env.VITE_APP_API_KEY,
// authDomain: import.meta.env.VITE_APP_AUTH_DOMAIN,
// projectId: import.meta.env.VITE_APP_PROJECT_ID,
// storageBucket: import.meta.env.VITE_APP_STORAGE_BUCKET,
// messagingSenderId: import.meta.env.VITE_APP_MESSAGING_SENDER_ID,
// appId: import.meta.env.VITE_APP_APP_ID,
// measurementId: import.meta.env.VITE_APP_MEASUREMENT_ID,
// };

// // Initialize Firebase
// const app = initializeApp(firebaseConfig);
// const messaging = getMessaging(app);

async function handleAllowAlarm() {
const permission = await Notification.requestPermission();
if (permission === "denied") {
console.log("알림 권한 허용 안됨");
}
}

const { mutate } = useMutation(postToken, {
onSuccess: (res) => {
console.log(res);
},
onError: (err) => {
console.log(err);
},
});

async function getDeviceToken() {
const token = await getToken(messaging, {
vapidKey: import.meta.env.VITE_APP_VAPID_KEY,
});
setDeviceToken(token);
}

function handleAttend() {
getDeviceToken();
}

useEffect(() => {
mutate(deviceToken);
}, [deviceToken]);

function handleCopyClipBoard(token: string) {
console.log(token);
try {
navigator.clipboard.writeText(token).then(() => {
alert("클립보드에 토큰이 복사되었어요.");
});
} catch (err) {
alert("링크 복사에 실패했습니다");
}
}

return (
<>
<Button type="button" onClick={handleAllowAlarm}>
알림허용
</Button>
<Button type="button" onClick={handleAttend}>
출석
</Button>
<Button onClick={() => handleCopyClipBoard(deviceToken)}>토큰 복사하기</Button>
{deviceToken}
</>
);
}

const Button = styled.button`
border: 1px solid black;

padding: 2rem;
`;
Loading