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

refactor: nf-team/core의 변수명 수정 #339

Merged
merged 1 commit into from
Nov 8, 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
10 changes: 5 additions & 5 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"homepage": "https://github.com/mbti-nf-team/unnamed-k-place-frontend#readme",
"dependencies": {
"@nf-team/core": "^2.0.3",
"@nf-team/core": "^3.0.1",
"@nf-team/react": "^2.6.0",
"@nf-team/storage": "^1.0.1",
"@react-google-maps/api": "^2.19.3",
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/my/favorite-places/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';

import { checkEmpty } from '@nf-team/core';
import { ensureArray } from '@nf-team/core';
import QueryString from 'qs';

import api, { FetchError } from '@/lib/apis';
Expand Down Expand Up @@ -46,7 +46,7 @@ export async function GET(request: NextRequest) {
const googleDetails = await fetchAllPlaceDetails({ placeIds });

const favoritePlaces = googleDetails.map((detail, index) => {
const placePhotoUrls = checkEmpty(detail.result.photos)
const placePhotoUrls = ensureArray(detail.result.photos)
.map((photo) => getPlacePhotoUrl(photo.getUrl(), 500))
.filter((photoUrl) => !!photoUrl);

Expand Down
4 changes: 2 additions & 2 deletions src/app/api/search/nearby/places/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';

import { checkEmpty } from '@nf-team/core';
import { ensureArray } from '@nf-team/core';

import { fetchAllSettledSearchNaverBlogs, getGoogleNearbySearch } from '@/app/api/handler';
import { FetchError } from '@/lib/apis';
Expand Down Expand Up @@ -35,7 +35,7 @@ export async function GET(request: NextRequest) {
location: [lat, lng],
});

const placesResult = filteredPlaces(checkEmpty(places?.results));
const placesResult = filteredPlaces(ensureArray(places?.results));
const placeName = placesResult.filter((place) => !!place?.name).map((place) => place.name);

const searchBlogPosts = await fetchAllSettledSearchNaverBlogs({ placeName });
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/search/places/[placeId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';

import { checkEmpty } from '@nf-team/core';
import { ensureArray } from '@nf-team/core';

import { fetchNaverSearchBlog, getGooglePlaceDetails, getPlacePhotoUrl } from '@/app/api/handler';
import { FetchError } from '@/lib/apis';
Expand Down Expand Up @@ -62,7 +62,7 @@ export async function GET(request: NextRequest) {
const country = address_components
?.find((address) => address.types.includes(PlaceType2.country));

const placePhotoUrls = checkEmpty(placeDetails.result.photos)
const placePhotoUrls = ensureArray(placeDetails.result.photos)
.map((photo) => getPlacePhotoUrl(photo.photo_reference, 500))
.filter((photoUrl) => !!photoUrl);

Expand Down
6 changes: 3 additions & 3 deletions src/app/api/search/places/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';

import { checkEmpty } from '@nf-team/core';
import { ensureArray } from '@nf-team/core';

import { FetchError } from '@/lib/apis';
import { filteredPlaces } from '@/utils';
Expand Down Expand Up @@ -37,14 +37,14 @@ export async function GET(request: NextRequest) {
location: (lat && lng) ? [lat, lng] : undefined,
});

const placesResult = filteredPlaces(checkEmpty(places?.results));
const placesResult = filteredPlaces(ensureArray(places?.results));
const placeName = placesResult.filter((place) => !!place?.name).map((place) => place.name);

const searchBlogPosts = await fetchAllSettledSearchNaverBlogs({ placeName });

const response = placesResult.map((place, index) => ({
...place,
photoUrls: checkEmpty(place.photos)
photoUrls: ensureArray(place.photos)
.map((photo) => getPlacePhotoUrl(photo.photo_reference, 500))
.filter((photoUrl) => !!photoUrl),
searchBlogPost: searchBlogPosts[index],
Expand Down
4 changes: 2 additions & 2 deletions src/app/place/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Metadata, ResolvingMetadata } from 'next';
import { cookies } from 'next/headers';

import { checkEmpty } from '@nf-team/core';
import { ensureArray } from '@nf-team/core';

import { getGooglePlaceDetails, getPlacePhotoUrl } from '@/app/api/handler';
import { metadata } from '@/app/page';
Expand Down Expand Up @@ -52,7 +52,7 @@ export async function generateMetadata(
);

const previousParent = await parent;
const previousImages = checkEmpty(previousParent.openGraph?.images);
const previousImages = ensureArray(previousParent.openGraph?.images);
const images = thumbnailPhotoUrl ? [
{
url: thumbnailPhotoUrl,
Expand Down
14 changes: 7 additions & 7 deletions src/components/common/PlaceItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { memo, MouseEvent } from 'react';

import Image from 'next/image';

import { checkEmpty, checkNumber } from '@nf-team/core';
import { ensureArray, getNumberOrDefault, isEmpty } from '@nf-team/core';
import { useActionKeyEvent } from '@nf-team/react';
import clsx from 'clsx';

Expand Down Expand Up @@ -39,7 +39,7 @@ function PlaceItem<T = boolean>({
}: Props<T>) {
const onKeyDown = useActionKeyEvent<HTMLLIElement, [string]>(['Enter', 'NumpadEnter'], (_, id) => onClick?.(id));

const isOnePhoto = checkEmpty(photoUrls).length === 1;
const isOnePhoto = ensureArray(photoUrls).length === 1;

const removeFavoritePlace = (e: MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
Expand All @@ -59,7 +59,7 @@ function PlaceItem<T = boolean>({
className={styles.placeItem}
role="menuitem"
>
{!!checkEmpty(photoUrls).length && (
{!isEmpty(photoUrls) && (
<div className={clsx(styles.photos, isOnePhoto && styles.onlyOnePhotoWrapper)}>
{photoUrls.map((photo, index) => (
<Image
Expand All @@ -83,12 +83,12 @@ function PlaceItem<T = boolean>({
)}
</div>
<div className={styles.placeRatingWrapper}>
<div className={styles.placeRating}>{checkNumber(rating)}</div>
<StarRating rating={checkNumber(rating)} type="list" />
<div className={styles.placeUserRatingsTotal}>{`(${checkNumber(userRatingsTotal)})`}</div>
<div className={styles.placeRating}>{getNumberOrDefault(rating)}</div>
<StarRating rating={getNumberOrDefault(rating)} type="list" />
<div className={styles.placeUserRatingsTotal}>{`(${getNumberOrDefault(userRatingsTotal)})`}</div>
</div>
{!!settledSearchBlogPost && (
<div className={styles.searchTotal}>{`네이버 검색결과 ${numberWithComma(checkNumber(settledSearchBlogPost?.total_count))}개`}</div>
<div className={styles.searchTotal}>{`네이버 검색결과 ${numberWithComma(getNumberOrDefault(settledSearchBlogPost?.total_count))}개`}</div>
)}
{isSavedPlace && (
<div className={styles.addressInfo}>
Expand Down
8 changes: 4 additions & 4 deletions src/components/common/StarRating/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react';

import { checkNumber, generateArrayOfNumber } from '@nf-team/core';
import { createNumberArray, getNumberOrDefault } from '@nf-team/core';
import clsx from 'clsx';

import {
Expand All @@ -20,7 +20,7 @@
function StarRating({
rating, maxRating = 5, type, className, size = 'large',
}: Props) {
const numberRating = checkNumber(rating);
const numberRating = getNumberOrDefault(rating);
const fillStarCount = Math.floor(numberRating);

const detailClassName = clsx({
Expand Down Expand Up @@ -54,15 +54,15 @@
}

return <FillStar className={detailClassName} data-testid="decimal-fill-star" />;
}, [numberRating, type, detailClassName]);

Check warning on line 57 in src/components/common/StarRating/index.tsx

View workflow job for this annotation

GitHub Actions / check unit test & lint

React Hook useMemo has missing dependencies: 'EmptyStar', 'FillStar', and 'HalfStar'. Either include them or remove the dependency array

return (
<div className={clsx(styles.starRatingWrapper, className)}>
{generateArrayOfNumber(fillStarCount).map((key) => (
{createNumberArray(fillStarCount).map((key) => (
<FillStar key={key} className={detailClassName} />
))}
{fillStarCount < maxRating && extraStar}
{generateArrayOfNumber(maxRating - (fillStarCount + 1)).map((key) => (
{createNumberArray(maxRating - (fillStarCount + 1)).map((key) => (
<EmptyStar key={key} className={detailClassName} />
))}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/map/FavoritePlaces/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useRouter, useSearchParams } from 'next/navigation';

import { checkNumber } from '@nf-team/core';
import { getNumberOrDefault } from '@nf-team/core';

import Button from '@/components/common/Button';
import PlaceItem from '@/components/common/PlaceItem';
Expand Down Expand Up @@ -33,11 +33,11 @@
});
const { mutate: removeFavoritePlaceMutate } = useRemoveFavoritePlaceMutation();

const favoritePlaceCount = checkNumber(favoritePlaces?.pages?.[0].total_count);
const favoritePlaceCount = getNumberOrDefault(favoritePlaces?.pages?.[0].total_count);

const onClickPlaceItem = useCallback((placeId: string) => {
router.push(`/place/${placeId}`);
}, []);

Check warning on line 40 in src/components/map/FavoritePlaces/index.tsx

View workflow job for this annotation

GitHub Actions / check unit test & lint

React Hook useCallback has a missing dependency: 'router'. Either include it or remove the dependency array

const refState = useIntersectionObserver<HTMLUListElement>({
isRoot: true,
Expand Down
12 changes: 6 additions & 6 deletions src/components/map/MapContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { useRouter, useSearchParams } from 'next/navigation';

import { checkEmpty, checkNumber, isEmpty } from '@nf-team/core';
import { ensureArray, getNumberOrDefault, isEmpty } from '@nf-team/core';
import { useGoogleMap } from '@react-google-maps/api';
import QueryString from 'qs';

Expand Down Expand Up @@ -90,7 +90,7 @@
setSelectedPlaceId(undefined);
setSearchForm(form);
saveNextKeyword(keyword);
}, [centerLatitude, centerLongitude, map]);

Check warning on line 93 in src/components/map/MapContainer/index.tsx

View workflow job for this annotation

GitHub Actions / check unit test & lint

React Hook useCallback has missing dependencies: 'saveNextKeyword', 'sendEvent', and 'setSearchForm'. Either include them or remove the dependency array

const onToggleMenu = () => {
const params = QueryString.parse(searchParams.toString());
Expand All @@ -110,10 +110,10 @@
};

const isCenterChange = () => {
const isEqualLat = checkNumber(searchResultCenter.lat).toFixed(3)
=== checkNumber(centerLatitude).toFixed(3);
const isEqualLng = checkNumber(searchResultCenter.lng).toFixed(3)
=== checkNumber(centerLongitude).toFixed(3);
const isEqualLat = getNumberOrDefault(searchResultCenter.lat).toFixed(3)
=== getNumberOrDefault(centerLatitude).toFixed(3);
const isEqualLng = getNumberOrDefault(searchResultCenter.lng).toFixed(3)
=== getNumberOrDefault(centerLongitude).toFixed(3);

if (isEqualLat && isEqualLng) {
return true;
Expand All @@ -122,7 +122,7 @@
return false;
};

const placesWithSearchResult = useMemo(() => checkEmpty(places?.pages)
const placesWithSearchResult = useMemo(() => ensureArray(places?.pages)
.filter((page) => !!page.results?.length && page.status === 'OK')
.flatMap((page) => page.results), [places]);

Expand Down
14 changes: 7 additions & 7 deletions src/components/place/PlaceDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { notFound, useRouter } from 'next/navigation';

import { checkEmpty, checkNumber } from '@nf-team/core';
import { ensureArray, getNumberOrDefault } from '@nf-team/core';
import clsx from 'clsx';
import { motion } from 'framer-motion';

Expand Down Expand Up @@ -71,11 +71,11 @@

const isVisibleLoading = isLoading || !placeDetail;

const googleReviewCount = checkNumber(placeDetail?.reviews?.length);
const koreanReviewCount = checkEmpty(placeDetail?.reviews).filter(({
const googleReviewCount = getNumberOrDefault(placeDetail?.reviews?.length);
const koreanReviewCount = ensureArray(placeDetail?.reviews).filter(({
language, original_language,
}) => (original_language ? original_language === 'ko' : language === 'ko')).length;
const blogCount = checkNumber(placeDetail?.searchBlogPost?.total_count);
const blogCount = getNumberOrDefault(placeDetail?.searchBlogPost?.total_count);

const goToExternalLink = (eventName: EventName) => (url?: string) => sendEvent({
name: eventName,
Expand Down Expand Up @@ -143,7 +143,7 @@

renderToast('URL 복사에 실패했습니다.', { type: 'error' });
}
}, [placeDetail?.place_id, placeDetail?.name]);

Check warning on line 146 in src/components/place/PlaceDetail/index.tsx

View workflow job for this annotation

GitHub Actions / check unit test & lint

React Hook useCallback has missing dependencies: 'renderToast' and 'sendEvent'. Either include them or remove the dependency array

const displayDetailInfoText = useMemo(() => {
if (googleReviewCount < 3) {
Expand Down Expand Up @@ -240,7 +240,7 @@
<div className={styles.ratingWrapper}>
<StarRating rating={placeDetail?.rating} type="detail" />
<div className={styles.ratingText}>
{placeDetail?.rating ? checkNumber(placeDetail?.rating).toFixed(1) : '별점 없음'}
{placeDetail?.rating ? getNumberOrDefault(placeDetail?.rating).toFixed(1) : '별점 없음'}
</div>
</div>
<div className={styles.recommendDescription}>
Expand Down Expand Up @@ -272,11 +272,11 @@
<Accordion
title="네이버 검색결과"
counterColor={blogCount ? 'danger' : 'positive'}
counter={checkNumber(placeDetail?.searchBlogPost?.total_count)}
counter={getNumberOrDefault(placeDetail?.searchBlogPost?.total_count)}
wrapperClassName={styles.reviewAccordionWrapper}
>
<div className={styles.resultWrapper}>
{checkEmpty(placeDetail?.searchBlogPost?.posts).map(({
{ensureArray(placeDetail?.searchBlogPost?.posts).map(({
title, description, link, thumbnail,
}) => (
<ResultCard
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useHideOnScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
RefObject, useCallback, useEffect, useMemo, useRef, useState,
} from 'react';

import { checkNumber } from '@nf-team/core';
import { getNumberOrDefault } from '@nf-team/core';
import { useThrottleCallback } from '@nf-team/react';

const DELAY_WHEN_LOAD = 300;
Expand All @@ -21,14 +21,14 @@ const useHideOnScroll = ({ rootRef, delay = 100, disabled }: UseHideOnScroll) =>
const getScrollState = useCallback(() => {
if (rootRef?.current) {
return {
scrollTop: checkNumber(rootRef.current?.scrollTop),
scrollTop: getNumberOrDefault(rootRef.current?.scrollTop),
scrollHeight: rootRef.current.scrollHeight,
clientHeight: rootRef.current.clientHeight,
};
}

return {
scrollTop: checkNumber(document.scrollingElement?.scrollTop),
scrollTop: getNumberOrDefault(document.scrollingElement?.scrollTop),
scrollHeight: document.documentElement.scrollHeight,
clientHeight: document.documentElement.clientHeight,
};
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2678,10 +2678,10 @@ __metadata:
languageName: node
linkType: hard

"@nf-team/core@npm:^2.0.3":
version: 2.0.3
resolution: "@nf-team/core@npm:2.0.3"
checksum: 10/36c3bed76489faf4e48092e8172ddcc29e38abde910503142a6d00d032ebf468a5bd97a2b017d9fbd37f480e53250c9ee4883dab98e1b8f7c1cef537b7c903e2
"@nf-team/core@npm:^3.0.1":
version: 3.0.1
resolution: "@nf-team/core@npm:3.0.1"
checksum: 10/16f0912284bebaf66245d0a4050f02ad97f7dfaa22be7d25b92dd79af5247caae3fe7651ed76aee4add835a4362209572a33c1a56d0a2aaa6031543fd0e71992
languageName: node
linkType: hard

Expand Down Expand Up @@ -12284,7 +12284,7 @@ __metadata:
"@commitlint/cli": "npm:^17.4.3"
"@commitlint/config-conventional": "npm:^17.4.3"
"@next/eslint-plugin-next": "npm:^14.2.13"
"@nf-team/core": "npm:^2.0.3"
"@nf-team/core": "npm:^3.0.1"
"@nf-team/eslint-config": "npm:^3.3.0"
"@nf-team/react": "npm:^2.6.0"
"@nf-team/storage": "npm:^1.0.1"
Expand Down
Loading