feat: 10/20 회의 반영 — 이야기 탭을 오늘 피드로 합침(글쓰기 칸·사진 올리기·위치 정보 삭제), 오늘의 각 카드와 히어로·각 공유 템플릿, 나만의 각을 이름+날씨 조건 저장으로, 로그인 없이 좋아요(IP 해시), 피드 순서·불쾌지수 상시·포스트 그림 배경, 새 각 아이콘
This commit is contained in:
1 parent
017022a0b0
commit
d0213f41a6
81 files changed
+3503
-593
No files matched your search
@@ -3,7 +3,6 @@ import { BLayout } from './b/BLayout'
|
||||
import { GakPage } from './b/GakPage'
|
||||
import { SeasonPage } from './b/SeasonPage'
|
||||
import { SkyPage } from './b/SkyPage'
|
||||
import { TalkPage } from './b/talk'
|
||||
import { TodayPage } from './b/TodayPage'
|
||||
import { WeekPage } from './b/WeekPage'
|
||||
|
||||
@@ -18,7 +17,6 @@ export default function App() {
|
||||
<Route path="sky" element={<SkyPage />} />
|
||||
<Route path="week" element={<WeekPage />} />
|
||||
<Route path="season" element={<SeasonPage />} />
|
||||
<Route path="talk" element={<TalkPage />} />
|
||||
<Route path="*" element={<TodayPage />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import { type DefaultError, type InfiniteData, infiniteQueryOptions, queryOptions, type UseMutationOptions } from '@tanstack/react-query';
|
||||
|
||||
import { client } from '../client.gen';
|
||||
import { addComment, addMyGak, addTalk, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listPlaces, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, signup, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe } from '../sdk.gen';
|
||||
import type { AddCommentData, AddCommentError, AddCommentResponse, AddMyGakData, AddMyGakError, AddMyGakResponse, AddTalkData, AddTalkError, AddTalkResponse, BlockTalkAuthorData, BlockTalkAuthorError, BlockTalkAuthorResponse, DeleteCommentData, DeleteCommentError, DeleteCommentResponse, DeleteMyGakData, DeleteMyGakError, DeleteMyGakResponse, DeleteTalkData, DeleteTalkError, DeleteTalkResponse, GetArticleData, GetArticleError, GetArticleResponse, GetFeedData, GetFeedError, GetFeedResponse, GetImageData, GetImageError, GetIndexData, GetIndexError, GetIndexResponse, GetPostData, GetPostError, GetPostResponse, GetSeasonWeekData, GetSeasonWeekResponse, GetSkyData, GetSkyError, GetSkyRankingData, GetSkyRankingResponse, GetSkyResponse, GetTodayGuPageData, GetTodayGuPageError, GetTodayGuPageResponse, GetTodayPageData, GetTodayPageError, GetTodayPageResponse, GetWatchSummaryData, GetWatchSummaryError, GetWatchSummaryResponse, GetWeatherNowData, GetWeatherNowError, GetWeatherNowResponse, GetWeatherTodayData, GetWeatherTodayError, GetWeatherTodayResponse, GetWeekData, GetWeekError, GetWeekRankingData, GetWeekRankingResponse, GetWeekResponse, HealthzHealthzGetData, HealthzHealthzGetResponse, LikeCommentData, LikeCommentError, LikeCommentResponse, LikePostData, LikePostError, LikePostResponse, LikeTalkData, LikeTalkError, LikeTalkResponse, ListArticlesData, ListArticlesError, ListArticlesResponse, ListCommentsData, ListCommentsError, ListCommentsResponse, ListEventsData, ListEventsError, ListEventsResponse, ListIndicesData, ListIndicesError, ListIndicesResponse, ListMyGakData, ListMyGakError, ListMyGakResponse, ListPlacesData, ListPlacesError, ListPlacesResponse, ListRegionsData, ListRegionsError, ListRegionsResponse, ListSavedData, ListSavedError, ListSavedResponse, ListTalksData, ListTalksError, ListTalksResponse, LoginData, LoginError, LoginResponse, LogoutData, LogoutError, LogoutResponse, MeData, MeError, MeResponse, NearestRegionData, NearestRegionError, NearestRegionResponse, RefreshData, RefreshError, RefreshResponse, ReportTalkData, ReportTalkError, ReportTalkResponse, SavePostData, SavePostError, SavePostResponse, SignupData, SignupError, SignupResponse, UnlikeCommentData, UnlikeCommentError, UnlikeCommentResponse, UnlikePostData, UnlikePostError, UnlikePostResponse, UnlikeTalkData, UnlikeTalkError, UnlikeTalkResponse, UnsavePostData, UnsavePostError, UnsavePostResponse, UpdateMeData, UpdateMeError, UpdateMeResponse } from '../types.gen';
|
||||
import { addComment, addMyGak, addTalk, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listPlaces, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, scoreMyGak, signup, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from '../sdk.gen';
|
||||
import type { AddCommentData, AddCommentError, AddCommentResponse, AddMyGakData, AddMyGakError, AddMyGakResponse, AddTalkData, AddTalkError, AddTalkResponse, BlockTalkAuthorData, BlockTalkAuthorError, BlockTalkAuthorResponse, DeleteCommentData, DeleteCommentError, DeleteCommentResponse, DeleteMyGakData, DeleteMyGakError, DeleteMyGakResponse, DeleteTalkData, DeleteTalkError, DeleteTalkResponse, GetArticleData, GetArticleError, GetArticleResponse, GetFeedData, GetFeedError, GetFeedResponse, GetImageData, GetImageError, GetIndexData, GetIndexError, GetIndexResponse, GetPostData, GetPostError, GetPostResponse, GetSeasonWeekData, GetSeasonWeekResponse, GetSkyData, GetSkyError, GetSkyRankingData, GetSkyRankingResponse, GetSkyResponse, GetTalkImageData, GetTalkImageError, GetTodayGuPageData, GetTodayGuPageError, GetTodayGuPageResponse, GetTodayPageData, GetTodayPageError, GetTodayPageResponse, GetWatchSummaryData, GetWatchSummaryError, GetWatchSummaryResponse, GetWeatherNowData, GetWeatherNowError, GetWeatherNowResponse, GetWeatherTodayData, GetWeatherTodayError, GetWeatherTodayResponse, GetWeekData, GetWeekError, GetWeekRankingData, GetWeekRankingResponse, GetWeekResponse, HealthzHealthzGetData, HealthzHealthzGetResponse, LikeCommentData, LikeCommentError, LikeCommentResponse, LikePostData, LikePostError, LikePostResponse, LikeTalkData, LikeTalkError, LikeTalkResponse, ListArticlesData, ListArticlesError, ListArticlesResponse, ListCommentsData, ListCommentsError, ListCommentsResponse, ListEventsData, ListEventsError, ListEventsResponse, ListIndicesData, ListIndicesError, ListIndicesResponse, ListMyGakData, ListMyGakError, ListMyGakResponse, ListPlacesData, ListPlacesError, ListPlacesResponse, ListRegionsData, ListRegionsError, ListRegionsResponse, ListSavedData, ListSavedError, ListSavedResponse, ListTalksData, ListTalksError, ListTalksResponse, LoginData, LoginError, LoginResponse, LogoutData, LogoutError, LogoutResponse, MeData, MeError, MeResponse, NearestRegionData, NearestRegionError, NearestRegionResponse, RefreshData, RefreshError, RefreshResponse, ReportTalkData, ReportTalkError, ReportTalkResponse, SavePostData, SavePostError, SavePostResponse, ScoreMyGakData, ScoreMyGakError, ScoreMyGakResponse, SignupData, SignupError, SignupResponse, UnlikeCommentData, UnlikeCommentError, UnlikeCommentResponse, UnlikePostData, UnlikePostError, UnlikePostResponse, UnlikeTalkData, UnlikeTalkError, UnlikeTalkResponse, UnsavePostData, UnsavePostError, UnsavePostResponse, UpdateMeData, UpdateMeError, UpdateMeResponse, UploadTalkImageData, UploadTalkImageError, UploadTalkImageResponse } from '../types.gen';
|
||||
|
||||
export type QueryKey<TOptions extends Options> = [
|
||||
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
|
||||
@@ -466,7 +466,7 @@ export const unlikePostMutation = (options?: Partial<Options<UnlikePostData>>):
|
||||
};
|
||||
|
||||
/**
|
||||
* 좋아요
|
||||
* 좋아요 (로그인 없으면 IP 당 한 번)
|
||||
*/
|
||||
export const likePostMutation = (options?: Partial<Options<LikePostData>>): UseMutationOptions<LikePostResponse, LikePostError, Options<LikePostData>> => {
|
||||
const mutationOptions: UseMutationOptions<LikePostResponse, LikePostError, Options<LikePostData>> = {
|
||||
@@ -693,7 +693,7 @@ export const unlikeCommentMutation = (options?: Partial<Options<UnlikeCommentDat
|
||||
};
|
||||
|
||||
/**
|
||||
* 댓글 좋아요
|
||||
* 댓글 좋아요 (로그인 없으면 IP 당 한 번)
|
||||
*/
|
||||
export const likeCommentMutation = (options?: Partial<Options<LikeCommentData>>): UseMutationOptions<LikeCommentResponse, LikeCommentError, Options<LikeCommentData>> => {
|
||||
const mutationOptions: UseMutationOptions<LikeCommentResponse, LikeCommentError, Options<LikeCommentData>> = {
|
||||
@@ -712,7 +712,7 @@ export const likeCommentMutation = (options?: Partial<Options<LikeCommentData>>)
|
||||
export const listMyGakQueryKey = (options?: Options<ListMyGakData>) => createQueryKey('listMyGak', options);
|
||||
|
||||
/**
|
||||
* 내 각과 섞을 수 있는 공식 각 (로그인 없이도 섞을 수 있는 목록은 보임)
|
||||
* 내 각 목록 (로그인하지 않았으면 빈 목록)
|
||||
*/
|
||||
export const listMyGakOptions = (options?: Options<ListMyGakData>) => queryOptions<ListMyGakResponse, ListMyGakError, ListMyGakResponse, ReturnType<typeof listMyGakQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
@@ -728,7 +728,7 @@ export const listMyGakOptions = (options?: Options<ListMyGakData>) => queryOptio
|
||||
});
|
||||
|
||||
/**
|
||||
* 공식 각 두 개를 섞어 내 각 만들기 (같은 조합이면 있는 것을 돌려줌)
|
||||
* 이름과 날씨 조건으로 내 각 만들기
|
||||
*/
|
||||
export const addMyGakMutation = (options?: Partial<Options<AddMyGakData>>): UseMutationOptions<AddMyGakResponse, AddMyGakError, Options<AddMyGakData>> => {
|
||||
const mutationOptions: UseMutationOptions<AddMyGakResponse, AddMyGakError, Options<AddMyGakData>> = {
|
||||
@@ -744,6 +744,23 @@ export const addMyGakMutation = (options?: Partial<Options<AddMyGakData>>): UseM
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 조건들의 그 동네 오늘 점수 (로그인 없이, 받은 링크의 각도)
|
||||
*/
|
||||
export const scoreMyGakMutation = (options?: Partial<Options<ScoreMyGakData>>): UseMutationOptions<ScoreMyGakResponse, ScoreMyGakError, Options<ScoreMyGakData>> => {
|
||||
const mutationOptions: UseMutationOptions<ScoreMyGakResponse, ScoreMyGakError, Options<ScoreMyGakData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await scoreMyGak({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 내 각 지우기
|
||||
*/
|
||||
@@ -826,6 +843,41 @@ export const addTalkMutation = (options?: Partial<Options<AddTalkData>>): UseMut
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 글에 붙일 사진 올리기 (10MB까지, 위치 정보를 지우고 1080px로 줄여 저장)
|
||||
*/
|
||||
export const uploadTalkImageMutation = (options?: Partial<Options<UploadTalkImageData>>): UseMutationOptions<UploadTalkImageResponse, UploadTalkImageError, Options<UploadTalkImageData>> => {
|
||||
const mutationOptions: UseMutationOptions<UploadTalkImageResponse, UploadTalkImageError, Options<UploadTalkImageData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await uploadTalkImage({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getTalkImageQueryKey = (options: Options<GetTalkImageData>) => createQueryKey('getTalkImage', options);
|
||||
|
||||
/**
|
||||
* 올린 사진
|
||||
*/
|
||||
export const getTalkImageOptions = (options: Options<GetTalkImageData>) => queryOptions<unknown, GetTalkImageError, unknown, ReturnType<typeof getTalkImageQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await getTalkImage({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: getTalkImageQueryKey(options)
|
||||
});
|
||||
|
||||
/**
|
||||
* 내 이야기 지우기
|
||||
*/
|
||||
@@ -861,7 +913,7 @@ export const unlikeTalkMutation = (options?: Partial<Options<UnlikeTalkData>>):
|
||||
};
|
||||
|
||||
/**
|
||||
* 이야기 좋아요
|
||||
* 이야기 좋아요 (로그인 없으면 IP 당 한 번)
|
||||
*/
|
||||
export const likeTalkMutation = (options?: Partial<Options<LikeTalkData>>): UseMutationOptions<LikeTalkResponse, LikeTalkError, Options<LikeTalkData>> => {
|
||||
const mutationOptions: UseMutationOptions<LikeTalkResponse, LikeTalkError, Options<LikeTalkData>> = {
|
||||
|
||||
@@ -13,4 +13,4 @@ import type { ClientOptions as ClientOptions2 } from './types.gen';
|
||||
*/
|
||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
||||
|
||||
export const client: Client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:9810', throwOnError: true }));
|
||||
export const client: Client = createClient(createConfig<ClientOptions2>({ baseUrl: 'http://localhost:9811', throwOnError: true }));
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
export { addComment, addMyGak, addTalk, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listPlaces, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, signup, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe } from './sdk.gen';
|
||||
export { type AddCommentData, type AddCommentError, type AddCommentErrors, type AddCommentResponse, type AddCommentResponses, type AddMyGakData, type AddMyGakError, type AddMyGakErrors, type AddMyGakResponse, type AddMyGakResponses, type AddTalkData, type AddTalkError, type AddTalkErrors, type AddTalkResponse, type AddTalkResponses, type AirData, AirGrade, ArticleCategory, type ArticleSummary, AuthProvider, type BandArticle, type BandEvent, type Bands, type BestTime, type BlockTalkAuthorData, type BlockTalkAuthorError, type BlockTalkAuthorErrors, type BlockTalkAuthorResponse, type BlockTalkAuthorResponses, type ClientOptions, type CommentData, type CommuteData, Confidence, type Cut, type DayData, type DeleteCommentData, type DeleteCommentError, type DeleteCommentErrors, type DeleteCommentResponse, type DeleteCommentResponses, type DeleteMyGakData, type DeleteMyGakError, type DeleteMyGakErrors, type DeleteMyGakResponse, type DeleteMyGakResponses, type DeleteTalkData, type DeleteTalkError, type DeleteTalkErrors, type DeleteTalkResponse, type DeleteTalkResponses, type ErrorInfo, type EventData, type Factor, type GakSlide, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type GetFeedData, type GetFeedError, type GetFeedErrors, type GetFeedResponse, type GetFeedResponses, type GetImageData, type GetImageError, type GetImageErrors, type GetImageResponses, type GetIndexData, type GetIndexError, type GetIndexErrors, type GetIndexResponse, type GetIndexResponses, type GetPostData, type GetPostError, type GetPostErrors, type GetPostResponse, type GetPostResponses, type GetSeasonWeekData, type GetSeasonWeekResponse, type GetSeasonWeekResponses, type GetSkyData, type GetSkyError, type GetSkyErrors, type GetSkyRankingData, type GetSkyRankingResponse, type GetSkyRankingResponses, type GetSkyResponse, type GetSkyResponses, type GetTodayGuPageData, type GetTodayGuPageError, type GetTodayGuPageErrors, type GetTodayGuPageResponse, type GetTodayGuPageResponses, type GetTodayPageData, type GetTodayPageError, type GetTodayPageErrors, type GetTodayPageResponse, type GetTodayPageResponses, type GetWatchSummaryData, type GetWatchSummaryError, type GetWatchSummaryErrors, type GetWatchSummaryResponse, type GetWatchSummaryResponses, type GetWeatherNowData, type GetWeatherNowError, type GetWeatherNowErrors, type GetWeatherNowResponse, type GetWeatherNowResponses, type GetWeatherTodayData, type GetWeatherTodayError, type GetWeatherTodayErrors, type GetWeatherTodayResponse, type GetWeatherTodayResponses, type GetWeekData, type GetWeekError, type GetWeekErrors, type GetWeekRankingData, type GetWeekRankingResponse, type GetWeekRankingResponses, type GetWeekResponse, type GetWeekResponses, type HealthzHealthzGetData, type HealthzHealthzGetResponse, type HealthzHealthzGetResponses, type Hero, type HeroStat, type HourCell, type HoursSlide, type HttpValidationError, IndexCategory, type IndexSummary, type LikeCommentData, type LikeCommentError, type LikeCommentErrors, type LikeCommentResponse, type LikeCommentResponses, type LikePostData, type LikePostError, type LikePostErrors, type LikePostResponse, type LikePostResponses, type LikeTalkData, type LikeTalkError, type LikeTalkErrors, type LikeTalkResponse, type LikeTalkResponses, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponses, type ListCommentsData, type ListCommentsError, type ListCommentsErrors, type ListCommentsResponse, type ListCommentsResponses, type ListEventsData, type ListEventsError, type ListEventsErrors, type ListEventsResponse, type ListEventsResponses, type ListIndicesData, type ListIndicesError, type ListIndicesErrors, type ListIndicesResponse, type ListIndicesResponses, type ListMyGakData, type ListMyGakError, type ListMyGakErrors, type ListMyGakResponse, type ListMyGakResponses, type ListPlacesData, type ListPlacesError, type ListPlacesErrors, type ListPlacesResponse, type ListPlacesResponses, type ListRegionsData, type ListRegionsError, type ListRegionsErrors, type ListRegionsResponse, type ListRegionsResponses, type ListSavedData, type ListSavedError, type ListSavedErrors, type ListSavedResponse, type ListSavedResponses, type ListTalksData, type ListTalksError, type ListTalksErrors, type ListTalksResponse, type ListTalksResponses, type LoginData, type LoginError, type LoginErrors, type LoginResponse, type LoginResponses, type LogoutData, type LogoutError, type LogoutErrors, type LogoutResponse, type LogoutResponses, type Me, type MeData, type MeError, type MeErrors, type MeResponse, type MeResponses, type MyGakData, type NearestRegionData, type NearestRegionError, type NearestRegionErrors, type NearestRegionResponse, type NearestRegionResponses, type PlaceData, type PlanSlide, type PlanSpot, type PlanStep, type PostData, PostType, type Rain2h, type RainHourData, RainType, type RankData, type RefreshData, type RefreshError, type RLine truncated
|
||||
export { addComment, addMyGak, addTalk, blockTalkAuthor, deleteComment, deleteMyGak, deleteTalk, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTalkImage, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, healthzHealthzGet, likeComment, likePost, likeTalk, listArticles, listComments, listEvents, listIndices, listMyGak, listPlaces, listRegions, listSaved, listTalks, login, logout, me, nearestRegion, type Options, refresh, reportTalk, savePost, scoreMyGak, signup, unlikeComment, unlikePost, unlikeTalk, unsavePost, updateMe, uploadTalkImage } from './sdk.gen';
|
||||
export { type AddCommentData, type AddCommentError, type AddCommentErrors, type AddCommentResponse, type AddCommentResponses, type AddMyGakData, type AddMyGakError, type AddMyGakErrors, type AddMyGakResponse, type AddMyGakResponses, type AddTalkData, type AddTalkError, type AddTalkErrors, type AddTalkResponse, type AddTalkResponses, type AirData, AirGrade, ArticleCategory, type ArticleSummary, AuthProvider, type BandArticle, type BandEvent, type Bands, type BestTime, type BlockTalkAuthorData, type BlockTalkAuthorError, type BlockTalkAuthorErrors, type BlockTalkAuthorResponse, type BlockTalkAuthorResponses, type BodyUploadTalkImageV1TalkImagePost, type ClientOptions, type CommentData, type CommuteData, Confidence, type Cut, type DayData, type DeleteCommentData, type DeleteCommentError, type DeleteCommentErrors, type DeleteCommentResponse, type DeleteCommentResponses, type DeleteMyGakData, type DeleteMyGakError, type DeleteMyGakErrors, type DeleteMyGakResponse, type DeleteMyGakResponses, type DeleteTalkData, type DeleteTalkError, type DeleteTalkErrors, type DeleteTalkResponse, type DeleteTalkResponses, type ErrorInfo, type EventData, type Factor, type GakSlide, type GetArticleData, type GetArticleError, type GetArticleErrors, type GetArticleResponse, type GetArticleResponses, type GetFeedData, type GetFeedError, type GetFeedErrors, type GetFeedResponse, type GetFeedResponses, type GetImageData, type GetImageError, type GetImageErrors, type GetImageResponses, type GetIndexData, type GetIndexError, type GetIndexErrors, type GetIndexResponse, type GetIndexResponses, type GetPostData, type GetPostError, type GetPostErrors, type GetPostResponse, type GetPostResponses, type GetSeasonWeekData, type GetSeasonWeekResponse, type GetSeasonWeekResponses, type GetSkyData, type GetSkyError, type GetSkyErrors, type GetSkyRankingData, type GetSkyRankingResponse, type GetSkyRankingResponses, type GetSkyResponse, type GetSkyResponses, type GetTalkImageData, type GetTalkImageError, type GetTalkImageErrors, type GetTalkImageResponses, type GetTodayGuPageData, type GetTodayGuPageError, type GetTodayGuPageErrors, type GetTodayGuPageResponse, type GetTodayGuPageResponses, type GetTodayPageData, type GetTodayPageError, type GetTodayPageErrors, type GetTodayPageResponse, type GetTodayPageResponses, type GetWatchSummaryData, type GetWatchSummaryError, type GetWatchSummaryErrors, type GetWatchSummaryResponse, type GetWatchSummaryResponses, type GetWeatherNowData, type GetWeatherNowError, type GetWeatherNowErrors, type GetWeatherNowResponse, type GetWeatherNowResponses, type GetWeatherTodayData, type GetWeatherTodayError, type GetWeatherTodayErrors, type GetWeatherTodayResponse, type GetWeatherTodayResponses, type GetWeekData, type GetWeekError, type GetWeekErrors, type GetWeekRankingData, type GetWeekRankingResponse, type GetWeekRankingResponses, type GetWeekResponse, type GetWeekResponses, type HealthzHealthzGetData, type HealthzHealthzGetResponse, type HealthzHealthzGetResponses, type Hero, type HeroStat, type HourCell, type HoursSlide, type HttpValidationError, IndexCategory, type IndexSummary, type LikeCommentData, type LikeCommentError, type LikeCommentErrors, type LikeCommentResponse, type LikeCommentResponses, type LikePostData, type LikePostError, type LikePostErrors, type LikePostResponse, type LikePostResponses, type LikeTalkData, type LikeTalkError, type LikeTalkErrors, type LikeTalkResponse, type LikeTalkResponses, type ListArticlesData, type ListArticlesError, type ListArticlesErrors, type ListArticlesResponse, type ListArticlesResponses, type ListCommentsData, type ListCommentsError, type ListCommentsErrors, type ListCommentsResponse, type ListCommentsResponses, type ListEventsData, type ListEventsError, type ListEventsErrors, type ListEventsResponse, type ListEventsResponses, type ListIndicesData, type ListIndicesError, type ListIndicesErrors, type ListIndicesResponse, type ListIndicesResponses, type ListMyGakData, type ListMyGakError, type ListMyGakErrors, type ListMyGakResponse, type ListMyGakResponses, type ListPlacesData, type ListPlacesError, type ListPlacesErrors, type ListPlacesResponse, type ListPlacesResponses, type ListRegionsData, type ListRegionsError, type ListRegionsErrors, type ListRegionsResponse, type ListRegionsResponses, type ListSavedData, type ListSavedError, type ListSavedErrors, type ListSavedResponse, type ListSavedResponses, type ListTalksData, type ListTalksError, type ListTalksErrors, type ListTalksResponse, type ListTalksResponses, type LoginData, type LoginError, type LoginErrors, type LoginResponse, type LoginResponses, type LogoutData, type LogoutError, type LogoutErrors, type LogoutResponse, type LogoutResponses, type Me, type MeData, type MeError, type MeErrors, type MeResponse, type MeResponses, type MyGakData, type MyGakRule, type MyGakScore, type NearestRegionData, type NearestRegionError, type NearestRegionErrors, type NearestRegionResponse, type NearestRegionResponses, type PlaceDatLine truncated
|
||||
@@ -1,8 +1,8 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client';
|
||||
import { type Client, type ClientMeta, formDataBodySerializer, type Options as Options2, type RequestResult, type TDataShape } from './client';
|
||||
import { client } from './client.gen';
|
||||
import type { AddCommentData, AddCommentErrors, AddCommentResponses, AddMyGakData, AddMyGakErrors, AddMyGakResponses, AddTalkData, AddTalkErrors, AddTalkResponses, BlockTalkAuthorData, BlockTalkAuthorErrors, BlockTalkAuthorResponses, DeleteCommentData, DeleteCommentErrors, DeleteCommentResponses, DeleteMyGakData, DeleteMyGakErrors, DeleteMyGakResponses, DeleteTalkData, DeleteTalkErrors, DeleteTalkResponses, GetArticleData, GetArticleErrors, GetArticleResponses, GetFeedData, GetFeedErrors, GetFeedResponses, GetImageData, GetImageErrors, GetImageResponses, GetIndexData, GetIndexErrors, GetIndexResponses, GetPostData, GetPostErrors, GetPostResponses, GetSeasonWeekData, GetSeasonWeekResponses, GetSkyData, GetSkyErrors, GetSkyRankingData, GetSkyRankingResponses, GetSkyResponses, GetTodayGuPageData, GetTodayGuPageErrors, GetTodayGuPageResponses, GetTodayPageData, GetTodayPageErrors, GetTodayPageResponses, GetWatchSummaryData, GetWatchSummaryErrors, GetWatchSummaryResponses, GetWeatherNowData, GetWeatherNowErrors, GetWeatherNowResponses, GetWeatherTodayData, GetWeatherTodayErrors, GetWeatherTodayResponses, GetWeekData, GetWeekErrors, GetWeekRankingData, GetWeekRankingResponses, GetWeekResponses, HealthzHealthzGetData, HealthzHealthzGetResponses, LikeCommentData, LikeCommentErrors, LikeCommentResponses, LikePostData, LikePostErrors, LikePostResponses, LikeTalkData, LikeTalkErrors, LikeTalkResponses, ListArticlesData, ListArticlesErrors, ListArticlesResponses, ListCommentsData, ListCommentsErrors, ListCommentsResponses, ListEventsData, ListEventsErrors, ListEventsResponses, ListIndicesData, ListIndicesErrors, ListIndicesResponses, ListMyGakData, ListMyGakErrors, ListMyGakResponses, ListPlacesData, ListPlacesErrors, ListPlacesResponses, ListRegionsData, ListRegionsErrors, ListRegionsResponses, ListSavedData, ListSavedErrors, ListSavedResponses, ListTalksData, ListTalksErrors, ListTalksResponses, LoginData, LoginErrors, LoginResponses, LogoutData, LogoutErrors, LogoutResponses, MeData, MeErrors, MeResponses, NearestRegionData, NearestRegionErrors, NearestRegionResponses, RefreshData, RefreshErrors, RefreshResponses, ReportTalkData, ReportTalkErrors, ReportTalkResponses, SavePostData, SavePostErrors, SavePostResponses, SignupData, SignupErrors, SignupResponses, UnlikeCommentData, UnlikeCommentErrors, UnlikeCommentResponses, UnlikePostData, UnlikePostErrors, UnlikePostResponses, UnlikeTalkData, UnlikeTalkErrors, UnlikeTalkResponses, UnsavePostData, UnsavePostErrors, UnsavePostResponses, UpdateMeData, UpdateMeErrors, UpdateMeResponses } from './types.gen';
|
||||
import type { AddCommentData, AddCommentErrors, AddCommentResponses, AddMyGakData, AddMyGakErrors, AddMyGakResponses, AddTalkData, AddTalkErrors, AddTalkResponses, BlockTalkAuthorData, BlockTalkAuthorErrors, BlockTalkAuthorResponses, DeleteCommentData, DeleteCommentErrors, DeleteCommentResponses, DeleteMyGakData, DeleteMyGakErrors, DeleteMyGakResponses, DeleteTalkData, DeleteTalkErrors, DeleteTalkResponses, GetArticleData, GetArticleErrors, GetArticleResponses, GetFeedData, GetFeedErrors, GetFeedResponses, GetImageData, GetImageErrors, GetImageResponses, GetIndexData, GetIndexErrors, GetIndexResponses, GetPostData, GetPostErrors, GetPostResponses, GetSeasonWeekData, GetSeasonWeekResponses, GetSkyData, GetSkyErrors, GetSkyRankingData, GetSkyRankingResponses, GetSkyResponses, GetTalkImageData, GetTalkImageErrors, GetTalkImageResponses, GetTodayGuPageData, GetTodayGuPageErrors, GetTodayGuPageResponses, GetTodayPageData, GetTodayPageErrors, GetTodayPageResponses, GetWatchSummaryData, GetWatchSummaryErrors, GetWatchSummaryResponses, GetWeatherNowData, GetWeatherNowErrors, GetWeatherNowResponses, GetWeatherTodayData, GetWeatherTodayErrors, GetWeatherTodayResponses, GetWeekData, GetWeekErrors, GetWeekRankingData, GetWeekRankingResponses, GetWeekResponses, HealthzHealthzGetData, HealthzHealthzGetResponses, LikeCommentData, LikeCommentErrors, LikeCommentResponses, LikePostData, LikePostErrors, LikePostResponses, LikeTalkData, LikeTalkErrors, LikeTalkResponses, ListArticlesData, ListArticlesErrors, ListArticlesResponses, ListCommentsData, ListCommentsErrors, ListCommentsResponses, ListEventsData, ListEventsErrors, ListEventsResponses, ListIndicesData, ListIndicesErrors, ListIndicesResponses, ListMyGakData, ListMyGakErrors, ListMyGakResponses, ListPlacesData, ListPlacesErrors, ListPlacesResponses, ListRegionsData, ListRegionsErrors, ListRegionsResponses, ListSavedData, ListSavedErrors, ListSavedResponses, ListTalksData, ListTalksErrors, ListTalksResponses, LoginData, LoginErrors, LoginResponses, LogoutData, LogoutErrors, LogoutResponses, MeData, MeErrors, MeResponses, NearestRegionData, NearestRegionErrors, NearestRegionResponses, RefreshData, RefreshErrors, RefreshResponses, ReportTalkData, ReportTalkErrors, ReportTalkResponses, SavePostData, SavePostErrors, SavePostResponses, ScoreMyGakData, ScoreMyGakErrors, ScoreMyGakResponses, SignupData, SignupErrors, SignupResponses, UnlikeCommentData, UnlikeCommentErrors, UnlikeCommentResponses, UnlikePostData, UnlikePostErrors, UnlikePostResponses, UnlikeTalkData, UnlikeTalkErrors, UnlikeTalkResponses, UnsavePostData, UnsavePostErrors, UnsavePostResponses, UpdateMeData, UpdateMeErrors, UpdateMeResponses, UploadTalkImageData, UploadTalkImageErrors, UploadTalkImageResponses } from './types.gen';
|
||||
|
||||
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ export const updateMe = <ThrowOnError extends boolean = true>(options: Options<U
|
||||
export const unlikePost = <ThrowOnError extends boolean = true>(options: Options<UnlikePostData, ThrowOnError>): RequestResult<UnlikePostResponses, UnlikePostErrors, ThrowOnError> => (options.client ?? client).delete<UnlikePostResponses, UnlikePostErrors, ThrowOnError>({ url: '/v1/reaction/post/{post_id}/like', ...options });
|
||||
|
||||
/**
|
||||
* 좋아요
|
||||
* 좋아요 (로그인 없으면 IP 당 한 번)
|
||||
*/
|
||||
export const likePost = <ThrowOnError extends boolean = true>(options: Options<LikePostData, ThrowOnError>): RequestResult<LikePostResponses, LikePostErrors, ThrowOnError> => (options.client ?? client).post<LikePostResponses, LikePostErrors, ThrowOnError>({ url: '/v1/reaction/post/{post_id}/like', ...options });
|
||||
|
||||
@@ -214,17 +214,17 @@ export const deleteComment = <ThrowOnError extends boolean = true>(options: Opti
|
||||
export const unlikeComment = <ThrowOnError extends boolean = true>(options: Options<UnlikeCommentData, ThrowOnError>): RequestResult<UnlikeCommentResponses, UnlikeCommentErrors, ThrowOnError> => (options.client ?? client).delete<UnlikeCommentResponses, UnlikeCommentErrors, ThrowOnError>({ url: '/v1/reaction/comment/{comment_id}/like', ...options });
|
||||
|
||||
/**
|
||||
* 댓글 좋아요
|
||||
* 댓글 좋아요 (로그인 없으면 IP 당 한 번)
|
||||
*/
|
||||
export const likeComment = <ThrowOnError extends boolean = true>(options: Options<LikeCommentData, ThrowOnError>): RequestResult<LikeCommentResponses, LikeCommentErrors, ThrowOnError> => (options.client ?? client).post<LikeCommentResponses, LikeCommentErrors, ThrowOnError>({ url: '/v1/reaction/comment/{comment_id}/like', ...options });
|
||||
|
||||
/**
|
||||
* 내 각과 섞을 수 있는 공식 각 (로그인 없이도 섞을 수 있는 목록은 보임)
|
||||
* 내 각 목록 (로그인하지 않았으면 빈 목록)
|
||||
*/
|
||||
export const listMyGak = <ThrowOnError extends boolean = true>(options?: Options<ListMyGakData, ThrowOnError>): RequestResult<ListMyGakResponses, ListMyGakErrors, ThrowOnError> => (options?.client ?? client).get<ListMyGakResponses, ListMyGakErrors, ThrowOnError>({ url: '/v1/my-gak', ...options });
|
||||
|
||||
/**
|
||||
* 공식 각 두 개를 섞어 내 각 만들기 (같은 조합이면 있는 것을 돌려줌)
|
||||
* 이름과 날씨 조건으로 내 각 만들기
|
||||
*/
|
||||
export const addMyGak = <ThrowOnError extends boolean = true>(options: Options<AddMyGakData, ThrowOnError>): RequestResult<AddMyGakResponses, AddMyGakErrors, ThrowOnError> => (options.client ?? client).post<AddMyGakResponses, AddMyGakErrors, ThrowOnError>({
|
||||
url: '/v1/my-gak',
|
||||
@@ -235,6 +235,18 @@ export const addMyGak = <ThrowOnError extends boolean = true>(options: Options<A
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 조건들의 그 동네 오늘 점수 (로그인 없이, 받은 링크의 각도)
|
||||
*/
|
||||
export const scoreMyGak = <ThrowOnError extends boolean = true>(options: Options<ScoreMyGakData, ThrowOnError>): RequestResult<ScoreMyGakResponses, ScoreMyGakErrors, ThrowOnError> => (options.client ?? client).post<ScoreMyGakResponses, ScoreMyGakErrors, ThrowOnError>({
|
||||
url: '/v1/my-gak/score',
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 내 각 지우기
|
||||
*/
|
||||
@@ -257,6 +269,24 @@ export const addTalk = <ThrowOnError extends boolean = true>(options: Options<Ad
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 글에 붙일 사진 올리기 (10MB까지, 위치 정보를 지우고 1080px로 줄여 저장)
|
||||
*/
|
||||
export const uploadTalkImage = <ThrowOnError extends boolean = true>(options: Options<UploadTalkImageData, ThrowOnError>): RequestResult<UploadTalkImageResponses, UploadTalkImageErrors, ThrowOnError> => (options.client ?? client).post<UploadTalkImageResponses, UploadTalkImageErrors, ThrowOnError>({
|
||||
...formDataBodySerializer,
|
||||
url: '/v1/talk/image',
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': null,
|
||||
...options.headers
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 올린 사진
|
||||
*/
|
||||
export const getTalkImage = <ThrowOnError extends boolean = true>(options: Options<GetTalkImageData, ThrowOnError>): RequestResult<GetTalkImageResponses, GetTalkImageErrors, ThrowOnError> => (options.client ?? client).get<GetTalkImageResponses, GetTalkImageErrors, ThrowOnError>({ url: '/v1/talk/image/{name}', ...options });
|
||||
|
||||
/**
|
||||
* 내 이야기 지우기
|
||||
*/
|
||||
@@ -268,7 +298,7 @@ export const deleteTalk = <ThrowOnError extends boolean = true>(options: Options
|
||||
export const unlikeTalk = <ThrowOnError extends boolean = true>(options: Options<UnlikeTalkData, ThrowOnError>): RequestResult<UnlikeTalkResponses, UnlikeTalkErrors, ThrowOnError> => (options.client ?? client).delete<UnlikeTalkResponses, UnlikeTalkErrors, ThrowOnError>({ url: '/v1/talk/{talk_id}/like', ...options });
|
||||
|
||||
/**
|
||||
* 이야기 좋아요
|
||||
* 이야기 좋아요 (로그인 없으면 IP 당 한 번)
|
||||
*/
|
||||
export const likeTalk = <ThrowOnError extends boolean = true>(options: Options<LikeTalkData, ThrowOnError>): RequestResult<LikeTalkResponses, LikeTalkErrors, ThrowOnError> => (options.client ?? client).post<LikeTalkResponses, LikeTalkErrors, ThrowOnError>({ url: '/v1/talk/{talk_id}/like', ...options });
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
export type ClientOptions = {
|
||||
baseUrl: `${string}://${string}` | (string & {});
|
||||
baseUrl: 'http://localhost:9811' | (string & {});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -238,6 +238,16 @@ export type BestTime = {
|
||||
end?: string | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Body_upload_talk_image_v1_talk_image_post
|
||||
*/
|
||||
export type BodyUploadTalkImageV1TalkImagePost = {
|
||||
/**
|
||||
* File
|
||||
*/
|
||||
file: Blob | File;
|
||||
};
|
||||
|
||||
/**
|
||||
* CommentData
|
||||
*/
|
||||
@@ -839,11 +849,90 @@ export type MyGakData = {
|
||||
*/
|
||||
my_gak_id: number;
|
||||
/**
|
||||
* Index Ids
|
||||
*
|
||||
* 섞은 공식 각 두 개. 점수는 두 각의 오늘 점수 중 낮은 쪽
|
||||
* Name
|
||||
*/
|
||||
index_ids: Array<number>;
|
||||
name: string;
|
||||
rule: MyGakRule;
|
||||
};
|
||||
|
||||
/**
|
||||
* MyGakRule
|
||||
*/
|
||||
export type MyGakRule = {
|
||||
/**
|
||||
* Temp
|
||||
*
|
||||
* 체감온도 범위 [최저, 최고]° (-20~40)
|
||||
*/
|
||||
temp?: [
|
||||
number,
|
||||
number
|
||||
] | null;
|
||||
/**
|
||||
* Rain
|
||||
*
|
||||
* dry: 비 안 와야 / wet: 비 와야 / 없으면 상관없음
|
||||
*/
|
||||
rain?: 'dry' | 'wet' | null;
|
||||
/**
|
||||
* Wind Max
|
||||
*
|
||||
* 바람 상한 m/s
|
||||
*/
|
||||
wind_max?: number | null;
|
||||
/**
|
||||
* Air
|
||||
*
|
||||
* 미세먼지 허용 단계: good 좋음까지 / normal 보통까지
|
||||
*/
|
||||
air?: 'good' | 'normal' | null;
|
||||
/**
|
||||
* Humidity
|
||||
*
|
||||
* 습도 범위 [최저, 최고]%
|
||||
*/
|
||||
humidity?: [
|
||||
number,
|
||||
number
|
||||
] | null;
|
||||
/**
|
||||
* Slots
|
||||
*
|
||||
* 볼 시간대
|
||||
*/
|
||||
slots?: Array<'morning' | 'day' | 'evening' | 'night'>;
|
||||
};
|
||||
|
||||
/**
|
||||
* MyGakScore
|
||||
*/
|
||||
export type MyGakScore = {
|
||||
/**
|
||||
* Score
|
||||
*
|
||||
* 지금 시간대 점수. 지금이 고른 시간대가 아니면 고른 시간대 중 가장 좋은 점수. 예보가 없으면 null
|
||||
*/
|
||||
score?: number | null;
|
||||
/**
|
||||
* Slot
|
||||
*
|
||||
* score 가 어느 시간대 점수인지
|
||||
*/
|
||||
slot?: 'morning' | 'day' | 'evening' | 'night' | null;
|
||||
/**
|
||||
* Slots
|
||||
*
|
||||
* 고른 시간대별 점수 (아침·낮·저녁·밤 순)
|
||||
*/
|
||||
slots?: {
|
||||
[key: string]: number;
|
||||
};
|
||||
/**
|
||||
* Reasons
|
||||
*
|
||||
* score 근거: 조건마다 그 시간대 실제 값
|
||||
*/
|
||||
reasons?: Array<string>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1240,14 +1329,26 @@ export type ReqLogin = {
|
||||
*/
|
||||
export type ReqMyGak = {
|
||||
/**
|
||||
* Index Ids
|
||||
* Name
|
||||
*
|
||||
* 섞을 공식 각 두 개
|
||||
* 내 각 이름 (끝에 '각'이 없으면 붙인다)
|
||||
*/
|
||||
index_ids: [
|
||||
number,
|
||||
number
|
||||
];
|
||||
name: string;
|
||||
rule: MyGakRule;
|
||||
};
|
||||
|
||||
/**
|
||||
* Req_MyGakScore
|
||||
*/
|
||||
export type ReqMyGakScore = {
|
||||
/**
|
||||
* Region Code
|
||||
*/
|
||||
region_code: string;
|
||||
/**
|
||||
* Rules
|
||||
*/
|
||||
rules: Array<MyGakRule>;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1292,6 +1393,12 @@ export type ReqTalk = {
|
||||
* 공백을 줄인 뒤 100자까지
|
||||
*/
|
||||
body: string;
|
||||
/**
|
||||
* Image
|
||||
*
|
||||
* 먼저 올린 사진 주소 (POST /v1/talk/image 결과)
|
||||
*/
|
||||
image?: string | null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1610,12 +1717,6 @@ export type ResMyGakList = {
|
||||
* Msg
|
||||
*/
|
||||
msg?: string | null;
|
||||
/**
|
||||
* Mixable
|
||||
*
|
||||
* 섞을 수 있는 공식 각 index_id
|
||||
*/
|
||||
mixable?: Array<number>;
|
||||
/**
|
||||
* Items
|
||||
*
|
||||
@@ -1624,6 +1725,25 @@ export type ResMyGakList = {
|
||||
items?: Array<MyGakData>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Res_MyGakScore
|
||||
*/
|
||||
export type ResMyGakScore = {
|
||||
result?: ErrorInfo;
|
||||
/**
|
||||
* Msg
|
||||
*/
|
||||
msg?: string | null;
|
||||
/**
|
||||
* Now Slot
|
||||
*/
|
||||
now_slot?: 'morning' | 'day' | 'evening' | 'night' | null;
|
||||
/**
|
||||
* Scores
|
||||
*/
|
||||
scores?: Array<MyGakScore>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Res_PlaceList
|
||||
*/
|
||||
@@ -1861,6 +1981,23 @@ export type ResTalk = {
|
||||
talk?: TalkData | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Res_TalkImage
|
||||
*/
|
||||
export type ResTalkImage = {
|
||||
result?: ErrorInfo;
|
||||
/**
|
||||
* Msg
|
||||
*/
|
||||
msg?: string | null;
|
||||
/**
|
||||
* Image
|
||||
*
|
||||
* 글에 붙일 사진 주소
|
||||
*/
|
||||
image?: string | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Res_TalkLike
|
||||
*/
|
||||
@@ -2544,6 +2681,12 @@ export type TalkData = {
|
||||
* Body
|
||||
*/
|
||||
body: string;
|
||||
/**
|
||||
* Image
|
||||
*
|
||||
* 올린 사진 주소
|
||||
*/
|
||||
image?: string | null;
|
||||
/**
|
||||
* Like Count
|
||||
*/
|
||||
@@ -4245,6 +4388,31 @@ export type AddMyGakResponses = {
|
||||
|
||||
export type AddMyGakResponse = AddMyGakResponses[keyof AddMyGakResponses];
|
||||
|
||||
export type ScoreMyGakData = {
|
||||
body: ReqMyGakScore;
|
||||
path?: never;
|
||||
query?: never;
|
||||
url: '/v1/my-gak/score';
|
||||
};
|
||||
|
||||
export type ScoreMyGakErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type ScoreMyGakError = ScoreMyGakErrors[keyof ScoreMyGakErrors];
|
||||
|
||||
export type ScoreMyGakResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: ResMyGakScore;
|
||||
};
|
||||
|
||||
export type ScoreMyGakResponse = ScoreMyGakResponses[keyof ScoreMyGakResponses];
|
||||
|
||||
export type DeleteMyGakData = {
|
||||
body?: never;
|
||||
headers?: {
|
||||
@@ -4348,6 +4516,65 @@ export type AddTalkResponses = {
|
||||
|
||||
export type AddTalkResponse = AddTalkResponses[keyof AddTalkResponses];
|
||||
|
||||
export type UploadTalkImageData = {
|
||||
body: BodyUploadTalkImageV1TalkImagePost;
|
||||
headers?: {
|
||||
/**
|
||||
* Authorization
|
||||
*/
|
||||
authorization?: string | null;
|
||||
};
|
||||
path?: never;
|
||||
query?: never;
|
||||
url: '/v1/talk/image';
|
||||
};
|
||||
|
||||
export type UploadTalkImageErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type UploadTalkImageError = UploadTalkImageErrors[keyof UploadTalkImageErrors];
|
||||
|
||||
export type UploadTalkImageResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: ResTalkImage;
|
||||
};
|
||||
|
||||
export type UploadTalkImageResponse = UploadTalkImageResponses[keyof UploadTalkImageResponses];
|
||||
|
||||
export type GetTalkImageData = {
|
||||
body?: never;
|
||||
path: {
|
||||
/**
|
||||
* Name
|
||||
*/
|
||||
name: string;
|
||||
};
|
||||
query?: never;
|
||||
url: '/v1/talk/image/{name}';
|
||||
};
|
||||
|
||||
export type GetTalkImageErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type GetTalkImageError = GetTalkImageErrors[keyof GetTalkImageErrors];
|
||||
|
||||
export type GetTalkImageResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: unknown;
|
||||
};
|
||||
|
||||
export type DeleteTalkData = {
|
||||
body?: never;
|
||||
headers?: {
|
||||
|
||||
@@ -20,7 +20,6 @@ const TABS = [
|
||||
{ to: '/gak', key: 'gak', label: '각', title: '오늘의 각' },
|
||||
// 메인인 오늘 탭을 가운데에
|
||||
{ to: '/', key: 'today', label: '오늘', title: null },
|
||||
{ to: '/talk', key: 'talk', label: '이야기', title: '동네 이야기' },
|
||||
{ to: '/week', key: 'week', label: '주말·행사', title: '주말·행사' },
|
||||
{ to: '/season', key: 'season', label: '계절·상식', title: '계절·상식' },
|
||||
] as const
|
||||
|
||||
+62
-9
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef, useState, type CSSProperties, type MouseEvent, type ReactNode } from 'react'
|
||||
import { useEffect, useRef, useState, type CSSProperties, type MouseEvent, type ReactNode, type RefObject } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { PostType, SlotTone, type GakSlide, type HoursSlide, type PlanSlide, type PostData, type ResFeed, type RowsSlide, type SunsetSlide, type WeekSlide } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
@@ -7,7 +7,6 @@ import type { SlideBg } from './types'
|
||||
import { deg } from './weatherText'
|
||||
import { useMutation, useQueryClient, type QueryClient } from '@tanstack/react-query'
|
||||
import { likePostMutation, unlikePostMutation } from '../api/client/@tanstack/react-query.gen'
|
||||
import { useAuth } from './authContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { CommentIcon, HeartIcon, SendIcon } from './svg'
|
||||
import { useCarousel } from './carousel'
|
||||
@@ -52,6 +51,22 @@ function slideBg(post: PostData, slide: Slide): SlideBg {
|
||||
|
||||
const DARK = new Set<SlideBg>(['dusk', 'night'])
|
||||
|
||||
// 그림 배경이 있는 각(code)과 장 수. 여러 장이면 글마다 돌려 쓴다
|
||||
const BG_IMAGES: Record<string, number> = { bike: 4, picnic: 1, hiking: 1, camping: 1, stars: 1, walk: 1, hangang: 1 }
|
||||
const EVENT_BG_N = 4
|
||||
|
||||
function bgImage(name: string, n: number, seed: number): CSSProperties {
|
||||
const file = n > 1 ? `${name}-${'abcd'[seed % n]}` : name
|
||||
return { backgroundImage: `url(/post-bg/${file}.webp)`, backgroundSize: 'cover', backgroundPosition: 'center' }
|
||||
}
|
||||
|
||||
/** 그림 배경: 각은 각마다, 사진 없는 행사는 행사용. 없으면 색 배경만 */
|
||||
function slideImage(post: PostData, slide: Slide): CSSProperties | undefined {
|
||||
if (slide.kind === 'gak') return BG_IMAGES[slide.code] ? bgImage(slide.code, BG_IMAGES[slide.code], post.post_id) : undefined
|
||||
if (post.post_type === PostType.EVENT && slide.kind === 'rows' && !slide.image) return bgImage('event', EVENT_BG_N, post.post_id)
|
||||
return undefined
|
||||
}
|
||||
|
||||
function Lines({ text }: { text: string }) {
|
||||
return text.split('\n').map((t, i) => (
|
||||
<span key={i}>
|
||||
@@ -79,7 +94,7 @@ function Pic({ name, className }: { name: string; className?: string }) {
|
||||
|
||||
const slideBase = 'relative flex h-full w-full shrink-0 flex-col px-5 py-[22px]'
|
||||
|
||||
function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
|
||||
function SlideView({ slide, bg, img }: { slide: Slide; bg: SlideBg; img?: CSSProperties }) {
|
||||
const { open } = useSheet()
|
||||
if (slide.kind === 'hours') {
|
||||
const temps = slide.hours.flatMap((h) => (h.temp_c == null ? [] : [h.temp_c]))
|
||||
@@ -114,7 +129,7 @@ function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
|
||||
}
|
||||
if (slide.kind === 'gak')
|
||||
return (
|
||||
<div className={cx(slideBase, `b-bg-${bg}`)}>
|
||||
<div className={cx(slideBase, `b-bg-${bg}`)} style={img}>
|
||||
<Eyebrow>오늘의 각 · {slide.rank}위</Eyebrow>
|
||||
<Big>{slide.line}</Big>
|
||||
<Pic name={slide.code} />
|
||||
@@ -223,7 +238,7 @@ function SlideView({ slide, bg }: { slide: Slide; bg: SlideBg }) {
|
||||
</div>
|
||||
)
|
||||
return (
|
||||
<div className={cx(slideBase, `b-bg-${bg}`)}>
|
||||
<div className={cx(slideBase, `b-bg-${bg}`)} style={img}>
|
||||
<Eyebrow className={DARK.has(bg) ? 'opacity-85' : undefined}>{slide.eyebrow}</Eyebrow>
|
||||
<Big className="relative z-[1]">
|
||||
<Lines text={slide.line} />
|
||||
@@ -312,7 +327,6 @@ export function PostCardSkel() {
|
||||
|
||||
function FullCard({ post }: PostProps) {
|
||||
const { open } = useSheet()
|
||||
const { loggedIn } = useAuth()
|
||||
const liked = !!post.liked
|
||||
const likeCount = post.like_count
|
||||
const queryClient = useQueryClient()
|
||||
@@ -338,7 +352,6 @@ function FullCard({ post }: PostProps) {
|
||||
|
||||
// 화면을 먼저 바꾸고, 실패하면 되돌린다 (서버는 실패도 200 + result.success=false 로 준다)
|
||||
const setLike = (on: boolean) => {
|
||||
if (!loggedIn) return open({ type: 'login' })
|
||||
if (on === liked || like.isPending || unlike.isPending) return
|
||||
if (on) setPop((p) => p + 1)
|
||||
setLikeFailed(0)
|
||||
@@ -363,7 +376,7 @@ function FullCard({ post }: PostProps) {
|
||||
if ((e.target as HTMLElement).closest('button')) return
|
||||
const now = Date.now()
|
||||
if (now - lastTap.current < 320) {
|
||||
if (liked && loggedIn) setPop((p) => p + 1)
|
||||
if (liked) setPop((p) => p + 1)
|
||||
else setLike(true)
|
||||
}
|
||||
lastTap.current = now
|
||||
@@ -401,7 +414,7 @@ function FullCard({ post }: PostProps) {
|
||||
>
|
||||
<div ref={trackRef} className="flex h-full">
|
||||
{post.slides.map((s, i) => (
|
||||
<SlideView key={i} slide={s} bg={bgs[i]} />
|
||||
<SlideView key={i} slide={s} bg={bgs[i]} img={slideImage(post, s)} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -457,3 +470,43 @@ function FullCard({ post }: PostProps) {
|
||||
</article>
|
||||
)
|
||||
}
|
||||
|
||||
type FrameProps = { title: string; account: string; avatar: string; caption?: ReactNode; more?: ReactNode; shot?: RefObject<HTMLDivElement | null>; children: ReactNode }
|
||||
|
||||
/** 피드 글과 같은 틀(계정 줄·본문·보내기 줄)에 날씨·각 같은 화면 조각을 담는다. 보내기는 shot(공유용 틀)이 있으면 그것을, 없으면 본문을 이미지로 */
|
||||
export function PostFrame({ title, account, avatar, caption, more, shot, children }: FrameProps) {
|
||||
const { open } = useSheet()
|
||||
const bodyRef = useRef<HTMLDivElement>(null)
|
||||
const share = () => {
|
||||
const el = shot?.current ?? bodyRef.current
|
||||
if (el) open({ type: 'share', share: { title, slides: [el] } })
|
||||
}
|
||||
return (
|
||||
<article className="mt-3.5 border-y border-(--line) bg-white first:mt-1" aria-label={title}>
|
||||
<div className="flex items-center gap-2.5 px-3 py-2.5">
|
||||
<span className="b-ring size-[34px] shrink-0 rounded-full p-0.5">
|
||||
<i className="grid size-full place-items-center rounded-full bg-white">
|
||||
<Ic name={avatar} className="w-[22px]" />
|
||||
</i>
|
||||
</span>
|
||||
<span>
|
||||
<b className="block text-sm leading-tight font-extrabold">날씨각</b>
|
||||
<small className="text-xs font-semibold text-(--ink2)">{account}</small>
|
||||
</span>
|
||||
</div>
|
||||
<div ref={bodyRef}>{children}</div>
|
||||
<div className="flex items-center gap-3.5 px-3 pt-2.5 pb-1 [&_svg]:size-[26px] [&_svg]:stroke-[1.9]">
|
||||
<button type="button" onClick={share} aria-label="보내기" className={cx('relative grid size-7 cursor-pointer place-items-center', TAP44)}>
|
||||
<SendIcon className="fill-none stroke-(--ink) [stroke-linecap:round] [stroke-linejoin:round]" />
|
||||
</button>
|
||||
{more && <span className="ml-auto text-[13px] font-bold text-(--ink2)">{more}</span>}
|
||||
</div>
|
||||
{caption && (
|
||||
<p className="px-3 pt-0.5 pb-3 text-sm">
|
||||
<b className="mr-[5px] font-extrabold">날씨각</b>
|
||||
{caption}
|
||||
</p>
|
||||
)}
|
||||
</article>
|
||||
)
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import { cx } from '../lib/utils'
|
||||
import { useAuth } from './authContext'
|
||||
import { ago, ARTICLE_CAT, articleMeta, AVATAR_COLORS, cardBg, CHARACTERS, dateRange, loadOf, MOODS, shortDay } from './lib'
|
||||
import { MixSheet } from './myGak'
|
||||
import { useMyGak } from './myGakState'
|
||||
import { ownPage, useRegion } from './regionContext'
|
||||
import { useSky } from './skyContext'
|
||||
import { SHARE_SIZES, shareImage, type ShareSize } from './storyImage'
|
||||
@@ -134,7 +133,7 @@ function SheetHost({ state, onClose }: { state: SheetState; onClose: () => void
|
||||
{state.type === 'login' && <LoginSheet onDone={onClose} onLoggedIn={then ? () => open(then) : onClose} />}
|
||||
{state.type === 'me' && <MeSheet onDone={onClose} />}
|
||||
{state.type === 'region' && <RegionSheet onDone={onClose} />}
|
||||
{state.type === 'mix' && <MixSheet ids={state.ids} shared={state.shared} onDone={onClose} />}
|
||||
{state.type === 'mix' && <MixSheet shared={state.shared} onDone={onClose} />}
|
||||
</div>
|
||||
)}
|
||||
{!state && <RegionLinks />}
|
||||
@@ -326,8 +325,6 @@ function Radar({ name, factors, size = 250 }: { name: string; factors: Factor[];
|
||||
|
||||
function GakSheet({ indexId, onTitle }: { indexId: number; onTitle: (t: string) => void }) {
|
||||
const { region } = useRegion()
|
||||
const { open } = useSheet()
|
||||
const { mixable } = useMyGak()
|
||||
const q = useQuery(getIndexOptions({ path: { index_id: indexId }, query: { region: region.code } }))
|
||||
const d: ResIndexDetail | undefined = q.data
|
||||
const g = d?.index
|
||||
@@ -360,11 +357,6 @@ function GakSheet({ indexId, onTitle }: { indexId: number; onTitle: (t: string)
|
||||
<b className={cx('ml-auto font-bagel text-[42px] font-normal', g.active ? 'text-(--orange)' : 'text-(--ink3)')}>{g.score}</b>
|
||||
</div>
|
||||
{!g.active && <p className="mt-2 text-[13px] font-bold text-(--ink2)">지금 시간대엔 해당 없어요. 점수는 오늘 가장 좋은 시간대 기준이에요.</p>}
|
||||
{mixable.has(g.index_id) && (
|
||||
<button type="button" onClick={() => open({ type: 'mix', ids: [g.index_id] })} className="mt-2.5 w-full cursor-pointer rounded-2xl bg-[#fff4ec] py-2.5 font-jua text-[15.5px] text-(--orange)">
|
||||
다른 각과 섞어 내 각 만들기
|
||||
</button>
|
||||
)}
|
||||
{now && (
|
||||
<p className="mt-3 rounded-2xl bg-[#fff4ec] px-3.5 py-2.5 text-[14.5px] font-bold">
|
||||
<b className="mr-1.5 font-jua font-normal text-(--orange)">{now.low}~{now.high}점</b>
|
||||
@@ -624,8 +616,6 @@ const EMOJIS = ['☀️', '🌂', '🍻', '🌇', '😍', '👍']
|
||||
|
||||
function CommentRow({ c, postId }: { c: CommentData; postId: number }) {
|
||||
const { region } = useRegion()
|
||||
const { loggedIn } = useAuth()
|
||||
const { open } = useSheet()
|
||||
const queryClient = useQueryClient()
|
||||
const [liked, setLiked] = useState(c.liked)
|
||||
const [count, setCount] = useState(c.like_count)
|
||||
@@ -636,7 +626,6 @@ function CommentRow({ c, postId }: { c: CommentData; postId: number }) {
|
||||
const [likeFailed, setLikeFailed] = useState(false)
|
||||
|
||||
const toggle = () => {
|
||||
if (!loggedIn) return open({ type: 'login' })
|
||||
if (like.isPending || unlike.isPending) return
|
||||
const next = !liked
|
||||
setLikeFailed(false)
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
import { Fragment, useEffect, useState, type ReactNode } from 'react'
|
||||
import { Fragment, useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { Link } from 'react-router'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getFeedOptions, getWeatherTodayOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import { RainType, Sky, type BandArticle, type BandEvent, type Hero as HeroData, type ResWeatherToday, type TopIndex, type WeatherSlot } from '../api/client/types.gen'
|
||||
import { RainType, Sky, type BandArticle, type BandEvent, type Hero as HeroData, type ResWeatherToday, type TalkData, type TopIndex, type WeatherSlot } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { cardBg, fall, kindOfHour, kst, type Load, loadOf, MEDALS, type TimeKind, WEEKDAYS } from './lib'
|
||||
import { MyGakRow } from './myGak'
|
||||
import { PostCard, PostCardSkel } from './Post'
|
||||
import { fromShare } from './myGakState'
|
||||
import { PostCard, PostCardSkel, PostFrame } from './Post'
|
||||
import { FeedComposer, TalkCard } from './talk'
|
||||
import { useFeedTalks } from './talkState'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { useSky } from './skyContext'
|
||||
import { Ic, Rail, Sec, Skel, SkelRail, StateBox, Thumb } from './ui'
|
||||
import { GakShareCard, HeroShareCard, type HeroShare } from './shareCards'
|
||||
import { SendIcon } from './svg'
|
||||
import { Ic, Rail, Sec, Skel, StateBox, TAP44, Thumb } from './ui'
|
||||
import { deg, slotAt } from './weatherText'
|
||||
|
||||
type Mode = 'now' | TimeKind
|
||||
@@ -103,6 +108,9 @@ const CLOUD_N: Record<Weather, number> = { clear: 0, partly: 2, cloudy: 3, rain:
|
||||
|
||||
function Hero({ hero, today, ranked, feedLoad, todayLoad }: HeroProps) {
|
||||
const { open } = useSheet()
|
||||
const { region } = useRegion()
|
||||
const tplRef = useRef<HTMLDivElement>(null)
|
||||
const share = () => tplRef.current && open({ type: 'share', share: { title: `${region.name} 오늘 날씨`, slides: [tplRef.current] } })
|
||||
const { preview, setServerKind, setPreview } = useSky()
|
||||
const mode: Mode = preview ?? 'now'
|
||||
const clock = useNow()
|
||||
@@ -138,9 +146,26 @@ function Hero({ hero, today, ranked, feedLoad, todayLoad }: HeroProps) {
|
||||
const rain = weather === 'rain' || weather === 'sleet'
|
||||
const snow = weather === 'snow' || weather === 'sleet'
|
||||
|
||||
const shareData: HeroShare = {
|
||||
kind,
|
||||
sky: weather,
|
||||
date: `${t.mo}월 ${t.d}일 ${WEEKDAYS[t.wd]}요일`,
|
||||
place: region.name,
|
||||
label: `${slotScore != null && mode !== 'now' ? PREVIEW[mode].label : '지금'} 날씨 점수`,
|
||||
score,
|
||||
bubble,
|
||||
summary: top1?.summary,
|
||||
status: status.map((x) => ({ label: x.label, value: x.value, warn: x.tone === 'warn' })),
|
||||
slots: KINDS.map((k) => {
|
||||
const s = slotOf(k === nowKind ? 'now' : k)
|
||||
return { label: k === nowKind ? '지금' : PREVIEW[k].label, icon: k === 'night' && weatherOf(s) === 'clear' ? 'moon' : WEATHER_ICON[weatherOf(s)], temp: s?.temp_c != null ? deg(s.temp_c) : '–', on: k === kind }
|
||||
}),
|
||||
}
|
||||
|
||||
// 시안 D4-2: 가운데 해(점수)와 하늘 날씨, 결론 두 줄, 상태 한 줄, 아래 하루 흐름 칸(누르면 그 시간대 하늘로)
|
||||
return (
|
||||
<div className="b-hero relative mx-3 mt-1 overflow-hidden rounded-[28px] px-4 pt-3 pb-3" data-t={kind} data-sky={weather}>
|
||||
<HeroShareCard d={shareData} ref={tplRef} />
|
||||
<div className="b-stars pointer-events-none absolute inset-0" aria-hidden="true">
|
||||
{STARS.map((s, i) => (
|
||||
<i key={i} className="absolute size-[3px] rounded-full shadow-[0_0_6px_#fff]" style={s} />
|
||||
@@ -155,9 +180,14 @@ function Hero({ hero, today, ranked, feedLoad, todayLoad }: HeroProps) {
|
||||
{snow && FLAKES.map((s, i) => <i key={i} className="b-flake" style={s} />)}
|
||||
</div>
|
||||
)}
|
||||
<p className="relative z-[3] m-0 text-[14px] font-bold opacity-80">
|
||||
{t.mo}월 {t.d}일 {WEEKDAYS[t.wd]}요일
|
||||
</p>
|
||||
<div className="relative z-[3] flex items-center justify-between">
|
||||
<p className="m-0 text-[14px] font-bold opacity-80">
|
||||
{t.mo}월 {t.d}일 {WEEKDAYS[t.wd]}요일
|
||||
</p>
|
||||
<button type="button" onClick={share} aria-label="오늘 날씨 보내기" className={cx('relative grid size-7 cursor-pointer place-items-center opacity-80 [&_svg]:size-[22px] [&_svg]:stroke-[2]', TAP44)}>
|
||||
<SendIcon className="fill-none stroke-current [stroke-linecap:round] [stroke-linejoin:round]" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="relative h-[146px]">
|
||||
{CLOUDS.slice(0, CLOUD_N[weather]).map((c) => (
|
||||
<span key={c.cls} className={cx('b-cloud b-fall z-[1]', c.cls)} style={fall(c.d, c.f)} aria-hidden="true" />
|
||||
@@ -228,27 +258,34 @@ function moonPath(pct: number, r: number, lit: boolean) {
|
||||
return `M0,${-r} A${r},${r} 0 0 ${lit ? 1 : 0} 0,${r} ${edge}`
|
||||
}
|
||||
|
||||
function Stories({ items }: { items: TopIndex[] }) {
|
||||
function GakCard({ items, place, at }: { items: TopIndex[]; place: string; at: string }) {
|
||||
const { open } = useSheet()
|
||||
const tplRef = useRef<HTMLDivElement>(null)
|
||||
const top = items.filter((g) => g.active).slice(0, 5)
|
||||
return (
|
||||
<Rail label="오늘의 각 순위">
|
||||
{items.map((g, i) => (
|
||||
<button key={g.index_id} type="button" onClick={() => open({ type: 'gak', indexId: g.index_id })} aria-label={g.active ? `${g.rank}위 ${g.name} ${g.score}점` : `${g.name}, 지금 시간대 아님`} className={cx('flex w-[72px] cursor-pointer flex-col items-center gap-1', !g.active && 'opacity-55')}>
|
||||
<span className={cx('relative size-[68px] rounded-full p-[3px]', !g.active || g.score < 50 ? 'bg-[#d6deea]' : 'b-ring')}>
|
||||
<i className="grid size-full place-items-center rounded-full border-[3px] border-(--page) bg-(--page)">
|
||||
<Ic name={g.icon} className="w-[42px]" />
|
||||
</i>
|
||||
{i < 3 && g.active && <Ic name={MEDALS[i]} className="absolute -right-1 -bottom-1 w-[25px]" />}
|
||||
</span>
|
||||
<b className="font-jua text-[13px] font-normal whitespace-nowrap">{g.name}</b>
|
||||
{g.active ? (
|
||||
<em className="font-bagel text-[12.5px] leading-none text-(--orange) not-italic">{g.score}</em>
|
||||
) : (
|
||||
<small className="text-[11px] leading-none font-extrabold text-(--ink3)">지금 아님</small>
|
||||
)}
|
||||
</button>
|
||||
))}
|
||||
</Rail>
|
||||
<PostFrame title={`오늘의 각 · ${place}`} account="오늘의 각" avatar="rabbit" more={<Link to="/gak">전체 보기</Link>} caption="누르면 계산 근거를 보여 줘요" shot={tplRef}>
|
||||
<GakShareCard items={top} title={`오늘의 각 · ${place} ${at}`} ref={tplRef} />
|
||||
<div className="b-band-2 px-4 pt-3.5 pb-3">
|
||||
<p className="m-0 font-jua text-[19px]">
|
||||
오늘의 각 · {place} {at}
|
||||
</p>
|
||||
<ol className="m-0 mt-2 grid list-none gap-1.5 p-0">
|
||||
{top.map((g, i) => (
|
||||
<li key={g.index_id}>
|
||||
<button type="button" onClick={() => open({ type: 'gak', indexId: g.index_id })} className="flex w-full cursor-pointer items-center gap-2.5 rounded-[18px] bg-white px-3 py-2 text-left shadow-[inset_0_-4px_0_var(--shade)]">
|
||||
{i < 3 ? <Ic name={MEDALS[i]} alt={`${i + 1}위`} className="w-[24px] shrink-0" /> : <span className="w-[24px] shrink-0 text-center font-jua text-(--ink3)">{i + 1}</span>}
|
||||
<Ic name={g.icon} className="w-[34px] shrink-0" />
|
||||
<span className="min-w-0 flex-1">
|
||||
<b className="block font-jua text-[16px] leading-tight font-normal">{g.name}</b>
|
||||
{g.summary && <small className="block truncate text-xs font-semibold text-(--ink2)">{g.summary}</small>}
|
||||
</span>
|
||||
<em className="font-bagel text-[22px] leading-none text-(--orange) not-italic">{g.score}</em>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</div>
|
||||
</PostFrame>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -261,27 +298,6 @@ function PostsSkel() {
|
||||
)
|
||||
}
|
||||
|
||||
const STORY_SKELS = Array.from({ length: 6 }, (_, i) => i)
|
||||
|
||||
/** Stories 와 같은 칸(68px 동그라미 + 이름 + 점수)을 6개 */
|
||||
function StoriesSkel() {
|
||||
return (
|
||||
<SkelRail>
|
||||
{STORY_SKELS.map((i) => (
|
||||
<span key={i} className="flex w-[72px] flex-col items-center gap-1">
|
||||
<Skel shape className="size-[68px] rounded-full" />
|
||||
<b className="font-jua text-[13px] font-normal">
|
||||
<Skel className="w-12" />
|
||||
</b>
|
||||
<em className="font-bagel text-[12.5px] leading-none not-italic">
|
||||
<Skel className="w-6" />
|
||||
</em>
|
||||
</span>
|
||||
))}
|
||||
</SkelRail>
|
||||
)
|
||||
}
|
||||
|
||||
function Band({ tone, title, sub, to, children }: { tone: 1 | 2 | 3; title: string; sub: string; to: string; children: ReactNode }) {
|
||||
return (
|
||||
<section className={cx('mt-3.5 pt-4 pb-3.5', `b-band-${tone}`)} aria-label={title}>
|
||||
@@ -310,25 +326,6 @@ function EventsBand({ events }: { events: BandEvent[] }) {
|
||||
)
|
||||
}
|
||||
|
||||
function TopBand({ items, sub }: { items: TopIndex[]; sub: string }) {
|
||||
const { open } = useSheet()
|
||||
return (
|
||||
<Band tone={2} title="지금 뜨는 각 TOP 5" sub={sub} to="/gak">
|
||||
<Rail>
|
||||
{items.slice(0, 5).map((g, i) => (
|
||||
<button key={g.index_id} type="button" onClick={() => open({ type: 'gak', indexId: g.index_id })} className="relative flex w-[138px] cursor-pointer flex-col items-start gap-1 rounded-[22px] bg-white p-3 text-left shadow-[inset_0_-5px_0_var(--shade)]">
|
||||
{i < 3 ? <Ic name={MEDALS[i]} alt={`${i + 1}위`} className="absolute top-2 left-2 w-[26px]" /> : <span className="absolute top-2.5 left-3 font-jua text-(--ink3)">{i + 1}위</span>}
|
||||
<Ic name={g.icon} className="w-[58px] self-center" />
|
||||
<b className="font-jua text-base font-normal">{g.name}</b>
|
||||
<em className="font-bagel text-[22px] leading-none text-(--orange) not-italic">{g.score}</em>
|
||||
{g.summary && <small className="text-xs font-semibold text-(--ink2)">{g.summary}</small>}
|
||||
</button>
|
||||
))}
|
||||
</Rail>
|
||||
</Band>
|
||||
)
|
||||
}
|
||||
|
||||
function SeasonBand({ news }: { news: BandArticle[] }) {
|
||||
const { open } = useSheet()
|
||||
return (
|
||||
@@ -361,25 +358,28 @@ export function TodayPage() {
|
||||
const bands = f?.bands
|
||||
const nowAt = f?.hero?.now_at
|
||||
const load = loadOf(feed)
|
||||
const [mine, setMine] = useState<TalkData[]>([])
|
||||
// 사람들이 쓴 글은 운영 포스트 3개마다 하나씩. 방금 올린 내 글은 글쓰기 칸 아래에 따로 있으니 빼고
|
||||
const talks = useFeedTalks().filter((t) => !mine.some((m) => m.talk_id === t.talk_id))
|
||||
|
||||
useEffect(() => {
|
||||
window.scrollTo({ top: 0 })
|
||||
}, [region.code])
|
||||
|
||||
// 친구가 보낸 섞은 각 링크(/?mix=3,8)로 들어오면 내 동네 기준으로 보여 준다
|
||||
// 친구가 보낸 내 각 링크(/?my=...)로 들어오면 내 동네 기준으로 보여 준다
|
||||
useEffect(() => {
|
||||
const url = new URL(window.location.href)
|
||||
const ids = url.searchParams.get('mix')?.split(',').map(Number).filter(Number.isInteger)
|
||||
if (!ids || ids.length !== 2) return
|
||||
url.searchParams.delete('mix')
|
||||
const code = url.searchParams.get('my')
|
||||
if (!code) return
|
||||
url.searchParams.delete('my')
|
||||
window.history.replaceState(window.history.state, '', url)
|
||||
open({ type: 'mix', ids, shared: true })
|
||||
const g = fromShare(code)
|
||||
if (g) open({ type: 'mix', shared: g })
|
||||
}, [open])
|
||||
|
||||
// 디자인대로 3·6·9번째 글 뒤에 띠를 넣고, 글이 모자라면 남은 띠는 맨 뒤에 붙인다
|
||||
const bandAt: [number, ReactNode][] = [
|
||||
[3, bands?.events?.length ? <EventsBand key="events" events={bands.events} /> : null],
|
||||
[6, bands?.top5?.length ? <TopBand key="top5" items={sloted ? stories.filter((g) => g.active) : bands.top5} sub={sloted ? `${PREVIEW[preview].label} 기준` : nowAt ? `${kst(nowAt).h}시 기준` : '오늘 기준'} /> : null],
|
||||
[9, bands?.season?.length ? <SeasonBand key="season" news={bands.season} /> : null],
|
||||
]
|
||||
|
||||
@@ -387,10 +387,19 @@ export function TodayPage() {
|
||||
// 피드 칸은 전국 공통이라 지역이 바뀌어도 글 번호가 같다. 지역마다 새로 그려 넘긴 슬라이드·펼친 상태가 남지 않게 한다
|
||||
<section key={region.code} aria-label="오늘" aria-busy={load === 'loading'} className={cx('transition-opacity', feed.isPlaceholderData && 'opacity-60')}>
|
||||
<Hero hero={f?.hero} today={today.data} ranked={stories} feedLoad={load} todayLoad={loadOf(today)} />
|
||||
<MyGakRow stories={f?.stories ?? []} />
|
||||
<Sec title="오늘의 각" sub="누르면 계산 근거를 보여 줘요" more={{ to: '/gak' }} />
|
||||
{/* 실패 안내는 여기 한 번만, 각 줄 스켈레톤과 같은 크기로 */}
|
||||
{stories.length ? <Stories items={stories} /> : load === 'loading' ? <StoriesSkel /> : <StateBox load={load} onRetry={() => feed.refetch()} empty="오늘 계산된 각이 없어요." hold={<StoriesSkel />} className="inset-x-3 top-3 bottom-1" />}
|
||||
<FeedComposer onPosted={(t) => setMine((m) => [t, ...m])} />
|
||||
{mine.map((t) => (
|
||||
<TalkCard key={t.talk_id} t={t} />
|
||||
))}
|
||||
<MyGakRow />
|
||||
{/* 실패 안내는 여기 한 번만, 각 카드 스켈레톤과 같은 크기로 */}
|
||||
{stories.some((g) => g.active) ? (
|
||||
<GakCard items={stories} place={region.name.split(' ').at(-1)!} at={sloted ? `${PREVIEW[preview].label} 기준` : nowAt ? `${kst(nowAt).h}시 기준` : '오늘 기준'} />
|
||||
) : load === 'loading' ? (
|
||||
<PostCardSkel />
|
||||
) : (
|
||||
<StateBox load={load} onRetry={() => feed.refetch()} empty="오늘 계산된 각이 없어요." hold={<PostCardSkel />} className="inset-x-3 top-3 bottom-1" />
|
||||
)}
|
||||
<div>
|
||||
{load === 'loading' && <PostsSkel />}
|
||||
{/* 글이 없거나 못 받아도 스켈레톤 두 장 자리는 그대로 둔다 */}
|
||||
@@ -400,6 +409,7 @@ export function TodayPage() {
|
||||
{posts.map((p, i) => (
|
||||
<Fragment key={p.post_id}>
|
||||
<PostCard post={p} />
|
||||
{(i + 1) % 3 === 0 && talks[(i + 1) / 3 - 1] && <TalkCard t={talks[(i + 1) / 3 - 1]} />}
|
||||
{bandAt.find(([at]) => at === i + 1)?.[1]}
|
||||
</Fragment>
|
||||
))}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CSSProperties } from 'react'
|
||||
|
||||
const SHARED = new Set(['bear', 'bike', 'bronze', 'camping', 'carwash', 'chimaek', 'cloud', 'coldwind', 'delivery', 'dog', 'garden', 'glasses', 'gold', 'hiking', 'iced_hot', 'jjamppong', 'laundry', 'letter', 'makeup', 'makgeolli', 'maple', 'moon', 'muggy', 'naengmyeon', 'photo', 'picnic', 'rabbit', 'rain', 'running', 'silver', 'snow', 'stars', 'sun_cloud', 'sun', 'sunset', 'taxi', 'umbrella', 'vent', 'walk', 'yajang', 'baseball', 'study', 'netflix', 'chestnut', 'peanut', 'tangerine', 'sweet_potato', 'fallen_leaf', 'kimchi', 'apple', 'mask', 'golf', 'jipkok', 'fishing', 'drive', 'kite', 'waterplay', 'riverwind', 'trot', 'pajeon', 'bingsu', 'blanket', 'indoordry', 'flower', 'bungeoppang', 'singing_rain'])
|
||||
const SHARED = new Set(['bear', 'bike', 'bronze', 'camping', 'carwash', 'chimaek', 'cloud', 'coldwind', 'delivery', 'dog', 'garden', 'glasses', 'gold', 'hiking', 'iced_hot', 'jjamppong', 'laundry', 'letter', 'makeup', 'makgeolli', 'maple', 'moon', 'muggy', 'naengmyeon', 'photo', 'picnic', 'rabbit', 'rain', 'running', 'silver', 'snow', 'stars', 'sun_cloud', 'sun', 'sunset', 'taxi', 'umbrella', 'vent', 'walk', 'yajang', 'baseball', 'study', 'netflix', 'chestnut', 'peanut', 'tangerine', 'sweet_potato', 'fallen_leaf', 'kimchi', 'apple', 'mask', 'golf', 'jipkok', 'fishing', 'drive', 'kite', 'waterplay', 'riverwind', 'trot', 'pajeon', 'bingsu', 'blanket', 'indoordry', 'flower', 'bungeoppang', 'singing_rain', 'hangang', 'themepark', 'date', 'frizz', 'boiler', 'sunscreen', 'mosquito', 'tennis', 'hyodo', 'thanks', 'gift', 'party', 'game', 'selfie', 'sentimental'])
|
||||
const OWN = new Set(['fireworks', 'bulb', 'calendar', 'thermo', 'sheaf', 'popup', 'exhibition', 'concert'])
|
||||
|
||||
/** 아이콘 이름 → 파일 경로 (공용 public/icons, B 전용 public/b/icons). 'none'(데이터 없는 칸)은 그림 없음 */
|
||||
|
||||
+154
-91
@@ -1,134 +1,197 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useState } from 'react'
|
||||
import { getFeedOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
import type { TopIndex } from '../api/client/types.gen'
|
||||
import { useState, type ReactNode } from 'react'
|
||||
import type { MyGakRule, MyGakScore } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { mix, shareUrl, useMyGak } from './myGakState'
|
||||
import { gakName, shareUrl, SLOTS, type MyGak, type Slot, useMyGak, useMyGakScores } from './myGakState'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { Ic, Sec } from './ui'
|
||||
import { Sec } from './ui'
|
||||
|
||||
function Bar({ g, low }: { g: TopIndex; low: boolean }) {
|
||||
const SLOT_WORD = Object.fromEntries(SLOTS) as Record<Slot, string>
|
||||
|
||||
function Score({ s, big }: { s?: MyGakScore; big?: boolean }) {
|
||||
const v = s?.score
|
||||
return (
|
||||
<span className="grid grid-cols-[1fr_auto] items-center gap-x-2 text-[12.5px] font-bold">
|
||||
<span>{g.name}</span>
|
||||
<em className={cx('font-jua not-italic', low ? 'text-(--ink2)' : 'text-(--orange)')}>{g.score}</em>
|
||||
<i className="col-span-2 block h-[7px] overflow-hidden rounded-full bg-[#e3eaf4]">
|
||||
<s className={cx('b-keep-bg block h-full', low ? 'bg-[#f3b38f]' : 'bg-(--orange)')} style={{ width: `${g.score}%` }} />
|
||||
</i>
|
||||
</span>
|
||||
<em className={cx('ml-auto font-bagel leading-none not-italic', big ? 'text-[36px]' : 'text-[28px]', v == null || v < 50 ? 'text-(--ink3)' : 'text-(--orange)')}>
|
||||
{v ?? '–'}
|
||||
</em>
|
||||
)
|
||||
}
|
||||
|
||||
/** 오늘 탭의 내 각 줄: 섞은 각 카드들과 새로 섞기 */
|
||||
export function MyGakRow({ stories }: { stories: TopIndex[] }) {
|
||||
function Reasons({ s }: { s?: MyGakScore }) {
|
||||
if (!s?.slot) return <p className="m-0 text-[12.5px] font-semibold text-(--ink3)">예보를 불러오는 중이에요</p>
|
||||
return (
|
||||
<p className="m-0 text-[12.5px] leading-snug font-semibold text-(--ink2)">
|
||||
<b className="mr-1 text-(--ink)">{SLOT_WORD[s.slot as Slot]}</b>
|
||||
{s.reasons?.join(' · ')}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
/** 오늘 탭의 내 각 줄: 내가 정한 조건으로 매긴 오늘 점수 */
|
||||
export function MyGakRow() {
|
||||
const { open } = useSheet()
|
||||
const { pairs, remove } = useMyGak()
|
||||
const [copied, setCopied] = useState<string | null>(null)
|
||||
const send = (ids: number[], name: string) => {
|
||||
const url = shareUrl(ids)
|
||||
const { items, remove } = useMyGak()
|
||||
const scores = useMyGakScores(items.map((g) => g.rule)).data?.scores ?? []
|
||||
const [copied, setCopied] = useState<number | null>(null)
|
||||
const send = (g: MyGak, i: number) => {
|
||||
const url = shareUrl(g)
|
||||
if (navigator.share) {
|
||||
navigator.share({ title: `${name} · 날씨각`, url }).catch((e: unknown) => {
|
||||
navigator.share({ title: `${g.name} · 날씨각`, url }).catch((e: unknown) => {
|
||||
if (!(e instanceof DOMException && e.name === 'AbortError')) console.error('[myGak] share', e)
|
||||
})
|
||||
return
|
||||
}
|
||||
navigator.clipboard.writeText(url).then(
|
||||
() => setCopied(ids.join()),
|
||||
() => setCopied(i),
|
||||
(e: unknown) => console.error('[myGak] copy', e),
|
||||
)
|
||||
}
|
||||
if (!stories.length) return null
|
||||
return (
|
||||
<>
|
||||
<Sec title="내 각" sub="공식 각 두 개를 섞어 만들어요. 둘 다 좋아야 높아요" />
|
||||
<Sec title="내 각" sub="내가 정한 날씨 조건으로 오늘 점수를 매겨요" />
|
||||
<div className="flex snap-x gap-2 overflow-x-auto px-3 pb-1 [scrollbar-width:none]">
|
||||
{pairs.map((p) => {
|
||||
const m = mix(stories, p.ids)
|
||||
if (!m) return null
|
||||
return (
|
||||
<div key={p.ids.join()} className="flex w-[220px] shrink-0 snap-start flex-col gap-1.5 rounded-[22px] bg-white p-3 shadow-[inset_0_-5px_0_var(--shade)]">
|
||||
<div className="flex items-center gap-1">
|
||||
<Ic name={m.a.icon} className="w-8" />
|
||||
<Ic name={m.b.icon} className="-ml-3 w-8" />
|
||||
<b className="ml-1 font-jua text-[17px] leading-tight font-normal">{m.name}</b>
|
||||
<em className={cx('ml-auto font-bagel text-[28px] leading-none not-italic', m.score < 50 ? 'text-(--ink3)' : 'text-(--orange)')}>{m.score}</em>
|
||||
</div>
|
||||
<Bar g={m.a} low={m.low === m.a && m.a.score !== m.b.score} />
|
||||
<Bar g={m.b} low={m.low === m.b && m.a.score !== m.b.score} />
|
||||
<div className="mt-0.5 flex gap-1.5">
|
||||
<button type="button" onClick={() => send(p.ids, m.name)} className="cursor-pointer rounded-full bg-(--ink) px-3 py-1.5 text-[12.5px] font-extrabold text-white">
|
||||
{copied === p.ids.join() ? '링크 복사함' : '친구에게 보내기'}
|
||||
</button>
|
||||
<button type="button" onClick={() => remove(p)} className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1.5 text-[12.5px] font-extrabold text-(--ink2)">
|
||||
지우기
|
||||
</button>
|
||||
</div>
|
||||
{items.map((g, i) => (
|
||||
<div key={g.id ?? 'local'} className="flex w-[220px] shrink-0 snap-start flex-col gap-1.5 rounded-[22px] bg-white p-3 shadow-[inset_0_-5px_0_var(--shade)]">
|
||||
<div className="flex items-center gap-1">
|
||||
<b className="font-jua text-[17px] leading-tight font-normal">{g.name}</b>
|
||||
<Score s={scores[i]} />
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
<Reasons s={scores[i]} />
|
||||
<div className="mt-auto flex gap-1.5 pt-0.5">
|
||||
<button type="button" onClick={() => send(g, i)} className="cursor-pointer rounded-full bg-(--ink) px-3 py-1.5 text-[12.5px] font-extrabold text-white">
|
||||
{copied === i ? '링크 복사함' : '친구에게 보내기'}
|
||||
</button>
|
||||
<button type="button" onClick={() => remove(g)} className="cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1.5 text-[12.5px] font-extrabold text-(--ink2)">
|
||||
지우기
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<button type="button" onClick={() => open({ type: 'mix' })} className="flex w-[120px] shrink-0 cursor-pointer snap-start flex-col items-center justify-center gap-1 rounded-[22px] border-2 border-dashed border-(--line) p-3 font-jua text-[15px] text-(--ink2)">
|
||||
<span className="text-[26px] leading-none">+</span>
|
||||
각 섞기
|
||||
내 각 만들기
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/** 섞을 각 고르기와 미리보기. ids 가 둘이면(받은 링크) 바로 미리보기 */
|
||||
export function MixSheet({ ids: start = [], shared = false, onDone }: { ids?: number[]; shared?: boolean; onDone: () => void }) {
|
||||
function Row({ label, on, onToggle, children }: { label: string; on: boolean; onToggle: () => void; children: ReactNode }) {
|
||||
return (
|
||||
<div className={cx('flex min-h-[44px] flex-wrap items-center gap-2 border-b border-(--line) py-2', !on && 'opacity-60')}>
|
||||
<label className="flex w-[84px] cursor-pointer items-center gap-1.5 text-[14px] font-extrabold">
|
||||
<input type="checkbox" checked={on} onChange={onToggle} className="size-4 accent-(--orange)" />
|
||||
{label}
|
||||
</label>
|
||||
{on ? <div className="flex min-w-0 flex-1 flex-wrap items-center gap-1.5 text-[13.5px] font-bold">{children}</div> : <span className="text-[13px] font-semibold text-(--ink3)">상관없음</span>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Num({ value, onChange, min, max, label }: { value: number; onChange: (v: number) => void; min: number; max: number; label: string }) {
|
||||
return (
|
||||
<input
|
||||
type="number"
|
||||
inputMode="numeric"
|
||||
aria-label={label}
|
||||
value={value}
|
||||
min={min}
|
||||
max={max}
|
||||
onChange={(e) => {
|
||||
const v = Number(e.target.value)
|
||||
if (e.target.value !== '' && Number.isFinite(v)) onChange(Math.min(max, Math.max(min, v)))
|
||||
}}
|
||||
className="w-[58px] rounded-xl bg-[#f3f6fb] px-2 py-1.5 text-center tabular-nums"
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function Choice<T extends string>({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) {
|
||||
return (
|
||||
<span className="flex gap-1" role="radiogroup" aria-label={label}>
|
||||
{options.map(([k, word]) => (
|
||||
<button key={k} type="button" role="radio" aria-checked={value === k} onClick={() => onChange(k)} className={cx('cursor-pointer rounded-full px-3 py-1.5', value === k ? 'bg-(--orange) text-white' : 'bg-[#eef4fc]')}>
|
||||
{word}
|
||||
</button>
|
||||
))}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
type Filled<T> = { [K in keyof T]-?: NonNullable<T[K]> }
|
||||
const DEFAULT_RULE: Filled<MyGakRule> = { temp: [15, 25], rain: 'dry', wind_max: 4, air: 'normal', humidity: [30, 60], slots: ['morning', 'day', 'evening', 'night'] }
|
||||
type Cond = 'temp' | 'rain' | 'wind_max' | 'air' | 'humidity'
|
||||
|
||||
/** 내 각 만들기(이름과 조건)와 미리보기. shared 면 받은 각을 내 동네 점수로 보여 주고 가져오기만 */
|
||||
export function MixSheet({ shared, onDone }: { shared?: MyGak; onDone: () => void }) {
|
||||
const { region } = useRegion()
|
||||
const stories = useQuery(getFeedOptions({ query: { region: region.code } })).data?.stories ?? []
|
||||
const { mixable, has, create, pending } = useMyGak()
|
||||
const [ids, setIds] = useState<number[]>(start.slice(0, 2))
|
||||
const choices = stories.filter((g) => mixable.has(g.index_id))
|
||||
const m = ids.length === 2 ? mix(stories, ids) : null
|
||||
const owned = ids.length === 2 && has(ids)
|
||||
const toggle = (id: number) => setIds((now) => (now.includes(id) ? now.filter((x) => x !== id) : now.length < 2 ? [...now, id] : [now[0], id]))
|
||||
const { create, pending, failed } = useMyGak()
|
||||
const [name, setName] = useState(shared?.name ?? '')
|
||||
const [vals, setVals] = useState({ ...DEFAULT_RULE, ...(shared?.rule ?? {}) } as typeof DEFAULT_RULE)
|
||||
const [on, setOn] = useState<Record<Cond, boolean>>(
|
||||
shared ? { temp: !!shared.rule.temp, rain: !!shared.rule.rain, wind_max: shared.rule.wind_max != null, air: !!shared.rule.air, humidity: !!shared.rule.humidity } : { temp: true, rain: true, wind_max: false, air: false, humidity: false },
|
||||
)
|
||||
const set = <K extends keyof typeof vals>(k: K, v: (typeof vals)[K]) => setVals((x) => ({ ...x, [k]: v }))
|
||||
const toggle = (k: Cond) => setOn((x) => ({ ...x, [k]: !x[k] }))
|
||||
const rule: MyGakRule = { slots: vals.slots, ...(Object.fromEntries((Object.keys(on) as Cond[]).filter((k) => on[k]).map((k) => [k, vals[k]])) as Partial<MyGakRule>) }
|
||||
const valid = Object.values(on).some(Boolean) && vals.slots.length > 0 && (!on.temp || vals.temp[0] < vals.temp[1]) && (!on.humidity || vals.humidity[0] < vals.humidity[1])
|
||||
const score = useMyGakScores(valid ? [rule] : []).data?.scores?.[0]
|
||||
const title = gakName(name) || '이름 없는 각'
|
||||
const toggleSlot = (s: Slot) => set('slots', vals.slots.includes(s) ? vals.slots.filter((x) => x !== s) : SLOTS.map(([k]) => k).filter((k) => k === s || vals.slots.includes(k)))
|
||||
|
||||
return (
|
||||
<div className="flex-1 overflow-auto overscroll-contain px-4 pt-3.5 pb-[18px]">
|
||||
{!shared && (
|
||||
<>
|
||||
<p className="m-0 font-jua text-[19px]">{ids.length === 2 ? '이 둘을 섞어요' : ids.length ? '하나 더 골라요' : '섞을 각 두 개를 골라요'}</p>
|
||||
<p className="mt-0.5 mb-2.5 text-[13px] font-semibold text-(--ink2)">함께 할 일끼리 골라요. 점수는 둘 중 낮은 쪽이에요</p>
|
||||
<div className="flex flex-wrap gap-1.5" role="group" aria-label="섞을 각">
|
||||
{choices.map((g) => {
|
||||
const on = ids.includes(g.index_id)
|
||||
return (
|
||||
<button key={g.index_id} type="button" aria-pressed={on} onClick={() => toggle(g.index_id)} className={cx('flex cursor-pointer items-center gap-1 rounded-full py-1 pr-3 pl-1.5 text-[13.5px] font-extrabold', on ? 'bg-(--orange) text-white' : 'bg-[#eef4fc] text-(--ink)')}>
|
||||
<Ic name={g.icon} className="w-6" />
|
||||
{g.name.replace(/각$/, '')}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
{shared ? (
|
||||
<p className="m-0 text-[13px] font-bold text-(--ink2)">친구가 보낸 각이에요. {region.name} 기준 점수예요</p>
|
||||
) : (
|
||||
<label className="block">
|
||||
<span className="font-jua text-[19px]">이름</span>
|
||||
<input value={name} onChange={(e) => setName(e.target.value)} maxLength={11} placeholder="소맥, 야독, 새우깡" className="mt-1.5 w-full rounded-2xl bg-[#f3f6fb] px-3.5 py-2.5 text-[15px]" />
|
||||
</label>
|
||||
)}
|
||||
{m && (
|
||||
<div className="mt-3.5 flex flex-col gap-2 rounded-[20px] bg-[#f3f6fb] p-3.5">
|
||||
{shared && <p className="m-0 text-[13px] font-bold text-(--ink2)">친구가 보낸 각이에요. {region.name} 기준 점수예요</p>}
|
||||
<div className="flex items-center gap-1">
|
||||
<Ic name={m.a.icon} className="w-9" />
|
||||
<Ic name={m.b.icon} className="-ml-3 w-9" />
|
||||
<b className="ml-1 font-jua text-[20px] font-normal">{m.name}</b>
|
||||
<em className={cx('ml-auto font-bagel text-[36px] leading-none not-italic', m.score < 50 ? 'text-(--ink3)' : 'text-(--orange)')}>{m.score}</em>
|
||||
</div>
|
||||
<Bar g={m.a} low={m.low === m.a && m.a.score !== m.b.score} />
|
||||
<Bar g={m.b} low={m.low === m.b && m.a.score !== m.b.score} />
|
||||
<p className="m-0 text-[13px] font-semibold text-(--ink2)">
|
||||
{m.a.score === m.b.score ? '두 각 점수가 같아요' : `오늘은 ${m.low.name} 점수를 따라가요`}
|
||||
</p>
|
||||
<fieldset disabled={!!shared} className="m-0 mt-3 border-0 p-0">
|
||||
<legend className="font-jua text-[19px]">조건</legend>
|
||||
<Row label="기온" on={on.temp} onToggle={() => toggle('temp')}>
|
||||
<Num label="최저 기온" value={vals.temp[0]} min={-20} max={40} onChange={(v) => set('temp', [v, vals.temp[1]])} />~
|
||||
<Num label="최고 기온" value={vals.temp[1]} min={-20} max={40} onChange={(v) => set('temp', [vals.temp[0], v])} />° 체감
|
||||
</Row>
|
||||
<Row label="비" on={on.rain} onToggle={() => toggle('rain')}>
|
||||
<Choice label="비" value={vals.rain} onChange={(v) => set('rain', v)} options={[['dry', '안 와야'], ['wet', '와야']]} />
|
||||
</Row>
|
||||
<Row label="바람" on={on.wind_max} onToggle={() => toggle('wind_max')}>
|
||||
초속 <Num label="바람 상한" value={vals.wind_max} min={1} max={20} onChange={(v) => set('wind_max', v)} />m 이하
|
||||
</Row>
|
||||
<Row label="미세먼지" on={on.air} onToggle={() => toggle('air')}>
|
||||
<Choice label="미세먼지" value={vals.air} onChange={(v) => set('air', v)} options={[['good', '좋음만'], ['normal', '보통까지']]} />
|
||||
</Row>
|
||||
<Row label="습도" on={on.humidity} onToggle={() => toggle('humidity')}>
|
||||
<Num label="최저 습도" value={vals.humidity[0]} min={0} max={100} onChange={(v) => set('humidity', [v, vals.humidity[1]])} />~
|
||||
<Num label="최고 습도" value={vals.humidity[1]} min={0} max={100} onChange={(v) => set('humidity', [vals.humidity[0], v])} />%
|
||||
</Row>
|
||||
<div className="flex flex-wrap items-center gap-1.5 py-2.5 text-[13.5px] font-bold">
|
||||
<span className="w-[84px] text-[14px] font-extrabold">시간대</span>
|
||||
{SLOTS.map(([k, word]) => (
|
||||
<button key={k} type="button" aria-pressed={vals.slots.includes(k)} onClick={() => toggleSlot(k)} className={cx('cursor-pointer rounded-full px-3 py-1.5', vals.slots.includes(k) ? 'bg-(--orange) text-white' : 'bg-[#eef4fc]')}>
|
||||
{word}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</fieldset>
|
||||
<div className="mt-2 flex flex-col gap-1.5 rounded-[20px] bg-[#f3f6fb] p-3.5">
|
||||
<div className="flex items-center">
|
||||
<b className="font-jua text-[20px] font-normal">{title}</b>
|
||||
<Score s={valid ? score : undefined} big />
|
||||
</div>
|
||||
{valid ? <Reasons s={score} /> : <p className="m-0 text-[12.5px] font-semibold text-(--ink3)">조건과 시간대를 하나 이상 골라요</p>}
|
||||
</div>
|
||||
{failed && <p className="mt-2 mb-0 text-xs font-bold text-(--heart)">저장하지 못했어요. 이름에 링크나 긴 숫자가 있으면 빼 주세요</p>}
|
||||
<button
|
||||
type="button"
|
||||
disabled={!m || owned || pending}
|
||||
onClick={() => m && create(ids, onDone)}
|
||||
disabled={!valid || !gakName(name) || pending}
|
||||
onClick={() => create({ name, rule }, onDone)}
|
||||
className="mt-3.5 w-full cursor-pointer rounded-2xl bg-(--orange) py-3 font-jua text-[17px] text-white disabled:cursor-default disabled:opacity-45"
|
||||
>
|
||||
{owned ? '이미 내 각에 있어요' : shared ? '내 각으로 가져오기' : '내 각으로 만들기'}
|
||||
{shared ? '내 각으로 가져오기' : '내 각으로 저장'}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -2,22 +2,29 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useEffect, useSyncExternalStore } from 'react'
|
||||
import { SITE_URL } from '../api/setup'
|
||||
import { addMyGakMutation, deleteMyGakMutation, listMyGakOptions, listMyGakQueryKey } from '../api/client/@tanstack/react-query.gen'
|
||||
import type { TopIndex } from '../api/client/types.gen'
|
||||
import { scoreMyGak } from '../api/client/sdk.gen'
|
||||
import type { MyGakRule, MyGakScore } from '../api/client/types.gen'
|
||||
import { useAuth } from './authContext'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
|
||||
const KEY = 'nalssigak.b.myGak'
|
||||
const KEY = 'nalssigak.b.myRule'
|
||||
|
||||
/** 로그인하지 않으면 이 기기에 하나만 */
|
||||
export type Pair = { id?: number; ids: [number, number] }
|
||||
export type Slot = 'morning' | 'day' | 'evening' | 'night'
|
||||
export const SLOTS: [Slot, string][] = [
|
||||
['morning', '아침'],
|
||||
['day', '낮'],
|
||||
['evening', '저녁'],
|
||||
['night', '밤'],
|
||||
]
|
||||
|
||||
const sameIds = (a: number[], b: number[]) => a.length === 2 && b.length === 2 && a[0] === b[0] && a[1] === b[1]
|
||||
const sorted = (ids: number[]) => [...ids].sort((x, y) => x - y) as [number, number]
|
||||
/** 내 각 하나. 로그인하지 않으면 이 기기에 하나만(id 없음) */
|
||||
export type MyGak = { id?: number; name: string; rule: MyGakRule }
|
||||
|
||||
function readLocal(): [number, number] | null {
|
||||
function readLocal(): MyGak | null {
|
||||
try {
|
||||
const raw = localStorage.getItem(KEY)
|
||||
return raw ? sorted(JSON.parse(raw) as number[]) : null
|
||||
return raw ? (JSON.parse(raw) as MyGak) : null
|
||||
} catch {
|
||||
// 사파리 프라이빗 모드 등에서는 저장소를 못 쓴다 → 이번 방문엔 없는 것으로
|
||||
return null
|
||||
@@ -32,68 +39,94 @@ const subscribe = (cb: () => void) => {
|
||||
return () => listeners.delete(cb)
|
||||
}
|
||||
|
||||
function setLocal(ids: [number, number] | null) {
|
||||
local = ids
|
||||
function setLocal(g: MyGak | null) {
|
||||
local = g
|
||||
listeners.forEach((cb) => cb())
|
||||
try {
|
||||
if (ids) localStorage.setItem(KEY, JSON.stringify(ids))
|
||||
if (g) localStorage.setItem(KEY, JSON.stringify(g))
|
||||
else localStorage.removeItem(KEY)
|
||||
} catch (e) {
|
||||
console.warn('[myGak] 기기에 저장하지 못함', e)
|
||||
}
|
||||
}
|
||||
|
||||
/** 두 각 이름을 이어 붙인 이름: 러닝각 + 치맥각 → 러닝·치맥각 */
|
||||
const pairName = (a: TopIndex, b: TopIndex) => `${a.name.replace(/각$/, '')}·${b.name}`
|
||||
|
||||
/** 섞은 각 점수: 둘 다 좋아야 좋은 날이라 낮은 쪽 */
|
||||
export function mix(stories: TopIndex[], ids: number[]) {
|
||||
const a = stories.find((g) => g.index_id === ids[0])
|
||||
const b = stories.find((g) => g.index_id === ids[1])
|
||||
if (!a || !b) return null
|
||||
return { a, b, name: pairName(a, b), score: Math.min(a.score, b.score), low: a.score <= b.score ? a : b }
|
||||
/** 이름 끝에 '각'을 붙인다 (서버와 같은 규칙) */
|
||||
export const gakName = (name: string) => {
|
||||
const n = name.trim().replace(/\s+/g, ' ')
|
||||
return n && !n.endsWith('각') ? `${n}각` : n
|
||||
}
|
||||
|
||||
export const shareUrl = (ids: number[]) => `${SITE_URL}/?mix=${ids.join(',')}`
|
||||
/** 받은 링크(/?my=...)에 이름과 조건을 그대로 담는다 */
|
||||
export function shareUrl(g: MyGak) {
|
||||
const json = JSON.stringify({ n: g.name, r: g.rule })
|
||||
const b64 = btoa(String.fromCharCode(...new TextEncoder().encode(json)))
|
||||
return `${SITE_URL}/?my=${b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')}`
|
||||
}
|
||||
|
||||
export function fromShare(code: string): MyGak | null {
|
||||
try {
|
||||
const bin = atob(code.replace(/-/g, '+').replace(/_/g, '/'))
|
||||
const v = JSON.parse(new TextDecoder().decode(Uint8Array.from(bin, (c) => c.charCodeAt(0)))) as { n?: unknown; r?: unknown }
|
||||
return typeof v.n === 'string' && v.r && typeof v.r === 'object' ? { name: v.n, rule: v.r as MyGakRule } : null
|
||||
} catch (e) {
|
||||
console.warn('[myGak] 받은 링크를 읽지 못함', e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/** 조건들의 우리 동네 오늘 점수. 조건이 같으면 캐시를 같이 쓴다 */
|
||||
export function useMyGakScores(rules: MyGakRule[]) {
|
||||
const { region } = useRegion()
|
||||
return useQuery({
|
||||
queryKey: ['myGakScore', region.code, rules],
|
||||
enabled: rules.length > 0,
|
||||
staleTime: 5 * 60_000,
|
||||
queryFn: async (): Promise<{ nowSlot?: Slot | null; scores: MyGakScore[] }> => {
|
||||
const { data } = await scoreMyGak({ body: { region_code: region.code, rules } })
|
||||
if (!data.result?.success) throw new Error(data.result?.desc ?? 'score')
|
||||
return { nowSlot: data.now_slot, scores: data.scores ?? [] }
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useMyGak() {
|
||||
const { loggedIn } = useAuth()
|
||||
const { open } = useSheet()
|
||||
const queryClient = useQueryClient()
|
||||
const q = useQuery(listMyGakOptions())
|
||||
const q = useQuery({ ...listMyGakOptions(), enabled: loggedIn })
|
||||
const saved = useSyncExternalStore(subscribe, () => local)
|
||||
const add = useMutation({ ...addMyGakMutation(), onSuccess: () => queryClient.invalidateQueries({ queryKey: listMyGakQueryKey() }) })
|
||||
const del = useMutation({ ...deleteMyGakMutation(), onSuccess: () => queryClient.invalidateQueries({ queryKey: listMyGakQueryKey() }) })
|
||||
const refresh = () => queryClient.invalidateQueries({ queryKey: listMyGakQueryKey() })
|
||||
const add = useMutation({ ...addMyGakMutation(), onSuccess: refresh })
|
||||
const del = useMutation({ ...deleteMyGakMutation(), onSuccess: refresh })
|
||||
|
||||
// 로그인하면 이 기기에 만들어 둔 각을 계정으로 옮긴다
|
||||
const { mutate } = add
|
||||
useEffect(() => {
|
||||
if (!loggedIn || !saved) return
|
||||
mutate({ body: { index_ids: saved } }, { onSuccess: () => setLocal(null) })
|
||||
mutate({ body: { name: saved.name, rule: saved.rule } }, { onSuccess: () => setLocal(null) })
|
||||
}, [loggedIn, saved, mutate])
|
||||
|
||||
const pairs: Pair[] = loggedIn ? (q.data?.items ?? []).map((g) => ({ id: g.my_gak_id, ids: sorted(g.index_ids) })) : saved ? [{ ids: saved }] : []
|
||||
const has = (ids: number[]) => pairs.some((p) => sameIds(p.ids, sorted(ids)))
|
||||
const items: MyGak[] = loggedIn ? (q.data?.items ?? []).map((g) => ({ id: g.my_gak_id, name: g.name, rule: g.rule })) : saved ? [saved] : []
|
||||
|
||||
/** 로그인 없이 두 번째를 만들려 하면 로그인 창을 띄운다 */
|
||||
const create = (ids: number[], onDone?: () => void) => {
|
||||
const two = sorted(ids)
|
||||
const create = (g: MyGak, onDone?: () => void) => {
|
||||
const item = { name: gakName(g.name), rule: g.rule }
|
||||
if (loggedIn) {
|
||||
add.mutate({ body: { index_ids: two } }, { onSuccess: onDone })
|
||||
add.mutate({ body: item }, { onSuccess: (res) => res.result?.success && onDone?.() })
|
||||
return
|
||||
}
|
||||
if (saved && !sameIds(saved, two)) {
|
||||
if (saved) {
|
||||
open({ type: 'login' })
|
||||
return
|
||||
}
|
||||
setLocal(two)
|
||||
setLocal(item)
|
||||
onDone?.()
|
||||
}
|
||||
|
||||
const remove = (p: Pair) => {
|
||||
if (p.id != null) return del.mutate({ path: { my_gak_id: p.id } })
|
||||
const remove = (g: MyGak) => {
|
||||
if (g.id != null) return del.mutate({ path: { my_gak_id: g.id } })
|
||||
setLocal(null)
|
||||
}
|
||||
|
||||
return { mixable: new Set(q.data?.mixable ?? []), pairs, has, create, remove, pending: add.isPending }
|
||||
return { items, create, remove, pending: add.isPending, failed: add.data?.result?.success === false }
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import type { Ref } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import type { TopIndex } from '../api/client/types.gen'
|
||||
import { cx } from '../lib/utils'
|
||||
import { MEDALS } from './lib'
|
||||
import { Ic } from './ui'
|
||||
|
||||
/** 공유 이미지 전용 틀. 화면 밖에 그려 두고 보내기 때 이것만 찍는다 (화면의 버튼은 이미지에서 빠지므로 글자만으로 만든다) */
|
||||
function Offscreen({ children }: { children: React.ReactNode }) {
|
||||
return createPortal(
|
||||
<div aria-hidden="true" className="pointer-events-none fixed top-0 -left-[10000px] w-[380px]">
|
||||
{children}
|
||||
</div>,
|
||||
document.body,
|
||||
)
|
||||
}
|
||||
|
||||
export type HeroShare = {
|
||||
kind: string
|
||||
sky: string
|
||||
date: string
|
||||
place: string
|
||||
label: string
|
||||
score?: number | null
|
||||
bubble?: string | null
|
||||
summary?: string | null
|
||||
status: { label: string; value: string; warn: boolean }[]
|
||||
slots: { label: string; icon: string; temp: string; on: boolean }[]
|
||||
}
|
||||
|
||||
export function HeroShareCard({ d, ref }: { d: HeroShare; ref: Ref<HTMLDivElement> }) {
|
||||
return (
|
||||
<Offscreen>
|
||||
<div ref={ref} className="b-hero relative flex aspect-[4/5] flex-col overflow-hidden px-5 pt-5 pb-4 text-center" data-t={d.kind} data-sky={d.sky}>
|
||||
<p className="m-0 text-left text-[14px] font-bold opacity-80">
|
||||
{d.date} · {d.place}
|
||||
</p>
|
||||
<div className="b-sun mx-auto mt-5 grid aspect-square w-36 place-items-center rounded-full">
|
||||
<span>
|
||||
<small className="block font-jua text-[13px]">{d.label}</small>
|
||||
<b className="block font-bagel text-[58px] leading-[0.95] font-normal">{d.score ?? '–'}</b>
|
||||
</span>
|
||||
</div>
|
||||
<p className="m-0 mt-4 font-jua text-[26px] leading-tight">{d.bubble}</p>
|
||||
{d.summary && <p className="m-0 mt-1 text-[15px] font-bold opacity-80">{d.summary}</p>}
|
||||
<p className="m-0 mt-2 flex flex-wrap justify-center gap-x-2 font-jua text-[14px]">
|
||||
{d.status.map((x) => (
|
||||
<span key={x.label} className={cx('whitespace-nowrap', x.warn && 'b-warn')}>
|
||||
<span className="opacity-75">{x.label}</span> {x.value}
|
||||
</span>
|
||||
))}
|
||||
</p>
|
||||
<div className="b-strip mt-auto grid grid-cols-4 gap-1 rounded-[18px] p-[3px]">
|
||||
{d.slots.map((s) => (
|
||||
<span key={s.label} className={cx('flex flex-col items-center rounded-[14px] py-1.5', s.on && 'b-strip-on')}>
|
||||
<span className="text-[13px] font-bold opacity-80">{s.label}</span>
|
||||
<Ic name={s.icon} className="my-0.5 h-[22px] w-[22px] object-contain" />
|
||||
<b className="font-jua text-[15px] font-normal">{s.temp}</b>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</Offscreen>
|
||||
)
|
||||
}
|
||||
|
||||
export function GakShareCard({ items, title, ref }: { items: TopIndex[]; title: string; ref: Ref<HTMLDivElement> }) {
|
||||
return (
|
||||
<Offscreen>
|
||||
<div ref={ref} className="b-band-2 flex aspect-[4/5] flex-col bg-white px-5 pt-5 pb-4">
|
||||
<p className="m-0 font-jua text-[22px]">{title}</p>
|
||||
<ol className="m-0 mt-3 grid list-none gap-2 p-0">
|
||||
{items.map((g, i) => (
|
||||
<li key={g.index_id} className="flex items-center gap-2.5 rounded-[18px] bg-white px-3 py-2.5 shadow-[inset_0_-4px_0_var(--shade)]">
|
||||
{i < 3 ? <Ic name={MEDALS[i]} className="w-[24px] shrink-0" /> : <span className="w-[24px] shrink-0 text-center font-jua text-(--ink3)">{i + 1}</span>}
|
||||
<Ic name={g.icon} className="w-[36px] shrink-0" />
|
||||
<span className="min-w-0 flex-1">
|
||||
<b className="block font-jua text-[17px] leading-tight font-normal">{g.name}</b>
|
||||
{g.summary && <small className="block truncate text-xs font-semibold text-(--ink2)">{g.summary}</small>}
|
||||
</span>
|
||||
<em className="font-bagel text-[24px] leading-none text-(--orange) not-italic">{g.score}</em>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</div>
|
||||
</Offscreen>
|
||||
)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { MyGak } from './myGakState'
|
||||
import { createContext, use } from 'react'
|
||||
export type SharePayload = { title: string; slides: HTMLElement[] }
|
||||
|
||||
@@ -12,7 +13,7 @@ export type SheetState =
|
||||
| { type: 'login'; then?: CommentsState }
|
||||
| { type: 'me' }
|
||||
| { type: 'region' }
|
||||
| { type: 'mix'; ids?: number[]; shared?: boolean }
|
||||
| { type: 'mix'; shared?: MyGak }
|
||||
| null
|
||||
|
||||
export type SheetApi = { open: (s: Exclude<SheetState, null>) => void; close: () => void }
|
||||
|
||||
+89
-45
@@ -1,24 +1,26 @@
|
||||
import { useInfiniteQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { useEffect, useRef, useState, type ChangeEvent, type FormEvent } from 'react'
|
||||
import {
|
||||
addTalkMutation,
|
||||
blockTalkAuthorMutation,
|
||||
deleteTalkMutation,
|
||||
likeTalkMutation,
|
||||
listTalksInfiniteOptions,
|
||||
reportTalkMutation,
|
||||
unlikeTalkMutation,
|
||||
} from '../api/client/@tanstack/react-query.gen'
|
||||
import { uploadTalkImage } from '../api/client/sdk.gen'
|
||||
import { TalkReport, type TalkData } from '../api/client/types.gen'
|
||||
import { API_BASE_URL } from '../api/setup'
|
||||
import { cx } from '../lib/utils'
|
||||
import { useAuth } from './authContext'
|
||||
import { ago, kst, loadOf } from './lib'
|
||||
import { ago, kst } from './lib'
|
||||
import { useRegion } from './regionContext'
|
||||
import { useSheet } from './sheetContext'
|
||||
import { HeartIcon } from './svg'
|
||||
import { Avatar, Sec, StateBox, TAP44 } from './ui'
|
||||
import { Avatar, TAP44 } from './ui'
|
||||
|
||||
const BODY_MAX = 100
|
||||
const PHOTO_MAX = 10 * 1024 * 1024
|
||||
|
||||
// 서버 ErrorType 이름 → 안내
|
||||
const WRITE_ERRORS: Record<string, string> = {
|
||||
@@ -45,7 +47,7 @@ function useRefreshTalks() {
|
||||
return () => queryClient.invalidateQueries({ queryKey: [{ _id: 'listTalks' }] })
|
||||
}
|
||||
|
||||
function Composer() {
|
||||
function Composer({ onDone }: { onDone?: (t: TalkData) => void }) {
|
||||
const { region } = useRegion()
|
||||
const { loggedIn, me } = useAuth()
|
||||
const { open } = useSheet()
|
||||
@@ -53,22 +55,62 @@ function Composer() {
|
||||
const add = useMutation(addTalkMutation())
|
||||
const [text, setText] = useState('')
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [photo, setPhoto] = useState<{ file: File; src: string } | null>(null)
|
||||
const [uploading, setUploading] = useState(false)
|
||||
const fileRef = useRef<HTMLInputElement>(null)
|
||||
const busy = add.isPending || uploading
|
||||
|
||||
useEffect(() => {
|
||||
if (!photo) return
|
||||
return () => URL.revokeObjectURL(photo.src)
|
||||
}, [photo])
|
||||
|
||||
const pick = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0]
|
||||
e.target.value = ''
|
||||
if (!file) return
|
||||
if (file.size > PHOTO_MAX) return setError('사진은 10MB까지 올릴 수 있어요.')
|
||||
setError(null)
|
||||
setPhoto({ file, src: URL.createObjectURL(file) })
|
||||
}
|
||||
|
||||
// 사진이 있으면 먼저 올려 주소를 받고, 그 주소를 글에 붙인다
|
||||
const upload = async (): Promise<string | undefined> => {
|
||||
if (!photo) return undefined
|
||||
setUploading(true)
|
||||
try {
|
||||
const { data } = await uploadTalkImage({ body: { file: photo.file } })
|
||||
if (!data.result?.success || !data.image) throw new Error(data.result?.desc ?? 'upload')
|
||||
return data.image
|
||||
} finally {
|
||||
setUploading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const submit = (e: FormEvent) => {
|
||||
e.preventDefault()
|
||||
if (!loggedIn) return open({ type: 'login' })
|
||||
const body = text.trim()
|
||||
if (!body || add.isPending) return
|
||||
if (!body || busy) return
|
||||
setError(null)
|
||||
add.mutate(
|
||||
{ body: { region_code: region.code, body } },
|
||||
{
|
||||
onSuccess: (res) => {
|
||||
if (!res.result?.success) return setError(WRITE_ERRORS[res.result?.desc ?? ''] ?? '글을 올리지 못했어요. 다시 해 주세요.')
|
||||
setText('')
|
||||
refresh()
|
||||
},
|
||||
onError: () => setError('글을 올리지 못했어요. 다시 해 주세요.'),
|
||||
upload().then(
|
||||
(image) =>
|
||||
add.mutate(
|
||||
{ body: { region_code: region.code, body, image } },
|
||||
{
|
||||
onSuccess: (res) => {
|
||||
if (!res.result?.success) return setError(WRITE_ERRORS[res.result?.desc ?? ''] ?? '글을 올리지 못했어요. 다시 해 주세요.')
|
||||
setText('')
|
||||
setPhoto(null)
|
||||
refresh()
|
||||
if (res.talk) onDone?.(res.talk)
|
||||
},
|
||||
onError: () => setError('글을 올리지 못했어요. 다시 해 주세요.'),
|
||||
},
|
||||
),
|
||||
(e: unknown) => {
|
||||
console.error('[talk] photo upload', e)
|
||||
setError('사진을 올리지 못했어요. 사진 파일인지 확인해 주세요.')
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -79,20 +121,32 @@ function Composer() {
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
onFocus={() => !loggedIn && open({ type: 'login' })}
|
||||
readOnly={add.isPending}
|
||||
readOnly={busy}
|
||||
maxLength={BODY_MAX}
|
||||
rows={2}
|
||||
placeholder={`지금 ${region.name.split(' ').at(-1)} 날씨 어때요?`}
|
||||
aria-label="동네 이야기 쓰기"
|
||||
className="w-full resize-none rounded-2xl bg-[#f3f6fb] px-3 py-2.5 text-[14.5px]"
|
||||
/>
|
||||
{photo && (
|
||||
<div className="relative mt-2 w-[96px]">
|
||||
<img src={photo.src} alt="올릴 사진" className="aspect-[4/5] w-full rounded-xl object-cover" />
|
||||
<button type="button" onClick={() => setPhoto(null)} aria-label="사진 빼기" className="absolute -top-1.5 -right-1.5 grid size-6 cursor-pointer place-items-center rounded-full bg-(--ink) text-[13px] font-extrabold text-white">
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<input ref={fileRef} type="file" accept="image/*" onChange={pick} hidden />
|
||||
<div className="mt-1.5 flex items-center gap-2 text-xs font-bold text-(--ink3)">
|
||||
<span>{me ? `${me.nickname} · ${region.name.split(' ').at(-1)} · 지금 날씨가 함께 올라가요` : '로그인하면 쓸 수 있어요'}</span>
|
||||
<button type="button" onClick={() => (loggedIn ? fileRef.current?.click() : open({ type: 'login' }))} disabled={busy} className="shrink-0 cursor-pointer rounded-full bg-[#eef4fc] px-3 py-1.5 text-[13px] font-extrabold text-(--ink2) disabled:opacity-40">
|
||||
사진
|
||||
</button>
|
||||
<span className="min-w-0 truncate">{me ? `${me.nickname} · ${region.name.split(' ').at(-1)} · 지금 날씨가 함께 올라가요` : '로그인하면 쓸 수 있어요'}</span>
|
||||
<span className="ml-auto tabular-nums">
|
||||
{text.length}/{BODY_MAX}
|
||||
</span>
|
||||
<button type="submit" disabled={add.isPending || (loggedIn && !text.trim())} className="cursor-pointer rounded-full bg-(--orange) px-3.5 py-1.5 text-[13px] font-extrabold text-white disabled:opacity-40">
|
||||
{add.isPending ? '올리는 중…' : '올리기'}
|
||||
<button type="submit" disabled={busy || (loggedIn && !text.trim())} className="shrink-0 cursor-pointer rounded-full bg-(--orange) px-3.5 py-1.5 text-[13px] font-extrabold text-white disabled:opacity-40">
|
||||
{busy ? '올리는 중…' : '올리기'}
|
||||
</button>
|
||||
</div>
|
||||
{error && (
|
||||
@@ -119,7 +173,6 @@ function TalkRow({ t }: { t: TalkData }) {
|
||||
const [failed, setFailed] = useState(false)
|
||||
|
||||
const toggle = () => {
|
||||
if (!loggedIn) return open({ type: 'login' })
|
||||
if (like.isPending || unlike.isPending) return
|
||||
const next = !liked
|
||||
setLiked(next)
|
||||
@@ -160,6 +213,7 @@ function TalkRow({ t }: { t: TalkData }) {
|
||||
{[t.region_name, slotWord(t.created_at), t.weather].filter(Boolean).join(' · ')}
|
||||
</small>
|
||||
<p className="m-0 mt-0.5 text-[14.5px] break-words whitespace-pre-wrap">{t.body}</p>
|
||||
{t.image && <img src={t.image.startsWith('/v1/') ? API_BASE_URL + t.image : t.image} alt="" loading="lazy" className="mt-2 aspect-[4/5] w-full rounded-2xl bg-[#eef4fc] object-cover" />}
|
||||
<small className="mt-0.5 block text-xs font-bold text-(--ink3)">
|
||||
{ago(t.created_at)} · 좋아요 {count}개 ·{' '}
|
||||
<button type="button" onClick={() => setMenu(menu === 'closed' ? 'open' : 'closed')} aria-expanded={menu !== 'closed'} className="cursor-pointer font-bold text-(--ink3)">
|
||||
@@ -206,30 +260,20 @@ function TalkRow({ t }: { t: TalkData }) {
|
||||
}
|
||||
|
||||
/** 이야기 탭: 쓰기 칸과 전국 최신 글 (아래로 더 받기) */
|
||||
export function TalkPage() {
|
||||
const list = useInfiniteQuery({
|
||||
...listTalksInfiniteOptions(),
|
||||
initialPageParam: {},
|
||||
getNextPageParam: (last) => last.next_cursor ?? undefined,
|
||||
})
|
||||
const talks = list.data?.pages.flatMap((p) => p.talks ?? []) ?? []
|
||||
const load = loadOf(list)
|
||||
/** 피드 위 쓰는 칸. 늘 펼쳐 두고, 방금 올린 글은 바로 아래에 보인다 (피드 사이 글은 새로 받을 때 섞인다) */
|
||||
export function FeedComposer({ onPosted }: { onPosted: (t: TalkData) => void }) {
|
||||
return (
|
||||
<section aria-label="동네 이야기" aria-busy={load === 'loading'}>
|
||||
<Sec title="지금 날씨 이야기" sub="전국 사람들이 쓰는 동네 날씨 이야기" />
|
||||
<Composer />
|
||||
<div className="relative mx-3 mt-2 min-h-[120px] rounded-[22px] bg-white px-3 py-1 shadow-[inset_0_-5px_0_var(--shade)]">
|
||||
{talks.length ? (
|
||||
talks.map((t) => <TalkRow key={`${t.talk_id}:${t.liked}:${t.like_count}`} t={t} />)
|
||||
) : (
|
||||
<StateBox load={load} onRetry={() => list.refetch()} empty="아직 글이 없어요. 첫 이야기를 남겨 보세요." className="inset-0" />
|
||||
)}
|
||||
{list.hasNextPage && (
|
||||
<button type="button" onClick={() => list.fetchNextPage()} disabled={list.isFetchingNextPage} className="w-full cursor-pointer border-t border-(--line) py-2.5 text-center text-sm font-bold text-(--ink2) disabled:opacity-50">
|
||||
{list.isFetchingNextPage ? '불러오는 중…' : '더 보기'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
<div className="mt-3.5">
|
||||
<Composer onDone={onPosted} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/** 피드에 끼우는 글 한 장 */
|
||||
export function TalkCard({ t }: { t: TalkData }) {
|
||||
return (
|
||||
<article className="mt-3.5 border-y border-(--line) bg-white px-3" aria-label={`${t.nickname}의 글`}>
|
||||
<TalkRow key={`${t.talk_id}:${t.liked}:${t.like_count}`} t={t} />
|
||||
</article>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { useInfiniteQuery } from '@tanstack/react-query'
|
||||
import { listTalksInfiniteOptions } from '../api/client/@tanstack/react-query.gen'
|
||||
|
||||
/** 사람들이 쓴 글. 오늘 피드에 운영 포스트 사이사이 섞는다 */
|
||||
export function useFeedTalks() {
|
||||
const list = useInfiniteQuery({
|
||||
...listTalksInfiniteOptions(),
|
||||
initialPageParam: {},
|
||||
getNextPageParam: (last) => last.next_cursor ?? undefined,
|
||||
})
|
||||
return list.data?.pages.flatMap((p) => p.talks ?? []) ?? []
|
||||
}
|
||||
Reference in new issue
Block a user