Skip to content

hotfix: qa2 반영 #76

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

Merged
merged 11 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"react-native-gesture-handler": "^2.17.1",
"react-native-image-picker": "^7.1.2",
"react-native-linear-gradient": "^2.8.3",
"react-native-mail": "^6.1.1",
"react-native-pager-view": "^6.3.3",
"react-native-permissions": "^4.1.5",
"react-native-reanimated": "^3.14.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface UseAroundSpotQueryParams {
interface AroundSpotResponse {
attraction: SpotResponse[];
restaurant: SpotResponse[];
accomodation: SpotResponse[];
accommodation: SpotResponse[];
}

export default function useAroundSpotQuery({
Expand Down
44 changes: 39 additions & 5 deletions packages/react-native/src/components/common/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { Alert, ImageBackground, TouchableOpacity, View } from 'react-native';
import { useState } from 'react';
import { ImageBackground, TouchableOpacity, View } from 'react-native';
import HeartIcon from '@assets/HeartIcon';
import { useNavigation } from '@react-navigation/native';
import { Font } from 'design-system';
import { SpotCardData } from '@/types/spot';
import { StackNavigation } from '@/types/navigation';
import { getDisplayRegion } from '@/utils/getDisplayRegionName';
import useSpotLikeMutation from '@/apis/mutations/useSpotLikeMutation';
import MutationLoadingModal from './MutationLoadingModal';

interface CardProps {
data: SpotCardData;
size?: number;
}

interface CardLike {
likeCount: number;
isLiked: boolean;
}

function Default({ data, size = 260 }: CardProps) {
const {
isLiked,
Expand All @@ -23,14 +31,41 @@ function Default({ data, size = 260 }: CardProps) {
id,
workId,
} = data;

const [cardLike, setCardLike] = useState<CardLike>({
isLiked,
likeCount,
});
const navigation = useNavigation<StackNavigation<'Home/Search'>>();
const { like, isLikePending, isCancelLikePending, cancelLike } =
useSpotLikeMutation({ contentId });

const handleClickLike = () => {
if (cardLike.isLiked) {
setCardLike((prev) => ({
isLiked: !prev.isLiked,
likeCount: prev.likeCount - 1,
}));
cancelLike({ id });
return;
}

setCardLike((prev) => ({
isLiked: !prev.isLiked,
likeCount: prev.likeCount + 1,
}));
like({ id });
};

return (
<ImageBackground
source={{ uri: posterUrl }}
className="rounded-2xl overflow-hidden bg-SPOT-black"
style={{ width: size, aspectRatio: 3 / 4 }}
>
<MutationLoadingModal
isSubmiting={isLikePending || isCancelLikePending}
/>
<TouchableOpacity
className="flex-1 justify-end bg-black/40"
onPress={() =>
Expand All @@ -41,17 +76,16 @@ function Default({ data, size = 260 }: CardProps) {
<View className="flex-row justify-end items-center">
<TouchableOpacity
className="flex-row items-center p-2"
// FIXME: 실제 좋아요 기능 추가
onPress={() => Alert.alert('좋아요', `${id}`)}
onPress={handleClickLike}
>
<HeartIcon
width={15}
height={15}
color={isLiked ? 'red' : 'white'}
color={cardLike.isLiked ? 'red' : 'white'}
/>
<View className="ml-1">
<Font type="body3" color="white">
{likeCount}
{cardLike.likeCount}
</Font>
</View>
</TouchableOpacity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function SpotDetailBottomSheet({
const { data } = useSpotDetailQuery({ id: selectedDetailSpotId });
return (
<BottomSheet
snapPoints={['90%']}
snapPoints={['100%']}
handleClose={onClose}
isShow={Boolean(selectedDetailSpotId)}
>
Expand Down
26 changes: 26 additions & 0 deletions packages/react-native/src/constants/EMAIL_CONTENTS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const EMAIL_CONTENTS = {
BUG: {
title: '[버그 신고] SPOT!에 문의하기',
body: `
문제 발생 일시:

상세 내용:

문제 상황 이미지 및 영상 :

* 상황에 대한 자세한 설명이 작성되어 있지 않은 경우 문제 해결 및 답변이 어려운 점 참고 부탁드립니다.
* 문의 관련 스크린샷 또는 녹화본을 첨부하시면 빠른 문제확인 및 해결이 가능합니다.`,
},

NORMAL: {
title: '[일반 문의] SPOT!에 문의하기',
body: `
문의할 내용:

관련 이미지 및 영상 :

* 문의 관련 스크린샷 또는 녹화본을 첨부하시면 빠른 문제확인 및 해결이 가능합니다.`,
},
} as const;

export default EMAIL_CONTENTS;
47 changes: 47 additions & 0 deletions packages/react-native/src/hooks/useSortByStartDate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { useEffect, useState } from 'react';

type orderType = 'ascending' | 'descending';

interface ObjectWithStartDate {
startDate: string;
}

interface UseSortParams<T extends ObjectWithStartDate[]> {
defaultData: T;
}

export default function useSortByStartDate<T extends ObjectWithStartDate[]>({
defaultData,
}: UseSortParams<T>) {
const [data, setData] = useState<T>(defaultData);
const [order, setOrder] = useState<orderType>();

const sort = (type: orderType) => {
setData((prev) => {
const sortedData = [...prev].sort((a, b) => {
return type === 'ascending'
? new Date(a.startDate).getTime() - new Date(b.startDate).getTime()
: new Date(b.startDate).getTime() - new Date(a.startDate).getTime();
});
return sortedData as T;
});
};

const toggleSortOrder = (type?: orderType) => {
if (!type) {
setOrder((prev) => (prev === 'descending' ? 'ascending' : 'descending'));
return;
}

setOrder(type);
};

useEffect(() => {
setData(defaultData);
if (order) {
sort(order);
}
}, [order, defaultData]);

return { data, order, toggleSortOrder };
}
36 changes: 26 additions & 10 deletions packages/react-native/src/pages/Detail.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Font } from 'design-system';
import { ImageBackground, TouchableOpacity, View } from 'react-native';
import { useNavigation, useRoute } from '@react-navigation/native';
import { useHeaderHeight } from '@react-navigation/elements';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { StackNavigation, StackRouteProps } from '@/types/navigation';
import withSuspense from '@/components/HOC/withSuspense';
import DetailTabNavigator from '@/routes/DetailTabNavigator';
Expand All @@ -10,6 +12,7 @@ import useDetailQuery from '@/apis/queries/detail/useDetailQuery';
import useSpotLikeMutation from '@/apis/mutations/useSpotLikeMutation';
import MutationLoadingModal from '@/components/common/MutationLoadingModal';
import { getDisplayRegion } from '@/utils/getDisplayRegionName';
import Header from '@/components/common/Header';

const Detail = withSuspense(() => {
const route = useRoute<StackRouteProps<'Home/Detail'>>();
Expand All @@ -21,28 +24,32 @@ const Detail = withSuspense(() => {
useSpotLikeMutation({ contentId: paramsContentId });

const {
image,
title,
longitude,
latitude,
contentId,
addr1,
addr2,
overview,
posterUrl,
likeCount,
isLiked,
city,
region,
dist,
contentTypeId,
image,
posterUrl,
} = data;

const headerHeight = useHeaderHeight();
const insets = useSafeAreaInsets();

const defaultPaddingTop =
headerHeight - insets.top > 0 ? headerHeight - insets.top : 0;

const handleAddPlan = () => {
navigation.navigate('Home/AddSpot', {
spots: [
// TODO: useDetailQuery 반환타입과 호환되지 않음
// 추후 api응답 변경시 재변경 빌표
{
contentId: Number(contentId),
title,
Expand All @@ -64,13 +71,22 @@ const Detail = withSuspense(() => {
<MutationLoadingModal
isSubmiting={isCancelLikePending || isLikePending}
/>
<ImageBackground
className="h-[200px]"
source={{ uri: image ?? posterUrl }}
<Header />
{(image || posterUrl) && (
<ImageBackground
className="h-[200px]"
source={{ uri: image || posterUrl }}
>
<View className="flex-1 justify-end bg-black/20" />
</ImageBackground>
)}

<View
className="flex-1 bg-[#100F0F] p-4 pb-0"
style={{
paddingTop: !image && !posterUrl ? defaultPaddingTop : 16,
}}
>
<View className="flex-1 justify-end bg-black/20" />
</ImageBackground>
<View className="flex-1 bg-[#100F0F] p-4 pb-0">
<View>
<Font type="mainTitle" color="white">
{title}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/src/pages/Detail/DetailSpot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default withSuspense(function DetailSpot() {
/>
<CardSlider
title="숙소"
data={data.accomodation}
data={data.accommodation}
renderItem={({ item }) => (
<AroundCard
data={item}
Expand Down
24 changes: 12 additions & 12 deletions packages/react-native/src/pages/Maps/Records.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ import useRecordsQuery, {
} from '@/apis/queries/records/useRecordsQuery';
import withSuspense from '@/components/HOC/withSuspense';
import useRecordMutation from '@/apis/mutations/useRecordMutation';
import useSortByStartDate from '@/hooks/useSortByStartDate';

interface RecordsProps {
navigation: StackNavigation<'Maps/Record'>;
}

export default withSuspense(function Records({ navigation }: RecordsProps) {
const [showBottomSheet, toggleBottomSheet] = useToggle();
const [selectedRecord, setSelectedRecord] = useState<RecordResponse>();
const sort = () => {
// TODO: 실제 구현 필요(현재 UI없음)
};

const route = useRoute<StackRouteProps<'Maps/Record'>>();

const { data: recordsData } = useRecordsQuery({
location: route.params.location,
});
const { data, toggleSortOrder } = useSortByStartDate({
defaultData: recordsData,
});

const { deleteMutate } = useRecordMutation({
location: route.params.location,
});

const [showBottomSheet, toggleBottomSheet] = useToggle();
const [selectedRecord, setSelectedRecord] = useState<RecordResponse>();

const handleOpenOption = (selectedCardData: RecordResponse) => {
setSelectedRecord(selectedCardData);
toggleBottomSheet(true);
Expand All @@ -50,7 +50,10 @@ export default withSuspense(function Records({ navigation }: RecordsProps) {
<BackGroundGradient withoutScroll={isEmpty}>
<Header
RightActionButton={
<TouchableOpacity onPress={sort} className="px-4">
<TouchableOpacity
onPress={() => toggleSortOrder()}
className="px-4"
>
<SortIcon />
</TouchableOpacity>
}
Expand All @@ -73,10 +76,7 @@ export default withSuspense(function Records({ navigation }: RecordsProps) {
paddingRight: LOG_PADDING_X,
}}
>
<RecordCardList
cards={recordsData}
handleOpenOptions={handleOpenOption}
/>
<RecordCardList cards={data} handleOpenOptions={handleOpenOption} />
</View>
)}
</BackGroundGradient>
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/src/pages/MyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import BackGroundGradient from '@/layouts/BackGroundGradient';
import Rank from '@/components/mypage/Rank';
import EditButton from '@/components/common/EditButton';
import MyPageTabNavigator from '@/routes/MyPageTabNavigator';

Check warning on line 6 in packages/react-native/src/pages/MyPage.tsx

View workflow job for this annotation

GitHub Actions / build

'MyPageTabNavigator' is defined but never used
import useProfileQuery from '@/apis/queries/useProfileQuery';
import { StackNavigation } from '@/types/navigation';
import CogWheelIcon from '@/assets/CogWheelIcon';
Expand Down Expand Up @@ -52,9 +52,9 @@
>
<CogWheelIcon />
</TouchableOpacity>
<View className="flex-1">
{/* <View className="flex-1">
<MyPageTabNavigator />
</View>
</View> */}
</View>
</BackGroundGradient>
);
Expand Down
Loading
Loading