diff --git a/src/components/molecules/screens/announcement/list/ArticleList.tsx b/src/components/molecules/screens/announcement/list/ArticleList.tsx index f5d95ded..f336c1d2 100644 --- a/src/components/molecules/screens/announcement/list/ArticleList.tsx +++ b/src/components/molecules/screens/announcement/list/ArticleList.tsx @@ -4,6 +4,7 @@ import {FlatList} from 'react-native-gesture-handler'; import {DefinedInfiniteQueryObserverResult} from '@tanstack/react-query'; import ArticleItem from './ArticleItem'; import {ArticleItemType} from '../../../../../types/announcement.type'; +import usePullToRefresh from '../../../../../hooks/usePullToRefresh'; const REFRESH_STOP_TIME = 0.5 * 1000; @@ -29,22 +30,9 @@ const ArticleList = forwardRef( ref, ) => { // pull to refresh - const [refreshing, setRefreshing] = useState(false); - const setRefreshFinish = () => - setTimeout(() => { - setRefreshing(false); - }, REFRESH_STOP_TIME); - - const onRefresh = useCallback(() => { - if (!refetch) return; - setRefreshing(true); - try { - refetch(); - } catch (err) { - setRefreshFinish(); - } - setRefreshFinish(); - }, [refetch]); + const {onRefresh, refreshing} = usePullToRefresh(() => + refetch ? refetch() : undefined, + ); // render item const renderItem: ListRenderItem = ({item}) => ( diff --git a/src/components/molecules/screens/library/LibraryRoomItem.tsx b/src/components/molecules/screens/library/LibraryRoomItem.tsx index 3ae3e34c..c62ca00b 100644 --- a/src/components/molecules/screens/library/LibraryRoomItem.tsx +++ b/src/components/molecules/screens/library/LibraryRoomItem.tsx @@ -1,42 +1,72 @@ import React from 'react'; -import styled from '@emotion/native'; +import styled, {css} from '@emotion/native'; import {Txt, colors} from '@uoslife/design-system'; +import {useNavigation} from '@react-navigation/native'; import {LibraryStatusItemType} from '../../../../api/services/util/library/libraryAPI.type'; +import boxShadowStyle from '../../../../styles/boxShadow'; +import AnimatePress from '../../../animations/pressable_icon/AnimatePress'; +import {LibraryRoomStatusNavigationProp} from '../../../../navigators/types/library'; +import customShowToast from '../../../../configs/toast/index'; -export type Props = {item: LibraryStatusItemType}; +// TODO: 스터디홀, 중도 이외 도서관 예약 기능 추가되면 삭제 +const ACCSS_RESTRICTION_ROOM_NUMBER = ['6', '21', '22', '32', '33']; + +export type Props = { + item: LibraryStatusItemType; + boxWidth: number; +}; + +const LibraryRoomItem = ({item, boxWidth}: Props) => { + const navigation = useNavigation(); + const isAccessRestriction = ACCSS_RESTRICTION_ROOM_NUMBER.some( + i => i === item.room_no, + ); -const LibraryRoomItem = ({item}: Props) => { return ( - - - - - + { + if (isAccessRestriction) { + customShowToast('preparingLibraryReservationInfo'); + return; + } + navigation.navigate('Library_seat_list', { + roomNumber: item.room_no, + }); + }}> + + - + ); }; export default LibraryRoomItem; const S = { - Container: styled.View` - display: flex; - padding: 12px 0; - gap: 4px; - `, + Container: styled.View``, itemTxtContainer: styled.View` display: flex; flex-direction: row; @@ -46,6 +76,7 @@ const S = { progressBarConatiner: styled.View` margin-top: 8px; margin-bottom: 8px; + width: 100%; `, progressBarTrail: styled.View` height: 4px; diff --git a/src/components/molecules/screens/library/LibraryRoomStatus.tsx b/src/components/molecules/screens/library/LibraryRoomStatus.tsx new file mode 100644 index 00000000..453153c5 --- /dev/null +++ b/src/components/molecules/screens/library/LibraryRoomStatus.tsx @@ -0,0 +1,39 @@ +import {useQuery} from '@tanstack/react-query'; +import styled from '@emotion/native'; +import {colors} from '@uoslife/design-system'; +import {useState} from 'react'; +import {UtilAPI} from '../../../../api/services'; +import LibraryRoomItem from './LibraryRoomItem'; +import usePullToRefresh from '../../../../hooks/usePullToRefresh'; +import {LibraryRoomStatusTabsType} from '../../../../configs/utility/libraryTabs'; + +type Props = {roomType: LibraryRoomStatusTabsType}; + +const LibraryRoomStatus = ({roomType}: Props) => { + const {data, refetch} = useQuery({ + queryKey: ['getLibraryRoomStatus', roomType], + queryFn: () => UtilAPI.getLibraryRoomStatus({type: roomType}), + }); + + const {onRefresh, refreshing} = usePullToRefresh(() => refetch()); + const [width, setWidth] = useState(0); + return ( + } + numColumns={2} + onLayout={event => setWidth(event.nativeEvent.layout.width)} + /> + ); +}; + +export default LibraryRoomStatus; + +const S = { + Container: styled.FlatList` + padding: 8px 10px; + background-color: ${colors.primaryLighterAlt}; + `, +}; diff --git a/src/configs/utility/libraryTabs.ts b/src/configs/utility/libraryTabs.ts index 36e6c3d7..7c958303 100644 --- a/src/configs/utility/libraryTabs.ts +++ b/src/configs/utility/libraryTabs.ts @@ -1,8 +1,20 @@ export type LibraryTabsType = 'MY_SEAT' | 'SEAT_LIST' | 'RECORD'; export type LibraryTabsEnumType = Record; +export type LibraryRoomStatusTabsType = 'ECONOMY' | 'LAW' | 'CENTRAL'; +export type LibraryRoomStatusTabsEnumType = Record< + LibraryRoomStatusTabsType, + string +>; + export const LibraryTabsEnum: LibraryTabsEnumType = { MY_SEAT: '내자리', SEAT_LIST: '좌석', RECORD: '기록', }; + +export const LibraryRoomStatusTabsEnum: LibraryRoomStatusTabsEnumType = { + CENTRAL: '중앙도서관', + LAW: '법학전문도서관', + ECONOMY: '경영경제도서관', +}; diff --git a/src/navigators/types/library.ts b/src/navigators/types/library.ts index 1f767129..8ce39d40 100644 --- a/src/navigators/types/library.ts +++ b/src/navigators/types/library.ts @@ -11,8 +11,8 @@ export type LibraryStackParamList = { }; export type LibraryRoomStatusStackParamList = { - Library_room_status_main: {roomType: 'ECONOMY' | 'LAW' | 'CENTRAL'}; - Library_seat_list: {roomNumber: number}; + Library_room_status_main?: {roomType?: 'ECONOMY' | 'LAW' | 'CENTRAL'}; + Library_seat_list: {roomNumber: string}; Library_portal_authentication: undefined; }; diff --git a/src/screens/library/LibraryMainScreen.tsx b/src/screens/library/LibraryMainScreen.tsx index 50814dfa..3a6b8616 100644 --- a/src/screens/library/LibraryMainScreen.tsx +++ b/src/screens/library/LibraryMainScreen.tsx @@ -41,7 +41,6 @@ const LibraryMainScreen = ({route: {params}}: LibraryMainScreenProps) => { }, [isFocused, setIsFocusedLibraryScreen]); return ( - // <>
{ - const initialRoomType = (params?.roomType ?? 'CENTRAL') satisfies - | 'ECONOMY' - | 'LAW' - | 'CENTRAL'; + const insets = useSafeAreaInsets(); + const navigation = useNavigation(); + const handleGoBack = () => { + navigation.goBack(); + }; + const initialRoomType = (params?.roomType ?? + 'CENTRAL') satisfies LibraryRoomStatusTabsType; + + const initialIndex = useMemo( + () => + Object.keys(LibraryRoomStatusTabsEnum).findIndex(i => + i.match(initialRoomType), + ), + [initialRoomType], + ); + const [index, setIndex] = useState(initialIndex); - return <>; + return ( + <> +
+ + } + /> + } + /> + } + /> + + + ); }; export default LibraryRoomStatusScreen;