feat: 동네 이야기 — 로그인하면 100자 글 쓰기(쓸 때 동네 날씨가 붙음, 전국에 보임), 좋아요·신고 3건 자동 숨김·이 사람 글 안 보기·내 글 지우기, 링크·전화번호 막기와 하루 5개 제한
This commit is contained in:
1 parent
a8a126f6a5
commit
798286d975
18 files changed
+1356
-6
No files matched your search
@@ -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, deleteComment, deleteMyGak, getArticle, getFeed, getImage, getIndex, getPost, getSeasonWeek, getSky, getSkyRanking, getTodayGuPage, getTodayPage, getWatchSummary, getWeatherNow, getWeatherToday, getWeek, getWeekRanking, healthzHealthzGet, likeComment, likePost, listArticles, listComments, listEvents, listIndices, listMyGak, listPlaces, listRegions, listSaved, login, logout, me, nearestRegion, type Options, refresh, savePost, signup, unlikeComment, unlikePost, unsavePost, updateMe } from '../sdk.gen';
|
||||
import type { AddCommentData, AddCommentError, AddCommentResponse, AddMyGakData, AddMyGakError, AddMyGakResponse, DeleteCommentData, DeleteCommentError, DeleteCommentResponse, DeleteMyGakData, DeleteMyGakError, DeleteMyGakResponse, 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, ListArticlesData, ListArticlesError, ListArticlesResponse, ListCommentsData, ListCommentsError, ListCommentsResponse, ListEventsData, ListEventsError, ListEventsResponse, ListIndicesData, ListIndicesError, ListIndicesResponse, ListMyGakData, ListMyGakError, ListMyGakResponse, ListPlacesData, ListPlacesError, ListPlacesResponse, ListRegionsData, ListRegionsError, ListRegionsResponse, ListSavedData, ListSavedError, ListSavedResponse, LoginData, LoginError, LoginResponse, LogoutData, LogoutError, LogoutResponse, MeData, MeError, MeResponse, NearestRegionData, NearestRegionError, NearestRegionResponse, RefreshData, RefreshError, RefreshResponse, SavePostData, SavePostError, SavePostResponse, SignupData, SignupError, SignupResponse, UnlikeCommentData, UnlikeCommentError, UnlikeCommentResponse, UnlikePostData, UnlikePostError, UnlikePostResponse, 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, 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';
|
||||
|
||||
export type QueryKey<TOptions extends Options> = [
|
||||
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
|
||||
@@ -761,6 +761,156 @@ export const deleteMyGakMutation = (options?: Partial<Options<DeleteMyGakData>>)
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const listTalksQueryKey = (options?: Options<ListTalksData>) => createQueryKey('listTalks', options);
|
||||
|
||||
/**
|
||||
* 동네 이야기 (전국, 최신순, 로그인 없이 보기)
|
||||
*/
|
||||
export const listTalksOptions = (options?: Options<ListTalksData>) => queryOptions<ListTalksResponse, ListTalksError, ListTalksResponse, ReturnType<typeof listTalksQueryKey>>({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await listTalks({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listTalksQueryKey(options)
|
||||
});
|
||||
|
||||
export const listTalksInfiniteQueryKey = (options?: Options<ListTalksData>): QueryKey<Options<ListTalksData>> => createQueryKey('listTalks', options, true);
|
||||
|
||||
/**
|
||||
* 동네 이야기 (전국, 최신순, 로그인 없이 보기)
|
||||
*/
|
||||
export const listTalksInfiniteOptions = (options?: Options<ListTalksData>) => {
|
||||
const opts = infiniteQueryOptions<ListTalksResponse, ListTalksError, InfiniteData<ListTalksResponse>, QueryKey<Options<ListTalksData>>, number | null | Pick<QueryKey<Options<ListTalksData>>[0], 'body' | 'headers' | 'path' | 'query'>>(
|
||||
// @ts-ignore
|
||||
{
|
||||
queryFn: async ({ pageParam, queryKey, signal }) => {
|
||||
// @ts-ignore
|
||||
const page: Pick<QueryKey<Options<ListTalksData>>[0], 'body' | 'headers' | 'path' | 'query'> = typeof pageParam === 'object' ? pageParam : {
|
||||
query: {
|
||||
cursor: pageParam
|
||||
}
|
||||
};
|
||||
const params = createInfiniteParams(queryKey, page);
|
||||
const { data } = await listTalks({
|
||||
...options,
|
||||
...params,
|
||||
signal,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: listTalksInfiniteQueryKey(options)
|
||||
});
|
||||
return opts as Omit<typeof opts, 'initialData'>;
|
||||
};
|
||||
|
||||
/**
|
||||
* 동네 이야기 쓰기 (링크·전화번호 불가, 하루 5개)
|
||||
*/
|
||||
export const addTalkMutation = (options?: Partial<Options<AddTalkData>>): UseMutationOptions<AddTalkResponse, AddTalkError, Options<AddTalkData>> => {
|
||||
const mutationOptions: UseMutationOptions<AddTalkResponse, AddTalkError, Options<AddTalkData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await addTalk({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 내 이야기 지우기
|
||||
*/
|
||||
export const deleteTalkMutation = (options?: Partial<Options<DeleteTalkData>>): UseMutationOptions<DeleteTalkResponse, DeleteTalkError, Options<DeleteTalkData>> => {
|
||||
const mutationOptions: UseMutationOptions<DeleteTalkResponse, DeleteTalkError, Options<DeleteTalkData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await deleteTalk({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 이야기 좋아요 취소
|
||||
*/
|
||||
export const unlikeTalkMutation = (options?: Partial<Options<UnlikeTalkData>>): UseMutationOptions<UnlikeTalkResponse, UnlikeTalkError, Options<UnlikeTalkData>> => {
|
||||
const mutationOptions: UseMutationOptions<UnlikeTalkResponse, UnlikeTalkError, Options<UnlikeTalkData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await unlikeTalk({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 이야기 좋아요
|
||||
*/
|
||||
export const likeTalkMutation = (options?: Partial<Options<LikeTalkData>>): UseMutationOptions<LikeTalkResponse, LikeTalkError, Options<LikeTalkData>> => {
|
||||
const mutationOptions: UseMutationOptions<LikeTalkResponse, LikeTalkError, Options<LikeTalkData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await likeTalk({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 이야기 신고 (서로 다른 3명이면 숨김)
|
||||
*/
|
||||
export const reportTalkMutation = (options?: Partial<Options<ReportTalkData>>): UseMutationOptions<ReportTalkResponse, ReportTalkError, Options<ReportTalkData>> => {
|
||||
const mutationOptions: UseMutationOptions<ReportTalkResponse, ReportTalkError, Options<ReportTalkData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await reportTalk({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
/**
|
||||
* 이 글 쓴 사람의 글 안 보기
|
||||
*/
|
||||
export const blockTalkAuthorMutation = (options?: Partial<Options<BlockTalkAuthorData>>): UseMutationOptions<BlockTalkAuthorResponse, BlockTalkAuthorError, Options<BlockTalkAuthorData>> => {
|
||||
const mutationOptions: UseMutationOptions<BlockTalkAuthorResponse, BlockTalkAuthorError, Options<BlockTalkAuthorData>> = {
|
||||
mutationFn: async (fnOptions) => {
|
||||
const { data } = await blockTalkAuthor({
|
||||
...options,
|
||||
...fnOptions,
|
||||
throwOnError: true
|
||||
});
|
||||
return data;
|
||||
}
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const getWatchSummaryQueryKey = (options: Options<GetWatchSummaryData>) => createQueryKey('getWatchSummary', options);
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user