Skip to content

Commit

Permalink
Merge pull request #144 from MZ-OFFISSU/feat/sprint-final
Browse files Browse the repository at this point in the history
Feat/sprint final
  • Loading branch information
Jun99uu authored Sep 23, 2023
2 parents a9394c6 + 10bce4d commit 8be9bc0
Show file tree
Hide file tree
Showing 26 changed files with 246 additions and 354 deletions.
25 changes: 0 additions & 25 deletions TERMTERM/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,13 @@ import Toast from "react-native-toast-message";
import { toastConfig } from "@components/popup/toast";
import { ActionSheetProvider } from "@expo/react-native-action-sheet";
import { LogBox } from "react-native";
import { useNotification } from "@hooks/useNotification";
import { useEffect, useState } from "react";
import AsyncStorage from "@react-native-async-storage/async-storage";

export default function App() {
LogBox.ignoreLogs([
"Sending `onAnimatedValueUpdate` with no listeners registered.",
"Warning: Each child in a list should have a unique",
"Warning: Encountered two children with the same key",
]);
const [notificationStatus, setNotificationStatus] = useState<string | null>(
null
);
const { requestPermission, scheduleNotification } = useNotification();

const setNotification = async () => {
const noti = await AsyncStorage.getItem("noti_allow");
setNotificationStatus(noti);

if (!noti) {
const per = await requestPermission();
await AsyncStorage.setItem("noti_allow", per ? "allow" : "deny");
if (per) {
scheduleNotification(8, 30);
scheduleNotification(19, 0);
}
}
};

useEffect(() => {
setNotification();
}, []);

return (
<ActionSheetProvider>
Expand Down
1 change: 0 additions & 1 deletion TERMTERM/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"expo-apple-authentication": "~5.0.1",
"expo-haptics": "~12.0.1",
"expo-image-picker": "^14.1.1",
"expo-notifications": "~0.17.0",
"expo-sharing": "~11.0.1",
"expo-splash-screen": "^0.17.5",
"expo-status-bar": "~1.4.2",
Expand Down
4 changes: 2 additions & 2 deletions TERMTERM/src/api/PointApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class PointApi {
};

/** 폴더 한도 1개 추가 (폴더 구매) */
buyFolder = async (id: number) => {
await put(`/v1/point/pay/folder/${id}`);
buyFolder = async () => {
await put(`/v1/point/pay/folder`);
};
}

Expand Down
4 changes: 3 additions & 1 deletion TERMTERM/src/components/header/BookmarkBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Ionicons } from "@expo/vector-icons";
import { useThemeStyle } from "@hooks/useThemeStyle";
import BackArrowIcon from "@assets/icon/BackArrowIcon";
import { useBookmarkHeader } from "@hooks/useBookmarkHeader";
import { useShare } from "@hooks/useShare";

interface Props {
onBack: () => void;
Expand All @@ -27,6 +28,7 @@ const BookmarkBar = ({
}: Props) => {
const [COLOR, mode] = useThemeStyle();
const { bookmarked, handleBookmarkState } = useBookmarkHeader();
const { handleShare } = useShare();

return (
<HeaderWrapper style={{ justifyContent: "space-between" }}>
Expand Down Expand Up @@ -59,7 +61,7 @@ const BookmarkBar = ({
/>
)}
</CaretBtn>
<CaretBtn onPress={() => onShare()}>
<CaretBtn onPress={() => handleShare()}>
<Ionicons
name="share-social-outline"
size={24}
Expand Down
4 changes: 3 additions & 1 deletion TERMTERM/src/components/header/CarouselBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { AntDesign, Ionicons } from "@expo/vector-icons";
import { useThemeStyle } from "@hooks/useThemeStyle";
import { useHeader } from "@hooks/useHeader";
import BackArrowIcon from "@assets/icon/BackArrowIcon";
import { useShare } from "@hooks/useShare";

interface Props {
onBack: () => void;
Expand All @@ -18,6 +19,7 @@ interface Props {
const CarouselBar = ({ onBack, onBookmark, onShare }: Props) => {
const [COLOR, mode] = useThemeStyle();
const { headerState, bookmarkHandler } = useHeader();
const { handleShare } = useShare();

return (
<HeaderWrapper
Expand Down Expand Up @@ -47,7 +49,7 @@ const CarouselBar = ({ onBack, onBookmark, onShare }: Props) => {
/>
)}
</CaretBtn>
<CaretBtn onPress={() => onShare()}>
<CaretBtn onPress={() => handleShare()}>
<Ionicons
name="share-social-outline"
size={24}
Expand Down
16 changes: 4 additions & 12 deletions TERMTERM/src/components/header/IconBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import {
CaretBtn,
TitleWrapper,
} from "../common/NavigatorTitle";
import { AntDesign, Ionicons } from "@expo/vector-icons";
import { Ionicons } from "@expo/vector-icons";
import { useThemeStyle } from "@hooks/useThemeStyle";
import styled from "styled-components/native";
import AutoSizedImage from "@components/common/AutoSizedImage";
import { iconHeaderState } from "@recoil/iconHeaderState";
import { useRecoilValue } from "recoil";
import { useCallback } from "react";
import { Feather } from "@expo/vector-icons";
import * as Sharing from "expo-sharing";
Expand All @@ -19,6 +17,7 @@ import { useHeader } from "@hooks/useHeader";
import FolderApi from "@api/FolderApi";
import { useHaptics } from "@hooks/useHaptics";
import { Toast } from "react-native-toast-message/lib/src/Toast";
import { useShare } from "@hooks/useShare";

export enum Icon {
fold,
Expand All @@ -37,6 +36,7 @@ interface Props {
*/
const IconBar = ({ onBack, icon, onPress, bookmarkBar }: Props) => {
const folderApi = new FolderApi();
const { handleShare } = useShare();

const [COLOR, mode] = useThemeStyle();
const {
Expand Down Expand Up @@ -119,14 +119,6 @@ const IconBar = ({ onBack, icon, onPress, bookmarkBar }: Props) => {
);
};

const handleShare = async (url: string) => {
if (!(await Sharing.isAvailableAsync())) {
return;
}
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Warning);
Sharing.shareAsync(url);
};

return (
<HeaderWrapper style={{ justifyContent: "space-between" }}>
<CaretBtn onPress={() => onBack()} style={{ marginLeft: 20 }}>
Expand All @@ -147,7 +139,7 @@ const IconBar = ({ onBack, icon, onPress, bookmarkBar }: Props) => {
<CaretBtn onPress={() => onPress()} style={{ marginRight: 13 }}>
{icon === Icon.fold ? <Fold /> : <Collapse />}
</CaretBtn>
<CaretBtn onPress={() => handleShare("https://www.naver.com/")}>
<CaretBtn onPress={() => handleShare()}>
<Feather name="share-2" size={20} color={COLOR.Text.active} />
</CaretBtn>
</ElementWrapper>
Expand Down
4 changes: 3 additions & 1 deletion TERMTERM/src/components/my/MenuList/DefaultList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useMember } from "@hooks/useMember";
import { logoutSucceed } from "@utils/showToast";
import { useHaptics } from "@hooks/useHaptics";
import { Linking } from "react-native";
import { useShare } from "@hooks/useShare";

interface MenuProps {
title: string;
Expand All @@ -23,6 +24,7 @@ interface MenuProps {
const DefaultList = () => {
const { haptic } = useHaptics();
const { logout, loading } = useMember();
const { handleShare } = useShare();

const navigation = useNavigation<StackNavigationProp<RootStackParamList>>();
const [isModal, setIsModal] = useState(false);
Expand All @@ -46,7 +48,7 @@ const DefaultList = () => {
],
[
{ title: "문의하기", onPress: () => navigation.push("Support") },
{ title: "앱 공유하기", onPress: () => null },
{ title: "앱 공유하기", onPress: () => handleShare() },
],
[{ title: "버전 정보", subtitle: "v 1.0", onPress: () => null }],
[
Expand Down
2 changes: 1 addition & 1 deletion TERMTERM/src/components/my/Point/HistoryBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const HistoryBox = ({ history, ...props }: Props) => {
<ContentText COLOR={COLOR}>{content.detail}</ContentText>
<ContentText COLOR={COLOR}>
<ContentText COLOR={COLOR} style={{ fontWeight: `700` }}>
{Number(content.point) > 0 ? `+${content.point}` : content.point}
{Number(content.point) > 0 ? content.point : content.point}
</ContentText>{" "}
포인트
</ContentText>
Expand Down
7 changes: 6 additions & 1 deletion TERMTERM/src/components/my/Point/HistoryWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const HistoryWrapper = ({ ...props }: ViewProps) => {
const [visible, setVisible] = useState<number>(0);
const [max, setMax] = useState(false);

const { history } = usePoint();
const { history, getCurPoint, getHistoryByPage } = usePoint();

/**
* 시간 순으로 정렬
Expand Down Expand Up @@ -51,6 +51,11 @@ const HistoryWrapper = ({ ...props }: ViewProps) => {
}
}, [history]);

useEffect(() => {
getCurPoint();
getHistoryByPage();
}, []);

return (
<Container {...props}>
<TitleBox COLOR={COLOR}>포인트 사용 내역</TitleBox>
Expand Down
31 changes: 9 additions & 22 deletions TERMTERM/src/components/popup/tutorials/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,21 @@ import { AntDesign } from "@expo/vector-icons";
import TutorialCarousel from "./Carousel";
import { useRecoilState } from "recoil";
import { tutorialState } from "@recoil/tutorialState";
import { useCoach } from "@hooks/useCoach";

interface Props {
visible: boolean;
checked: boolean;
handleCheck: () => void;
hideTutorial: () => void;
}

/**
* 모달창 컴포넌트
* 그냥 사용만해도 뒷 배경이 흐릿해진다!
*/
const Tutorial = () => {
const Tutorial = ({ visible, checked, handleCheck, hideTutorial }: Props) => {
const [COLOR, mode] = useThemeStyle();
const [visible, setVisible] = useRecoilState(tutorialState);
const [checked, setChecked] = useState(false);

const getVisible = async () => {
const data = await AsyncStorage.getItem("tutorial");
if (!data) setVisible(true);
else return;
};

const hideTutorial = async () => {
if (checked) await AsyncStorage.setItem("tutorial", "hide");
setVisible(false);
};

const handleCheck = () => {
setChecked((prev) => !prev);
};

useEffect(() => {
getVisible();
}, []);

return (
<Modal
Expand Down
2 changes: 1 addition & 1 deletion TERMTERM/src/components/terms/WordCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const WordCarousel = ({
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>();

const navigateToTermDetail = (id: number) => {
navigation.push("TermsDetail", { id: id });
navigation.push("TermDetail", { id: `${id}` });
};

const moveToDetail = (index: number) => {
Expand Down
9 changes: 4 additions & 5 deletions TERMTERM/src/hooks/useCoach.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import AsyncStorage from "@react-native-async-storage/async-storage";
import { tutorialState } from "@recoil/tutorialState";
import { coachState, tutorialState } from "@recoil/tutorialState";
import { useState } from "react";
import { useRecoilValue } from "recoil";
import { useRecoilState, useRecoilValue } from "recoil";

export type CoachType = "folder" | "slide" | "comment" | "collapse";

export const useCoach = () => {
const isTutorialOpen = useRecoilValue(tutorialState);
const [isOpen, setIsOpen] = useState(false);
const [isOpen, setIsOpen] = useRecoilState(coachState);
const [whatCoach, setWhatCoach] = useState<CoachType>("folder");
const [checked, setChecked] = useState(false);

const openCoach = async (type: CoachType) => {
const checkPrevState = await AsyncStorage.getItem(`coach_${type}`);

if (!checkPrevState && !isTutorialOpen) {
if (!checkPrevState) {
setIsOpen(true);
setWhatCoach(type);
}
Expand Down
26 changes: 19 additions & 7 deletions TERMTERM/src/hooks/useCuration.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import CurationApi from "@api/CurationApi";
import PointApi from "@api/PointApi";
import {
archivedCurationListState,
curationDetailState,
curationListState,
} from "@recoil/curationState";
import {
Category,
CurationDetail,
CurationPreview,
MoreRecommendedCuration,
} from "Curation";
import { useEffect, useState } from "react";
import { Category } from "Curation";
import { useRecoilState } from "recoil";
import { usePoint } from "./usePoint";

/**
* 큐레이션 관리 훅
*/
export const useCuration = () => {
const curationApi = new CurationApi();
const pointApi = new PointApi();

const [arcihivedCurationList, setArchivedCurationList] = useRecoilState(
archivedCurationListState
);
Expand All @@ -26,6 +24,8 @@ export const useCuration = () => {
const [categoryCurationList, setCategoryCurationList] =
useRecoilState(curationListState);

const { getCurPoint } = usePoint();

/** 아카이브한 큐레이션 목록 가져오기 */
const getArchivecurationList = async (): Promise<boolean> => {
try {
Expand Down Expand Up @@ -87,6 +87,17 @@ export const useCuration = () => {
}
};

/** 포인트 지불하여 큐레이션 구매 함수 */
const buyThisCuration = async (id: number) => {
try {
await pointApi.buyCuration(id);
getCurPoint();
return true;
} catch (err) {
return false;
}
};

return {
getArchivecurationList,
arcihivedCurationList,
Expand All @@ -97,5 +108,6 @@ export const useCuration = () => {
categoryCurationList,
setCategoryCurationList,
deleteCurationBookmark,
buyThisCuration,
};
};
Loading

0 comments on commit 8be9bc0

Please sign in to comment.