From a8ccfb02179cc07d1401b803d1468a9c50bbfb99 Mon Sep 17 00:00:00 2001 From: Do-hyun Ko Date: Tue, 13 Feb 2024 23:45:58 +0900 Subject: [PATCH 1/5] :sparkles: Reaction migration preparation --- src/api/notice/notice.ts | 18 ++++++ .../[lng]/(common)/notice/[id]/Reactions.tsx | 55 +++++++++++++++++++ .../notice/[id]/assets/anguished-face.svg | 1 + .../notice/[id]/assets/fire-outlined.svg | 4 ++ .../notice/[id]/assets/loudly-crying-face.svg | 1 + .../assets/surprised-face-with-open-mouth.svg | 1 + .../notice/[id]/assets/thinking-face.svg | 1 + src/app/[lng]/(common)/notice/[id]/page.tsx | 3 + src/app/api/graphql/notices-api.ts | 13 +++++ src/app/api/graphql/route.ts | 4 ++ src/app/api/graphql/schema.graphql | 2 + src/generated/gql.ts | 10 ++++ src/generated/graphql.ts | 34 +++++++++++- src/generated/server.ts | 16 ++++++ 14 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 src/app/[lng]/(common)/notice/[id]/Reactions.tsx create mode 100644 src/app/[lng]/(common)/notice/[id]/assets/anguished-face.svg create mode 100644 src/app/[lng]/(common)/notice/[id]/assets/fire-outlined.svg create mode 100644 src/app/[lng]/(common)/notice/[id]/assets/loudly-crying-face.svg create mode 100644 src/app/[lng]/(common)/notice/[id]/assets/surprised-face-with-open-mouth.svg create mode 100644 src/app/[lng]/(common)/notice/[id]/assets/thinking-face.svg diff --git a/src/api/notice/notice.ts b/src/api/notice/notice.ts index 70c09c2c..908b4ccf 100644 --- a/src/api/notice/notice.ts +++ b/src/api/notice/notice.ts @@ -36,6 +36,12 @@ export interface Notice { contents: Content[]; imagesUrl: string[]; files?: NoticeFile[] | null; + // reactions: +} + +export interface Reaction { + emoji: string; + count: number; } export interface Content { @@ -183,3 +189,15 @@ export const DELETE_NOTICE = gql(` deleteNotice(id: $id) } `); + +export const ADD_REACTION = gql(` + mutation AddReaction($noticeId: Int!, $emoji: String!) { + addReaction(noticeId: $noticeId, emoji: $emoji) + } +`); + +export const DELETE_REACTION = gql(` + mutation DeleteReaction($noticeId: Int!, $emoji: String!) { + deleteReaction(noticeId: $noticeId, emoji: $emoji) + } +`); diff --git a/src/app/[lng]/(common)/notice/[id]/Reactions.tsx b/src/app/[lng]/(common)/notice/[id]/Reactions.tsx new file mode 100644 index 00000000..c65a414e --- /dev/null +++ b/src/app/[lng]/(common)/notice/[id]/Reactions.tsx @@ -0,0 +1,55 @@ +'use client'; + +import Image from 'next/image'; + +import { ADD_REACTION } from '@/api/notice/notice'; +import Button from '@/app/components/atoms/Button'; + +import { apolloClient } from '../../InitClient'; +import AnguishedFace from './assets/anguished-face.svg'; +import Fire from './assets/fire-outlined.svg'; +import LoudlyCryingFace from './assets/loudly-crying-face.svg'; +import SurprisedFace from './assets/surprised-face-with-open-mouth.svg'; +import ThinkingFace from './assets/thinking-face.svg'; + +interface ReactionsProps { + noticeId: number; +} + +const Reactions = ({ noticeId }: ReactionsProps) => { + const handleEmojiClick = async (emoji: string) => { + const res = apolloClient.mutate({ + mutation: ADD_REACTION, + variables: { + noticeId, + emoji, + }, + }); + }; + + return ( +
+ + + + + + + + + +
+ ); +}; + +export default Reactions; diff --git a/src/app/[lng]/(common)/notice/[id]/assets/anguished-face.svg b/src/app/[lng]/(common)/notice/[id]/assets/anguished-face.svg new file mode 100644 index 00000000..42fc85a7 --- /dev/null +++ b/src/app/[lng]/(common)/notice/[id]/assets/anguished-face.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/[lng]/(common)/notice/[id]/assets/fire-outlined.svg b/src/app/[lng]/(common)/notice/[id]/assets/fire-outlined.svg new file mode 100644 index 00000000..0637f2f9 --- /dev/null +++ b/src/app/[lng]/(common)/notice/[id]/assets/fire-outlined.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/app/[lng]/(common)/notice/[id]/assets/loudly-crying-face.svg b/src/app/[lng]/(common)/notice/[id]/assets/loudly-crying-face.svg new file mode 100644 index 00000000..e578ba59 --- /dev/null +++ b/src/app/[lng]/(common)/notice/[id]/assets/loudly-crying-face.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/[lng]/(common)/notice/[id]/assets/surprised-face-with-open-mouth.svg b/src/app/[lng]/(common)/notice/[id]/assets/surprised-face-with-open-mouth.svg new file mode 100644 index 00000000..6a233f8d --- /dev/null +++ b/src/app/[lng]/(common)/notice/[id]/assets/surprised-face-with-open-mouth.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/[lng]/(common)/notice/[id]/assets/thinking-face.svg b/src/app/[lng]/(common)/notice/[id]/assets/thinking-face.svg new file mode 100644 index 00000000..7cc0b54e --- /dev/null +++ b/src/app/[lng]/(common)/notice/[id]/assets/thinking-face.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/app/[lng]/(common)/notice/[id]/page.tsx b/src/app/[lng]/(common)/notice/[id]/page.tsx index 01b266af..983ea2db 100644 --- a/src/app/[lng]/(common)/notice/[id]/page.tsx +++ b/src/app/[lng]/(common)/notice/[id]/page.tsx @@ -17,6 +17,7 @@ import AddtionalNotices from './AdditionalNotices'; import AuthorActions from './AuthorActions'; import Content from './Content'; import NoticeInfo from './NoticeInfo'; +import Reactions from './Reactions'; import WriteEnglishNotice from './WriteEnglishNotice'; export const generateMetadata = async ( @@ -135,6 +136,8 @@ const DetailedNoticePage = async ({ )} + + {notice.imagesUrl.length > 0 && ( <>
diff --git a/src/app/api/graphql/notices-api.ts b/src/app/api/graphql/notices-api.ts index 6f0133bd..20ca8f14 100644 --- a/src/app/api/graphql/notices-api.ts +++ b/src/app/api/graphql/notices-api.ts @@ -93,4 +93,17 @@ export default class NoticesAPI extends RESTDataSource { return false; } } + + async addReaction(noticeId: number, emoji: string, token: string) { + return this.post(`notice/${noticeId}/reaction`, { + body: { emoji }, + headers: { Authorization: `Bearer ${token}` }, + }); + } + + async deleteReaction(noticeId: number, emoji: string, token: string) { + return this.delete(`notice/${noticeId}/reaction/${emoji}`, { + headers: { Authorization: `Bearer ${token}` }, + }); + } } diff --git a/src/app/api/graphql/route.ts b/src/app/api/graphql/route.ts index 07152a72..a1d6a725 100644 --- a/src/app/api/graphql/route.ts +++ b/src/app/api/graphql/route.ts @@ -65,6 +65,10 @@ const resolvers: Resolvers = { ), deleteNotice: (_, { id }, { dataSources, accessToken }) => dataSources.noticesAPI.deleteNotice(id, accessToken!), + addReaction: (_, { noticeId, emoji }, { dataSources, accessToken }) => + dataSources.noticesAPI.addReaction(noticeId, emoji, accessToken!), + deleteReaction: (_, { noticeId, emoji }, { dataSources, accessToken }) => + dataSources.noticesAPI.deleteReaction(noticeId, emoji, accessToken!), }, }; diff --git a/src/app/api/graphql/schema.graphql b/src/app/api/graphql/schema.graphql index 60c93563..e684c27d 100644 --- a/src/app/api/graphql/schema.graphql +++ b/src/app/api/graphql/schema.graphql @@ -98,4 +98,6 @@ type Mutation { noticeId: Int! ): DetailedNotice! deleteNotice(id: Int!): Boolean! + addReaction(noticeId: Int!, emoji: String!): Boolean! + deleteReaction(noticeId: Int!, emoji: String!): Boolean! } diff --git a/src/generated/gql.ts b/src/generated/gql.ts index 24e631c5..9407b0c8 100644 --- a/src/generated/gql.ts +++ b/src/generated/gql.ts @@ -18,6 +18,8 @@ const documents = { "\n mutation AttachInternationalNotice($title: String!, $body: String!, $deadline: Date, $noticeId: Int!, $contentId: Int!, $lang: String!) {\n attachInternationalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId, contentId: $contentId, lang: $lang) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n }\n }\n }\n": types.AttachInternationalNoticeDocument, "\n mutation CreateAdditionalNotice($title: String, $body: String!, $deadline: Date, $noticeId: Int!) {\n createAdditionalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n noticeId\n }\n }\n }\n": types.CreateAdditionalNoticeDocument, "\n mutation DeleteNotice($id: Int!) {\n deleteNotice(id: $id)\n }\n": types.DeleteNoticeDocument, + "\n mutation AddReaction($noticeId: Int!, $emoji: String!) {\n addReaction(noticeId: $noticeId, emoji: $emoji)\n }\n": types.AddReactionDocument, + "\n mutation DeleteReaction($noticeId: Int!, $emoji: String!) {\n deleteReaction(noticeId: $noticeId, emoji: $emoji)\n }\n": types.DeleteReactionDocument, }; /** @@ -54,6 +56,14 @@ export function gql(source: "\n mutation CreateAdditionalNotice($title: String, * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql(source: "\n mutation DeleteNotice($id: Int!) {\n deleteNotice(id: $id)\n }\n"): (typeof documents)["\n mutation DeleteNotice($id: Int!) {\n deleteNotice(id: $id)\n }\n"]; +/** + * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function gql(source: "\n mutation AddReaction($noticeId: Int!, $emoji: String!) {\n addReaction(noticeId: $noticeId, emoji: $emoji)\n }\n"): (typeof documents)["\n mutation AddReaction($noticeId: Int!, $emoji: String!) {\n addReaction(noticeId: $noticeId, emoji: $emoji)\n }\n"]; +/** + * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function gql(source: "\n mutation DeleteReaction($noticeId: Int!, $emoji: String!) {\n deleteReaction(noticeId: $noticeId, emoji: $emoji)\n }\n"): (typeof documents)["\n mutation DeleteReaction($noticeId: Int!, $emoji: String!) {\n deleteReaction(noticeId: $noticeId, emoji: $emoji)\n }\n"]; export function gql(source: string) { return (documents as any)[source] ?? {}; diff --git a/src/generated/graphql.ts b/src/generated/graphql.ts index 0f18610b..888df912 100644 --- a/src/generated/graphql.ts +++ b/src/generated/graphql.ts @@ -52,10 +52,18 @@ export enum MineNotice { export type Mutation = { __typename?: 'Mutation'; + addReaction: Scalars['Boolean']['output']; attachInternationalNotice: DetailedNotice; createAdditionalNotice: DetailedNotice; createNotice: DetailedNotice; deleteNotice: Scalars['Boolean']['output']; + deleteReaction: Scalars['Boolean']['output']; +}; + + +export type MutationAddReactionArgs = { + emoji: Scalars['String']['input']; + noticeId: Scalars['Int']['input']; }; @@ -90,6 +98,12 @@ export type MutationDeleteNoticeArgs = { id: Scalars['Int']['input']; }; + +export type MutationDeleteReactionArgs = { + emoji: Scalars['String']['input']; + noticeId: Scalars['Int']['input']; +}; + export type Notice = { __typename?: 'Notice'; author: Scalars['String']['output']; @@ -202,9 +216,27 @@ export type DeleteNoticeMutationVariables = Exact<{ export type DeleteNoticeMutation = { __typename?: 'Mutation', deleteNotice: boolean }; +export type AddReactionMutationVariables = Exact<{ + noticeId: Scalars['Int']['input']; + emoji: Scalars['String']['input']; +}>; + + +export type AddReactionMutation = { __typename?: 'Mutation', addReaction: boolean }; + +export type DeleteReactionMutationVariables = Exact<{ + noticeId: Scalars['Int']['input']; + emoji: Scalars['String']['input']; +}>; + + +export type DeleteReactionMutation = { __typename?: 'Mutation', deleteReaction: boolean }; + export const GetNoticesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetNotices"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"offset"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"limit"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"notices"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"offset"},"value":{"kind":"Variable","name":{"kind":"Name","value":"offset"}}},{"kind":"Argument","name":{"kind":"Name","value":"limit"},"value":{"kind":"Variable","name":{"kind":"Name","value":"limit"}}},{"kind":"Argument","name":{"kind":"Name","value":"orderBy"},"value":{"kind":"EnumValue","value":"RECENT"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"list"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"views"}},{"kind":"Field","name":{"kind":"Name","value":"currentDeadline"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"author"}},{"kind":"Field","name":{"kind":"Name","value":"imagesUrl"}},{"kind":"Field","name":{"kind":"Name","value":"tags"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"contents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"noticeId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"total"}}]}}]}}]} as unknown as DocumentNode; export const CreateNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"tags"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"images"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"tags"},"value":{"kind":"Variable","name":{"kind":"Name","value":"tags"}}},{"kind":"Argument","name":{"kind":"Name","value":"images"},"value":{"kind":"Variable","name":{"kind":"Name","value":"images"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"contents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"noticeId"}}]}}]}}]}}]} as unknown as DocumentNode; export const AttachInternationalNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AttachInternationalNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"contentId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"lang"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attachInternationalNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"contentId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"contentId"}}},{"kind":"Argument","name":{"kind":"Name","value":"lang"},"value":{"kind":"Variable","name":{"kind":"Name","value":"lang"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"contents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]}}]}}]} as unknown as DocumentNode; export const CreateAdditionalNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateAdditionalNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createAdditionalNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"contents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"noticeId"}}]}}]}}]}}]} as unknown as DocumentNode; -export const DeleteNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}]}]}}]} as unknown as DocumentNode; \ No newline at end of file +export const DeleteNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}]}]}}]} as unknown as DocumentNode; +export const AddReactionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AddReaction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"addReaction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"emoji"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}}}]}]}}]} as unknown as DocumentNode; +export const DeleteReactionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteReaction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteReaction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"emoji"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}}}]}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/src/generated/server.ts b/src/generated/server.ts index 8019e1d2..b4fba62e 100644 --- a/src/generated/server.ts +++ b/src/generated/server.ts @@ -53,10 +53,18 @@ export enum MineNotice { export type Mutation = { __typename?: 'Mutation'; + addReaction: Scalars['Boolean']['output']; attachInternationalNotice: DetailedNotice; createAdditionalNotice: DetailedNotice; createNotice: DetailedNotice; deleteNotice: Scalars['Boolean']['output']; + deleteReaction: Scalars['Boolean']['output']; +}; + + +export type MutationAddReactionArgs = { + emoji: Scalars['String']['input']; + noticeId: Scalars['Int']['input']; }; @@ -91,6 +99,12 @@ export type MutationDeleteNoticeArgs = { id: Scalars['Int']['input']; }; + +export type MutationDeleteReactionArgs = { + emoji: Scalars['String']['input']; + noticeId: Scalars['Int']['input']; +}; + export type Notice = { __typename?: 'Notice'; author: Scalars['String']['output']; @@ -291,10 +305,12 @@ export type DetailedNoticeResolvers = { + addReaction?: Resolver>; attachInternationalNotice?: Resolver>; createAdditionalNotice?: Resolver>; createNotice?: Resolver>; deleteNotice?: Resolver>; + deleteReaction?: Resolver>; }; export type NoticeResolvers = { From f01895a63b548d8476ed7b3ea923069d6979d072 Mon Sep 17 00:00:00 2001 From: Do-hyun Ko Date: Wed, 14 Feb 2024 03:35:06 +0900 Subject: [PATCH 2/5] :sparkles: Match with backend change --- .env | 4 +- .pnp.cjs | 11 + ...loader-npm-0.1.2-317e1d3ef1-26b5f81b24.zip | Bin 0 -> 1929 bytes package.json | 1 + src/api/notice/notice.ts | 123 ++++----- src/app/[lng]/(common)/mypage/MypageTable.tsx | 4 +- .../notice/[id]/AddAdditionalNotice.tsx | 11 +- .../notice/[id]/AdditionalNotices.tsx | 13 +- .../[lng]/(common)/notice/[id]/NoticeInfo.tsx | 9 +- .../[lng]/(common)/notice/[id]/Reactions.tsx | 90 ++++--- src/app/[lng]/(common)/notice/[id]/page.tsx | 63 ++--- .../(common)/write/handle-notice-submit.ts | 4 +- src/app/api/graphql/schema.graphql | 66 ++--- src/app/components/organisms/Tags/Tags.tsx | 7 +- .../organisms/Zabo/ImageZabo.stories.tsx | 4 +- .../components/organisms/Zabo/ImageZabo.tsx | 13 +- .../organisms/Zabo/TextZabo.stories.tsx | 10 +- .../components/organisms/Zabo/TextZabo.tsx | 10 +- src/app/components/organisms/Zabo/Zabo.tsx | 4 +- .../templates/ResultZabo/ResultImageZabo.tsx | 13 +- .../templates/ResultZabo/ResultTextZabo.tsx | 13 +- .../templates/ResultZabo/ResultZabo.tsx | 2 +- .../templates/SearchResults/SearchResults.tsx | 2 +- .../ZaboCarousel/ZaboCarousel.stories.tsx | 245 +----------------- src/generated/gql.ts | 16 +- src/generated/graphql.ts | 84 +++--- src/generated/server.ts | 146 +++++------ src/mock/dummy-mypage-articles.ts | 4 +- src/utils/getLocaleContents.ts | 11 - tsconfig.json | 2 +- yarn.lock | 8 + 31 files changed, 372 insertions(+), 621 deletions(-) create mode 100644 .yarn/cache/ignore-loader-npm-0.1.2-317e1d3ef1-26b5f81b24.zip delete mode 100644 src/utils/getLocaleContents.ts diff --git a/.env b/.env index 3206c940..b6c91bcc 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -NEXT_PUBLIC_API_BASE_URL=https://api.stg.ziggle.gistory.me/ -NEXT_PUBLIC_IDP_BASE_URL=https://idp.gistory.me/ +NEXT_PUBLIC_API_BASE_URL=https://api.stg.ziggle.gistory.me/v3/ +NEXT_PUBLIC_IDP_BASE_URL=https://stg.idp.gistory.me/ NEXT_PUBLIC_IDP_CLIENT_ID=ziggle2023 NEXT_PUBLIC_IDP_REDIRECT_URI=https://stg.ziggle.gistory.me/api/login diff --git a/.pnp.cjs b/.pnp.cjs index 1026578e..5d0b02fe 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -75,6 +75,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["i18next", "npm:23.7.6"],\ ["i18next-browser-languagedetector", "npm:7.2.0"],\ ["i18next-resources-to-backend", "npm:1.2.0"],\ + ["ignore-loader", "npm:0.1.2"],\ ["isomorphic-dompurify", "npm:1.9.0"],\ ["jsdom", "virtual:83b023ebdab1314ff947ce99f7ade4167acbe4884bade3517f8af451f59f14135954817a677debeda585604140e91ee5221d2475b34f0fef082a5f253dd488c2#npm:22.1.0"],\ ["lottie-react", "virtual:87f60e1993a720750ca249cfb3b3cb49c78ef522f4777e0afa244d187678197cd7cf40543d5c4fff4efaea92efc9c1f391189683c0c2d8c070b9a281636b19a1#npm:2.4.0"],\ @@ -15314,6 +15315,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["ignore-loader", [\ + ["npm:0.1.2", {\ + "packageLocation": "./.yarn/cache/ignore-loader-npm-0.1.2-317e1d3ef1-26b5f81b24.zip/node_modules/ignore-loader/",\ + "packageDependencies": [\ + ["ignore-loader", "npm:0.1.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["image-size", [\ ["npm:1.0.2", {\ "packageLocation": "./.yarn/cache/image-size-npm-1.0.2-ed5424d843-01745fdb47.zip/node_modules/image-size/",\ @@ -23585,6 +23595,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["i18next", "npm:23.7.6"],\ ["i18next-browser-languagedetector", "npm:7.2.0"],\ ["i18next-resources-to-backend", "npm:1.2.0"],\ + ["ignore-loader", "npm:0.1.2"],\ ["isomorphic-dompurify", "npm:1.9.0"],\ ["jsdom", "virtual:83b023ebdab1314ff947ce99f7ade4167acbe4884bade3517f8af451f59f14135954817a677debeda585604140e91ee5221d2475b34f0fef082a5f253dd488c2#npm:22.1.0"],\ ["lottie-react", "virtual:87f60e1993a720750ca249cfb3b3cb49c78ef522f4777e0afa244d187678197cd7cf40543d5c4fff4efaea92efc9c1f391189683c0c2d8c070b9a281636b19a1#npm:2.4.0"],\ diff --git a/.yarn/cache/ignore-loader-npm-0.1.2-317e1d3ef1-26b5f81b24.zip b/.yarn/cache/ignore-loader-npm-0.1.2-317e1d3ef1-26b5f81b24.zip new file mode 100644 index 0000000000000000000000000000000000000000..534e7348a126c0c5c20644404edd501f7935a49d GIT binary patch literal 1929 zcmWIWW@Zs#00D<}*EqloD8UP)^YT+t<8$*n(ssU?Q-B)o1F<@OjRlFx*@@|?dRfK!d7*t9`3@QIxO}f`ohm7m@Wg$_ zZ-H|c`Ph&N#AXthe8+`7*z0kEXdW- z#n)9YHzl^;G3&5_fa~|-E`Gixt+(#&{=#r``)W0Xqw_4hL{4TrSt3yLJ!+HrTek%> zzkl7wHRImT153Z|dhGD!<#o;|zCh{r$s2Vl=G=T}A$42w`s0Jg9k++SNZhdO>cxt1 zK~dH+zeU@od1$&y?|8_zxhG)SqW3XnHUFRcWSpw&d?%^DdyCH`k)TlRMRA>{erB$? z8ol-2T%Y(@m(^|shF&ppsB>W@3Uxy z(xxM9U+sRHf4$vha^v62eMhGVxBr}zQFXrlCo3emz+yd?ZO5$=CI$vA76t|-{DI@+ z>Fnwk>>3;7-G9qKVBhcX9*ehL7rzz0SZJP~B(~a9#xhOw_ymbZT1Pa@T>tz&$5OU^ zZHq`{+P>>NttJz8U+X()H0{^r(xP^|L(acB;_d5yvSsEkf64W`*`G%&1VnX;kZ(reemefd-Iij z%#NJgdSqgQ^zDatCbn=yv@9?~% zs=P0PCuC0fjDSA>x~7EoM#X05`^DGz%Rlo(+Fx{fT&w*q_wf9->nBeM zy*78|gew{f2d$@ym`)URTCQF5DSf8*X5Sk@vnE+g_hN4E%2vKydd@T?J9cH%f||B1 zOLeA8g}NwueQsG5!Thm{e?_>>dC#torn{~`;SUPU-C7eV8L`qvIHE@EMUVaSM{2DL zFU>iv)Yv2b$MuXxtIn*8H_poDgf)3BIsS3F)Jm_eiK{MU)Tqq}nqB_F?V1wfx>R58 z$gEJ6o@<>Prjr%ciI|H;nf@sjlv((Fm)QH337qqk!+jIFewh6^@{a*E%`zYTsvQAL ztC>Koj6cn0=B1=o0L!V^Gqzj}20RWAZI_?8GXE&I2!C+$lGa&Xvzrv|-95LizdzkQ z{mm_-mAnk;cikVhzF%$jcE=;b7L)M85ZA~nkC{7W6~$`=J=!7amRxuAr$K14tnY<$ zAGzfNycwD7nQ<4?K-Yo6TSpLuR&3+e3M#l^;H{%Jkcpxdy%>iW1k2Ls1v$*1C5L@#*|CPo3vBRnQT%OQ00&{GA%JU&*u=E2fP VfHx}}ND~_no&kDlIZzt|0|4cZ>%;&6 literal 0 HcmV?d00001 diff --git a/package.json b/package.json index ca936665..dd6d0fcf 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-storybook": "^0.6.14", "http-proxy-middleware": "^2.0.6", + "ignore-loader": "^0.1.2", "node-fetch": "2", "postcss": "latest", "prettier": "^3.1.0", diff --git a/src/api/notice/notice.ts b/src/api/notice/notice.ts index 908b4ccf..acbafcc3 100644 --- a/src/api/notice/notice.ts +++ b/src/api/notice/notice.ts @@ -9,6 +9,11 @@ export interface NoticePaginationParams { limit?: number; } +export interface Tag { + id: number; + name: string; +} + export enum NoticeKind { RECRUIT = 'recruit', EVENT = 'event', @@ -25,52 +30,40 @@ export interface NoticeSearchParams { export interface Notice { id: number; - views: number; - currentDeadline?: dayjs.Dayjs | string | null; + title: string; + deadline: dayjs.Dayjs | string | null; + currentDeadline: dayjs.Dayjs | string | null; + langs: string[]; + content: string; + author: { + name: string; + uuid: string; + }; createdAt: dayjs.Dayjs | string; - updatedAt: dayjs.Dayjs | string; - deletedAt?: dayjs.Dayjs | string | null; - author: string; - tags: Tag[]; - logName?: string; - contents: Content[]; - imagesUrl: string[]; - files?: NoticeFile[] | null; - // reactions: + tags: string[]; + views: number; + imageUrls: string[]; + documentUrls: string[]; + isReminded: boolean; + reactions: Reaction[]; } export interface Reaction { emoji: string; count: number; + isReacted: boolean; } export interface Content { id: number; - lang: string; // TODO: enum graphql๊ณผ์˜ ํ˜ธํ™˜์„ฑ ๋ฌธ์ œ๋กœ ์ž„์‹œ๋กœ string์œผ๋กœ ์‚ฌ์šฉ - title: string; - body: string; - deadline?: dayjs.Dayjs | string | null; - createdAt: dayjs.Dayjs | string; - noticeId: number; -} - -interface NoticeFile { - uuid: string; - name: string; - createdAt: dayjs.Dayjs | string; - url: string; - type: string; // TODO: enum - noticeId: number; -} - -export interface Tag { - id: number; - name: string; + deadline: Date; + content: string; + lang: string; + createdAt: Date; } export interface NoticeDetail extends Notice { - reminder: boolean; - authorId: string; + additionalContents: Content[]; } export interface Notices { @@ -86,10 +79,6 @@ export const getAllNotices = async ( list: data.list.map(({ currentDeadline, ...notice }) => ({ ...notice, currentDeadline: currentDeadline ?? null, - contents: notice.contents.map(({ deadline, ...content }) => ({ - ...content, - deadline: deadline ?? null, - })), })), })); @@ -97,10 +86,6 @@ export const getNotice = async (id: number) => api.get(`/notice/${id}`).then(({ data }) => ({ ...data, currentDeadline: data.currentDeadline || null, - contents: data.contents.map(({ deadline, ...content }) => ({ - ...content, - deadline: deadline || null, - })), })); export const GET_NOTICES = gql(` @@ -108,25 +93,25 @@ export const GET_NOTICES = gql(` notices(offset: $offset, limit: $limit, orderBy: RECENT) { list { id - views + title + deadline currentDeadline - createdAt - updatedAt - deletedAt - author - imagesUrl - tags { - id + langs + content + author { name + uuid } - contents { - id - lang - title - body - deadline - createdAt - noticeId + createdAt + tags + views + imageUrls + documentUrls + isReminded + reactions { + emoji + count + isReacted } } total @@ -138,14 +123,12 @@ export const CREATE_NOTICE = gql(` mutation CreateNotice($title: String!, $body: String!, $deadline: Date, $tags: [Int!], $images: [String!]) { createNotice(title: $title, body: $body, deadline: $deadline, tags: $tags, images: $images) { id - contents { + additionalContents { id - lang - title - body deadline + content + lang createdAt - noticeId } } } @@ -155,14 +138,6 @@ export const ATTACH_INTERNATIONAL_NOTICE = gql(` mutation AttachInternationalNotice($title: String!, $body: String!, $deadline: Date, $noticeId: Int!, $contentId: Int!, $lang: String!) { attachInternationalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId, contentId: $contentId, lang: $lang) { id - contents { - id - lang - title - body - deadline - createdAt - } } } `); @@ -171,14 +146,12 @@ export const CREATE_ADDITIONAL_NOTICE = gql(` mutation CreateAdditionalNotice($title: String, $body: String!, $deadline: Date, $noticeId: Int!) { createAdditionalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId) { id - contents { + additionalContents { id - lang - title - body deadline + content + lang createdAt - noticeId } } } diff --git a/src/app/[lng]/(common)/mypage/MypageTable.tsx b/src/app/[lng]/(common)/mypage/MypageTable.tsx index 7da5cd81..f88d94b3 100644 --- a/src/app/[lng]/(common)/mypage/MypageTable.tsx +++ b/src/app/[lng]/(common)/mypage/MypageTable.tsx @@ -5,7 +5,6 @@ import { Notice } from '@/api/notice/notice'; import { createTranslation, PropsWithLng } from '@/app/i18next'; import { Locale } from '@/app/i18next/settings'; import LazyCat from '@/assets/lazy-cat.svg'; -import getLocaleContents from '@/utils/getLocaleContents'; interface MypageTableProps { title: string; @@ -49,7 +48,6 @@ const MypageTable = async ({ {articles.map((articleObj, index) => { const isLastRow = index === articles.length - 1; const underLine = isLastRow ? '' : 'border-b border-gray-300'; - const localeContents = getLocaleContents(articleObj.contents, lng); return (
- {localeContents[0].title} + {articleObj.title}
diff --git a/src/app/[lng]/(common)/notice/[id]/AddAdditionalNotice.tsx b/src/app/[lng]/(common)/notice/[id]/AddAdditionalNotice.tsx index 015ae2b5..967470ec 100644 --- a/src/app/[lng]/(common)/notice/[id]/AddAdditionalNotice.tsx +++ b/src/app/[lng]/(common)/notice/[id]/AddAdditionalNotice.tsx @@ -24,17 +24,16 @@ import AddIcon from '@/assets/icons/add.svg'; import { WarningSwal } from '@/utils/swals'; import { apolloClient } from '../../InitClient'; -import AddNoticeRadio from './AddNoticeRadio'; interface AddAddtionalNoticesProps { noticeId: number; originallyHasDeadline: string | Dayjs | null; - supportLanguage: string[]; + supportedLanguage: string[]; } const AddAdditionalNotice = ({ noticeId, - supportLanguage, + supportedLanguage, originallyHasDeadline, lng, }: AddAddtionalNoticesProps & PropsWithLng) => { @@ -46,7 +45,7 @@ const AddAdditionalNotice = ({ const { t } = useTranslation(lng); - const supportEnglish = supportLanguage.includes('en'); + const supportEnglish = supportedLanguage.includes('en'); const { refresh } = useRouter(); @@ -72,7 +71,7 @@ const AddAdditionalNotice = ({ }, }); - const contents = notice.data?.createAdditionalNotice.contents; + const contents = notice.data?.createAdditionalNotice.additionalContents; if (!contents) { return; } @@ -156,7 +155,7 @@ const AddAdditionalNotice = ({ />
- {supportLanguage.includes('en') && ( + {supportedLanguage.includes('en') && (
{t('zabo.additionalNotices.englishAdditionalNotice')} diff --git a/src/app/[lng]/(common)/notice/[id]/AdditionalNotices.tsx b/src/app/[lng]/(common)/notice/[id]/AdditionalNotices.tsx index cd10a8e9..6b7a2cba 100644 --- a/src/app/[lng]/(common)/notice/[id]/AdditionalNotices.tsx +++ b/src/app/[lng]/(common)/notice/[id]/AdditionalNotices.tsx @@ -1,18 +1,17 @@ import dayjs from 'dayjs'; -import { Content } from '@/api/notice/notice'; +import { Content, NoticeDetail } from '@/api/notice/notice'; import { PropsWithLng, T } from '@/app/i18next'; import AddIcon from '@/assets/icons/add.svg'; -import getLocaleContents from '@/utils/getLocaleContents'; interface AdditionalNoticesProps { - mainContent: Content; + notice: NoticeDetail; additionalContents: Content[]; t: T; } const AdditionalNotices = async ({ - mainContent, + notice, additionalContents, t, lng, @@ -21,9 +20,7 @@ const AdditionalNotices = async ({
{additionalContents.map((content, index) => { const lastDeadline = - index > 0 - ? additionalContents[index - 1].deadline - : mainContent.deadline; + index > 0 ? additionalContents[index - 1].deadline : notice.deadline; const deadlineChanged = !dayjs(content.deadline).isSame( dayjs(lastDeadline), @@ -66,7 +63,7 @@ const AdditionalNotices = async ({
-

{content.body}

+

{content.content}

); diff --git a/src/app/[lng]/(common)/notice/[id]/NoticeInfo.tsx b/src/app/[lng]/(common)/notice/[id]/NoticeInfo.tsx index 1b3e5c4e..df65fc10 100644 --- a/src/app/[lng]/(common)/notice/[id]/NoticeInfo.tsx +++ b/src/app/[lng]/(common)/notice/[id]/NoticeInfo.tsx @@ -7,13 +7,13 @@ import { NoticeDetail } from '@/api/notice/notice'; import DDay from '@/app/components/molecules/DDay'; import Tags from '@/app/components/organisms/Tags'; import { createTranslation, PropsWithLng, PropsWithT } from '@/app/i18next'; -import getLocaleContents from '@/utils/getLocaleContents'; interface NoticeInfoProps extends Omit {} const NoticeInfo = async ({ currentDeadline: deadline, - contents, + title, + content, author, createdAt, views, @@ -21,7 +21,6 @@ const NoticeInfo = async ({ lng, }: PropsWithLng) => { const { t } = await createTranslation(lng); - const localeContents = getLocaleContents(contents, lng); return (
@@ -31,10 +30,10 @@ const NoticeInfo = async ({
)} - + <Title title={title} /> <div className="h-2" /> <Metadata - author={author} + author={author.name} createdAt={dayjs(createdAt)} views={views} t={t} diff --git a/src/app/[lng]/(common)/notice/[id]/Reactions.tsx b/src/app/[lng]/(common)/notice/[id]/Reactions.tsx index c65a414e..288086af 100644 --- a/src/app/[lng]/(common)/notice/[id]/Reactions.tsx +++ b/src/app/[lng]/(common)/notice/[id]/Reactions.tsx @@ -1,8 +1,8 @@ 'use client'; -import Image from 'next/image'; +import { toast } from 'react-toastify'; -import { ADD_REACTION } from '@/api/notice/notice'; +import { ADD_REACTION, Notice, Reaction } from '@/api/notice/notice'; import Button from '@/app/components/atoms/Button'; import { apolloClient } from '../../InitClient'; @@ -12,42 +12,74 @@ import LoudlyCryingFace from './assets/loudly-crying-face.svg'; import SurprisedFace from './assets/surprised-face-with-open-mouth.svg'; import ThinkingFace from './assets/thinking-face.svg'; +const ReactionButton = ({ + emoji, + count, + isReacted, + onClick, +}: Reaction & { onClick: () => void }) => { + return ( + <Button variant={isReacted ? 'contained' : 'outlined'} onClick={onClick}> + {emoji === '๐Ÿ”ฅ' ? ( + <Fire width={20} /> + ) : emoji === '๐Ÿ˜ญ' ? ( + <LoudlyCryingFace width={20} /> + ) : emoji === '๐Ÿ˜ง' ? ( + <AnguishedFace width={20} /> + ) : emoji === '๐Ÿค”' ? ( + <ThinkingFace width={20} /> + ) : emoji === '๐Ÿ˜ฎ' ? ( + <SurprisedFace width={20} /> + ) : null} + + <p>{count}</p> + </Button> + ); +}; + interface ReactionsProps { - noticeId: number; + notice: Notice; } -const Reactions = ({ noticeId }: ReactionsProps) => { +const preReactionList = ['๐Ÿ”ฅ', '๐Ÿ˜ญ', '๐Ÿ˜ง', '๐Ÿค”', '๐Ÿ˜ฎ']; + +const Reactions = ({ notice: { id, reactions } }: ReactionsProps) => { const handleEmojiClick = async (emoji: string) => { - const res = apolloClient.mutate({ - mutation: ADD_REACTION, - variables: { - noticeId, - emoji, - }, - }); + try { + const res = await apolloClient.mutate({ + mutation: ADD_REACTION, + variables: { + noticeId: id, + emoji, + }, + }); + } catch (e) { + toast.error('๋กœ๊ทธ์ธ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.'); + console.log(e); + } }; return ( <div className={'flex gap-2'}> - <Button variant={'contained'} onClick={() => handleEmojiClick('๐Ÿ”ฅ')}> - <Fire /> - </Button> - - <Button variant={'contained'}> - <LoudlyCryingFace width={20} /> - </Button> - - <Button variant={'contained'}> - <AnguishedFace width={20} /> - </Button> - - <Button variant={'contained'}> - <ThinkingFace width={20} /> - </Button> + {preReactionList + .map((emoji) => { + const reaction = reactions.find( + (reaction) => reaction.emoji === emoji, + ); - <Button variant={'contained'}> - <SurprisedFace width={20} /> - </Button> + return { + emoji, + count: reaction?.count ?? 0, + isReacted: reaction?.isReacted ?? false, + }; + }) + .map((reaction) => ( + <ReactionButton + key={reaction.emoji} + onClick={() => handleEmojiClick(reaction.emoji)} + {...reaction} + /> + ))} </div> ); }; diff --git a/src/app/[lng]/(common)/notice/[id]/page.tsx b/src/app/[lng]/(common)/notice/[id]/page.tsx index 983ea2db..68a6dde6 100644 --- a/src/app/[lng]/(common)/notice/[id]/page.tsx +++ b/src/app/[lng]/(common)/notice/[id]/page.tsx @@ -1,15 +1,12 @@ -import { GetServerSideProps, Metadata, ResolvingMetadata } from 'next'; -import { useRouter } from 'next/router'; -import { createServerContext } from 'react'; +import { Metadata, ResolvingMetadata } from 'next'; import { auth } from '@/api/auth/auth'; import { getNotice } from '@/api/notice/notice'; import ImageCarousel from '@/app/components/organisms/ImageCarousel'; import HowAboutThese from '@/app/components/templates/HowAboutThese'; import ZaboShowcase from '@/app/components/templates/ZaboShowcase'; -import { createTranslation, PropsWithLng } from '@/app/i18next'; +import { createTranslation } from '@/app/i18next'; import { Locale } from '@/app/i18next/settings'; -import getLocaleContents from '@/utils/getLocaleContents'; import Actions from './Actions'; import AddAdditionalNotice from './AddAdditionalNotice'; @@ -30,18 +27,16 @@ export const generateMetadata = async ( const notice = await getNotice(Number.parseInt(id)); const previousImages = (await parent).openGraph?.images ?? []; - const localeContents = getLocaleContents(notice.contents, searchParams.lng); - return { - title: localeContents[0].title, - description: localeContents[0].body.slice(0, 100).replace(/\n/g, ' '), - keywords: notice.tags.map((tag) => tag.name), - authors: [{ name: notice.author }], + title: notice.title, + description: notice.content.slice(0, 100).replace(/\n/g, ' '), + keywords: notice.tags, + authors: [{ name: notice.author.name }], openGraph: { - title: localeContents[0].title, - description: localeContents[0].body.slice(0, 100).replace(/\n/g, ' '), + title: notice.title, + description: notice.content.slice(0, 100).replace(/\n/g, ' '), url: `https://ziggle.gistory.me/notice/${id}`, - images: [...notice.imagesUrl, ...previousImages], + images: [...notice.imageUrls, ...previousImages], }, }; }; @@ -56,32 +51,22 @@ const DetailedNoticePage = async ({ const { t } = await createTranslation(lng, 'translation'); const notice = await getNotice(Number.parseInt(id)); - const localContents = getLocaleContents(notice.contents, lng); - - const mainContent = - localContents.find((content) => content.id === 1) ?? localContents[0]; - - const additionalContents = localContents.filter( - (content) => content.id !== 1, - ); - - const title = localContents[0].title; + const title = notice.title; const user = await auth(); const isAdditionalNoticeShow = true; const isWriteEnglishNoticeShow = true; - const supportLanguage = notice.contents.map((content) => content.lang); // TODO: make this unique - const supportEnglish = supportLanguage.includes('en'); + const supportEnglish = notice.langs.includes('en'); return ( <> - <ZaboShowcase srcs={notice.imagesUrl} alt={title} lng={lng} /> + <ZaboShowcase srcs={notice.imageUrls} alt={title} lng={lng} /> <div className="content mx-auto mt-8 md:mt-12"> - <Actions title={localContents[0].title} lng={lng} /> + <Actions title={title} lng={lng} /> - {user && user.id === notice.authorId && ( + {user && user.id === notice.author.uuid && ( <> <div className="h-5" /> <AuthorActions @@ -100,30 +85,30 @@ const DetailedNoticePage = async ({ lng={lng} /> <div className="h-5" /> - <Content content={mainContent?.body ?? ''} /> + <Content content={notice.content} /> <div className="h-10" /> <AddtionalNotices - additionalContents={additionalContents} - mainContent={mainContent} + additionalContents={notice.additionalContents} + notice={notice} t={t} lng={lng} /> - {user && user.id === notice.authorId && isAdditionalNoticeShow && ( + {user && user.id === notice.author.uuid && isAdditionalNoticeShow && ( <> <div className="h-10" id="addNotice" /> <AddAdditionalNotice lng={lng} noticeId={Number(id)} - originallyHasDeadline={notice.currentDeadline} - supportLanguage={supportLanguage} + originallyHasDeadline={notice.deadline} + supportedLanguage={notice.langs} /> </> )} {user && - user.id === notice.authorId && + user.id === notice.author.uuid && isWriteEnglishNoticeShow && !supportEnglish && ( <> @@ -136,12 +121,12 @@ const DetailedNoticePage = async ({ </> )} - <Reactions /> + <Reactions notice={notice} /> - {notice.imagesUrl.length > 0 && ( + {notice.imageUrls.length > 0 && ( <> <div className="h-20" /> - <ImageCarousel srcs={notice.imagesUrl} alt={title} lng={lng} /> + <ImageCarousel srcs={notice.imageUrls} alt={title} lng={lng} /> </> )} <div className="h-20" /> diff --git a/src/app/[lng]/(common)/write/handle-notice-submit.ts b/src/app/[lng]/(common)/write/handle-notice-submit.ts index 5b9771d5..777abe8d 100644 --- a/src/app/[lng]/(common)/write/handle-notice-submit.ts +++ b/src/app/[lng]/(common)/write/handle-notice-submit.ts @@ -206,7 +206,7 @@ const handleNoticeSubmit = async ({ return; } - const { id, contents } = notice.data?.createNotice; + const { id, additionalContents } = notice.data?.createNotice; if (!id) { Swal.fire({ @@ -226,7 +226,7 @@ const handleNoticeSubmit = async ({ deadline, body: englishBody!, noticeId: id, - contentId: contents[0].id, + contentId: additionalContents[0].id, }, }); } diff --git a/src/app/api/graphql/schema.graphql b/src/app/api/graphql/schema.graphql index e684c27d..cb5d8b83 100644 --- a/src/app/api/graphql/schema.graphql +++ b/src/app/api/graphql/schema.graphql @@ -1,57 +1,57 @@ scalar Date -type Tag { - id: Int! - name: String! -} - type Content { id: Int! - lang: String! - title: String! - body: String! deadline: Date + content: String! + lang: String! createdAt: Date! - noticeId: Int! } -type NoticeFile { - uuid: String! +type Reaction { + emoji: String! + count: Int! + isReacted: Boolean! +} + +type Author { name: String! - createdAt: Date! - url: String! - type: String! - noticeId: Int! + uuid: String! } type Notice { id: Int! - views: Int! + title: String! + deadline: Date currentDeadline: Date + langs: [String!]! + content: String! + author: Author! createdAt: Date! - updatedAt: Date! - deletedAt: Date - author: String! - tags: [Tag!]! - imagesUrl: [String!]! - contents: [Content!]! - files: [NoticeFile!] + tags: [String!]! + views: Int! + imageUrls: [String!]! + documentUrls: [String!]! + isReminded: Boolean! + reactions: [Reaction!]! } type DetailedNotice { id: Int! - views: Int! + title: String! + deadline: Date currentDeadline: Date + langs: [String!]! + content: String! + author: Author! createdAt: Date! - updatedAt: Date! - deletedAt: Date - authorId: String! - author: String! - tags: [Tag!]! - imagesUrl: [String!]! - contents: [Content!]! - files: [NoticeFile!] - reminder: Boolean! + tags: [String!]! + views: Int! + imageUrls: [String!]! + documentUrls: [String!]! + isReminded: Boolean! + reactions: [Reaction!]! + additionalContents: [Content!]! } type Notices { diff --git a/src/app/components/organisms/Tags/Tags.tsx b/src/app/components/organisms/Tags/Tags.tsx index 3abe7551..07967349 100644 --- a/src/app/components/organisms/Tags/Tags.tsx +++ b/src/app/components/organisms/Tags/Tags.tsx @@ -1,4 +1,3 @@ -import { Tag } from '@/api/notice/notice'; import { createTranslation, PropsWithLng } from '@/app/i18next'; import Chip from '../../molecules/Chip'; @@ -14,16 +13,16 @@ const Tags = async ({ searchQuery, lng, }: PropsWithLng<{ - tags: Tag[]; + tags: string[]; className?: string; searchQuery?: string; }>) => { const { t } = await createTranslation(lng); return ( <div className={`flex gap-2 ${className ?? ''}`}> - {tags.map(({ id, name }, i) => ( + {tags.map((name, i) => ( <Chip - key={id} + key={name} className="font-normal" variant={name === searchQuery ? 'contained' : undefined} >{`#${isDefaultTag(name) ? t(`notices.${name}.name`) : name}`}</Chip> diff --git a/src/app/components/organisms/Zabo/ImageZabo.stories.tsx b/src/app/components/organisms/Zabo/ImageZabo.stories.tsx index 7ef195a3..375c50da 100644 --- a/src/app/components/organisms/Zabo/ImageZabo.stories.tsx +++ b/src/app/components/organisms/Zabo/ImageZabo.stories.tsx @@ -16,12 +16,12 @@ const Template: StoryFn<typeof Zabo> = (args) => { return <Zabo {...args} t={t} />; }; const args = { - imagesUrl: ['https://picsum.photos/200/300'], + imageUrls: ['https://picsum.photos/200/300'], title: '23๋…„๋„ ์ธํฌํŒ€ ์‹ ๊ทœ ๋ถ€์› ๋ชจ์ง‘', content: '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', createdAt: dayjs('2023-02-14T11:57:18.740Z'), views: 110, - author: '์ด์ •์šฐ', + author: { name: '์ธํฌํŒ€', uuid: 'info' }, deadline: dayjs().add(1, 'd'), }; diff --git a/src/app/components/organisms/Zabo/ImageZabo.tsx b/src/app/components/organisms/Zabo/ImageZabo.tsx index 78e9d225..273e7e47 100644 --- a/src/app/components/organisms/Zabo/ImageZabo.tsx +++ b/src/app/components/organisms/Zabo/ImageZabo.tsx @@ -3,14 +3,13 @@ import { Trans } from 'react-i18next'; import ZaboImage from '@/app/components/molecules/ZaboImage'; import { PropsWithLng } from '@/app/i18next'; -import getLocaleContents from '@/utils/getLocaleContents'; import DDay from '../../molecules/DDay'; import { ZaboOrigin, ZaboProps, ZaboSize } from './Zabo'; const ImageZabo = <Origin extends ZaboOrigin>({ - imagesUrl, - contents, + imageUrls, + title, createdAt, views, author, @@ -20,13 +19,9 @@ const ImageZabo = <Origin extends ZaboOrigin>({ height, lng, }: ZaboProps<Origin> & PropsWithLng) => { - const localContents = getLocaleContents(contents, lng); - const deadline = rawDeadline ? dayjs(rawDeadline) : undefined; const size = { width, height } as ZaboSize<Origin>; - const title = localContents[0].title; - return ( <div className="group mt-4 flex w-min flex-col gap-3"> <div @@ -37,7 +32,7 @@ const ImageZabo = <Origin extends ZaboOrigin>({ } > <ZaboImage - src={imagesUrl[0]} + src={imageUrls[0]} alt={title} className="rounded border border-secondaryText object-cover" {...size} @@ -60,7 +55,7 @@ const ImageZabo = <Origin extends ZaboOrigin>({ <strong className="font-bold"> ยท {{ views }}</strong> </Trans> </div> - <div className="font-bold">{author}</div> + <div className="font-bold">{author.name}</div> </div> </div> ); diff --git a/src/app/components/organisms/Zabo/TextZabo.stories.tsx b/src/app/components/organisms/Zabo/TextZabo.stories.tsx index bb844eed..0f95637b 100644 --- a/src/app/components/organisms/Zabo/TextZabo.stories.tsx +++ b/src/app/components/organisms/Zabo/TextZabo.stories.tsx @@ -14,15 +14,11 @@ export default { const Template: StoryFn<typeof Zabo> = (args) => { const { t } = useTranslation(fallbackLng); const lineClampLevel = - args.contents[0].title.length > 40 - ? 2 - : args.contents[0].title.length > 20 - ? 1 - : 0; + args.title.length > 40 ? 2 : args.title.length > 20 ? 1 : 0; return ( <> - <div>length of title: {args.contents[0].title.length}</div> + <div>length of title: {args.title.length}</div> <br /> <code className="whitespace-pre"> {'const lineClampLevel = title.length > 40 ? 2 : title.length > 20 ? 1 : 0;\n\n' + @@ -82,7 +78,7 @@ const args = { content: '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', createdAt: dayjs('2023-02-14T11:57:18.740Z'), views: 110, - author: '์ด์ •์šฐ', + author: { name: '์ธํฌํŒ€', uuid: 'info' }, deadline: dayjs().add(1, 'd'), // organization: "INFOTEAM", }; diff --git a/src/app/components/organisms/Zabo/TextZabo.tsx b/src/app/components/organisms/Zabo/TextZabo.tsx index 5e82fdbe..c6cca3e4 100644 --- a/src/app/components/organisms/Zabo/TextZabo.tsx +++ b/src/app/components/organisms/Zabo/TextZabo.tsx @@ -2,13 +2,13 @@ import dayjs from 'dayjs'; import { Trans } from 'react-i18next'; import { PropsWithLng } from '@/app/i18next'; -import getLocaleContents from '@/utils/getLocaleContents'; import DDay from '../../molecules/DDay'; import { ZaboOrigin, ZaboProps } from './Zabo'; const TextZabo = <Origin extends ZaboOrigin>({ - contents, + content, + title, createdAt, views, author, @@ -22,8 +22,6 @@ const TextZabo = <Origin extends ZaboOrigin>({ const origin = width ? 'width' : 'height'; const antiOrigin = width ? 'height' : 'width'; const originSize = (origin === 'width' ? width : height) ?? 0; - const localContents = getLocaleContents(contents, lng); - const title = localContents[0].title; const lineClampLevel = title.length > 40 ? 2 : title.length > 20 ? 1 : 0; @@ -59,7 +57,7 @@ const TextZabo = <Origin extends ZaboOrigin>({ {title} </div> <div className="shrink overflow-hidden text-lg font-medium"> - {localContents[0].body} + {content} </div> <div className={'grow'} /> <div className="flex flex-col gap-2.5"> @@ -69,7 +67,7 @@ const TextZabo = <Origin extends ZaboOrigin>({ <strong className="font-bold"> ยท {{ views }}</strong> </Trans> </div> - <div className="font-bold">{author}</div> + <div className="font-bold">{author.name}</div> </div> </div> ); diff --git a/src/app/components/organisms/Zabo/Zabo.tsx b/src/app/components/organisms/Zabo/Zabo.tsx index a6c3e4a3..0db7af4f 100644 --- a/src/app/components/organisms/Zabo/Zabo.tsx +++ b/src/app/components/organisms/Zabo/Zabo.tsx @@ -19,10 +19,10 @@ export type ZaboProps<Origin extends ZaboOrigin> = PropsWithT< const Zabo = <IsImage extends boolean>( props: ZaboProps<ZaboOrigin> & PropsWithLng, ) => - props.imagesUrl.length > 0 ? ( + props.imageUrls.length > 0 ? ( <ImageZabo {...(props as ZaboProps<ZaboOrigin> & PropsWithLng)} - imagesUrl={props.imagesUrl} + imageUrls={props.imageUrls} /> ) : ( <TextZabo {...(props as ZaboProps<ZaboOrigin> & PropsWithLng)} /> diff --git a/src/app/components/templates/ResultZabo/ResultImageZabo.tsx b/src/app/components/templates/ResultZabo/ResultImageZabo.tsx index a40fedb9..dfe70a74 100644 --- a/src/app/components/templates/ResultZabo/ResultImageZabo.tsx +++ b/src/app/components/templates/ResultZabo/ResultImageZabo.tsx @@ -6,7 +6,6 @@ import Link from 'next/link'; import { Trans } from 'react-i18next/TransWithoutContext'; import { createTranslation } from '@/app/i18next'; -import getLocaleContents from '@/utils/getLocaleContents'; import HighlightedText from '../../molecules/HighlightedText'; import ZaboImage from '../../molecules/ZaboImage'; @@ -14,29 +13,25 @@ import Tags from '../../organisms/Tags'; import { ResultZaboProps } from './ResultZabo'; const ResultImageZabo = async ({ - contents, + title, createdAt, views, author, currentDeadline, tags, searchQuery, - imagesUrl, + imageUrls, id, lng, }: ResultZaboProps) => { const { t } = await createTranslation(lng); - const localeContents = getLocaleContents(contents, lng); - - const title = localeContents[0].title; - return ( <Link className={'w-full'} href={`/${lng}/notice/` + id}> <div className="box-border flex w-full flex-nowrap items-stretch justify-start gap-5 overflow-hidden rounded border border-secondaryText"> <ZaboImage width={230} // handle mobile - src={imagesUrl[0]} + src={imageUrls[0]} alt={title} style={{ objectFit: 'cover', objectPosition: 'center' }} /> @@ -68,7 +63,7 @@ const ResultImageZabo = async ({ <p className="text-start text-sm font-bold md:text-lg"> {searchQuery ? ( <HighlightedText query={searchQuery}> - {author} + {author.name} </HighlightedText> ) : ( author diff --git a/src/app/components/templates/ResultZabo/ResultTextZabo.tsx b/src/app/components/templates/ResultZabo/ResultTextZabo.tsx index ae56baa6..99999440 100644 --- a/src/app/components/templates/ResultZabo/ResultTextZabo.tsx +++ b/src/app/components/templates/ResultZabo/ResultTextZabo.tsx @@ -5,14 +5,14 @@ import Link from 'next/link'; import { Trans } from 'react-i18next/TransWithoutContext'; import { createTranslation } from '@/app/i18next'; -import getLocaleContents from '@/utils/getLocaleContents'; import HighlightedText from '../../molecules/HighlightedText'; import Tags from '../../organisms/Tags'; import { ResultZaboProps } from './ResultZabo'; const ResultTextZabo = async ({ - contents, + content, + title, createdAt, views, author, @@ -24,9 +24,6 @@ const ResultTextZabo = async ({ lng, }: ResultZaboProps) => { const { t } = await createTranslation(lng); - const localeContents = getLocaleContents(contents, lng); - - const title = localeContents[0].title; return ( <Link className={'w-full'} href={`/${lng}/notice/` + id}> @@ -56,7 +53,9 @@ const ResultTextZabo = async ({ <div className="flex items-center gap-0.5"> <div className="text-lg font-bold"> {searchQuery ? ( - <HighlightedText query={searchQuery}>{author}</HighlightedText> + <HighlightedText query={searchQuery}> + {author.name} + </HighlightedText> ) : ( author )} @@ -72,7 +71,7 @@ const ResultTextZabo = async ({ /> <div className="line-clamp-4 text-ellipsis text-start text-sm font-medium"> - {localeContents[0].body ?? t('zabo.noContent')} + {content ?? t('zabo.noContent')} </div> <div className="flex gap-0.5"> diff --git a/src/app/components/templates/ResultZabo/ResultZabo.tsx b/src/app/components/templates/ResultZabo/ResultZabo.tsx index 32d692b0..8df647b0 100644 --- a/src/app/components/templates/ResultZabo/ResultZabo.tsx +++ b/src/app/components/templates/ResultZabo/ResultZabo.tsx @@ -16,7 +16,7 @@ export type ResultZaboProps = PropsWithLng< >; const ResultZabo = (props: ResultZaboProps) => { - return props.imagesUrl.length > 0 ? ( // image exists in zabo + return props.imageUrls.length > 0 ? ( // image exists in zabo <ResultImageZabo {...(props as ResultZaboProps)} /> ) : ( <ResultTextZabo {...(props as ResultZaboProps)} /> diff --git a/src/app/components/templates/SearchResults/SearchResults.tsx b/src/app/components/templates/SearchResults/SearchResults.tsx index 5579eff2..ac927af7 100644 --- a/src/app/components/templates/SearchResults/SearchResults.tsx +++ b/src/app/components/templates/SearchResults/SearchResults.tsx @@ -33,7 +33,7 @@ const Results = async ({ event="search_result_click" properties={{ location: 'SearchPage', - isText: notice.imagesUrl.length === 0, + isText: notice.imageUrls.length === 0, }} key={notice.id} > diff --git a/src/app/components/templates/ZaboCarousel/ZaboCarousel.stories.tsx b/src/app/components/templates/ZaboCarousel/ZaboCarousel.stories.tsx index 5ae9b612..a3ff007a 100644 --- a/src/app/components/templates/ZaboCarousel/ZaboCarousel.stories.tsx +++ b/src/app/components/templates/ZaboCarousel/ZaboCarousel.stories.tsx @@ -15,243 +15,20 @@ Default.args = { notices: [ { id: 1, - imagesUrl: ['https://picsum.photos/200/300'], - contents: [ - { - id: 1, - lang: 'ko', - title: '23๋…„๋„ ์ธํฌํŒ€ ์‹ ๊ทœ ๋ถ€์› ๋ชจ์ง‘', - body: '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - { - id: 2, - lang: 'en', - title: "We're recruiting new members for the Info Team in 2023", - body: 'The Info Team is recruiting new members for 2023. Please apply a lot.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - ], + title: '์ธํฌํŒ€ ์‹ ๊ทœ ๋ถ€์› ๋ชจ์ง‘', + deadline: dayjs('2023-02-14T11:57:18.740Z'), + currentDeadline: null, + imageUrls: ['https://picsum.photos/200/300'], + documentUrls: [], + langs: ['ko'], + content: + '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', createdAt: dayjs('2023-02-14T11:57:18.740Z'), - updatedAt: dayjs('2023-02-14T11:57:18.740Z'), views: 110, - author: '์ด์ •์šฐ', + author: { name: '์ธํฌํŒ€', uuid: 'info' }, tags: [], - files: [], - }, - { - id: 2, - imagesUrl: ['https://picsum.photos/200/300'], - contents: [ - { - id: 1, - lang: 'ko', - title: '23๋…„๋„ ์ธํฌํŒ€ ์‹ ๊ทœ ๋ถ€์› ๋ชจ์ง‘', - body: '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - { - id: 2, - lang: 'en', - title: "We're recruiting new members for the Info Team in 2023", - body: 'The Info Team is recruiting new members for 2023. Please apply a lot.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - ], - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - updatedAt: dayjs('2023-02-14T11:57:18.740Z'), - views: 110, - author: '์ด์ •์šฐ', - tags: [], - files: [], - }, - { - id: 3, - imagesUrl: ['https://picsum.photos/200/300'], - contents: [ - { - id: 1, - lang: 'ko', - title: '23๋…„๋„ ์ธํฌํŒ€ ์‹ ๊ทœ ๋ถ€์› ๋ชจ์ง‘', - body: '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - { - id: 2, - lang: 'en', - title: "We're recruiting new members for the Info Team in 2023", - body: 'The Info Team is recruiting new members for 2023. Please apply a lot.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - ], - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - updatedAt: dayjs('2023-02-14T11:57:18.740Z'), - views: 110, - author: '์ด์ •์šฐ', - tags: [], - files: [], - }, - { - id: 4, - imagesUrl: ['https://picsum.photos/200/300'], - contents: [ - { - id: 1, - lang: 'ko', - title: '23๋…„๋„ ์ธํฌํŒ€ ์‹ ๊ทœ ๋ถ€์› ๋ชจ์ง‘', - body: '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - { - id: 2, - lang: 'en', - title: "We're recruiting new members for the Info Team in 2023", - body: 'The Info Team is recruiting new members for 2023. Please apply a lot.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - ], - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - updatedAt: dayjs('2023-02-14T11:57:18.740Z'), - views: 110, - author: '์ด์ •์šฐ', - tags: [], - files: [], - }, - { - id: 5, - imagesUrl: ['https://picsum.photos/200/300'], - contents: [ - { - id: 1, - lang: 'ko', - title: '23๋…„๋„ ์ธํฌํŒ€ ์‹ ๊ทœ ๋ถ€์› ๋ชจ์ง‘', - body: '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - { - id: 2, - lang: 'en', - title: "We're recruiting new members for the Info Team in 2023", - body: 'The Info Team is recruiting new members for 2023. Please apply a lot.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - ], - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - updatedAt: dayjs('2023-02-14T11:57:18.740Z'), - views: 110, - author: '์ด์ •์šฐ', - tags: [], - files: [], - }, - { - id: 6, - imagesUrl: ['https://picsum.photos/200/300'], - contents: [ - { - id: 1, - lang: 'ko', - title: '23๋…„๋„ ์ธํฌํŒ€ ์‹ ๊ทœ ๋ถ€์› ๋ชจ์ง‘', - body: '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - { - id: 2, - lang: 'en', - title: "We're recruiting new members for the Info Team in 2023", - body: 'The Info Team is recruiting new members for 2023. Please apply a lot.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - ], - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - updatedAt: dayjs('2023-02-14T11:57:18.740Z'), - views: 110, - author: '์ด์ •์šฐ', - tags: [], - files: [], - }, - { - id: 7, - imagesUrl: ['https://picsum.photos/200/300'], - contents: [ - { - id: 1, - lang: 'ko', - title: '23๋…„๋„ ์ธํฌํŒ€ ์‹ ๊ทœ ๋ถ€์› ๋ชจ์ง‘', - body: '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - { - id: 2, - lang: 'en', - title: "We're recruiting new members for the Info Team in 2023", - body: 'The Info Team is recruiting new members for 2023. Please apply a lot.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - ], - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - updatedAt: dayjs('2023-02-14T11:57:18.740Z'), - views: 110, - author: '์ด์ •์šฐ', - tags: [], - files: [], - }, - { - id: 8, - imagesUrl: ['https://picsum.photos/200/300'], - contents: [ - { - id: 1, - lang: 'ko', - title: '23๋…„๋„ ์ธํฌํŒ€ ์‹ ๊ทœ ๋ถ€์› ๋ชจ์ง‘', - body: '์ธํฌํŒ€์—์„œ๋Š” 23๋…„๋„ ์‹ ๊ทœ ๋ถ€์›์„ ๋ชจ์ง‘ํ•ฉ๋‹ˆ๋‹ค. ๋งŽ์€ ์ง€์› ๋ฐ”๋ž๋‹ˆ๋‹ค.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - { - id: 2, - lang: 'en', - title: "We're recruiting new members for the Info Team in 2023", - body: 'The Info Team is recruiting new members for 2023. Please apply a lot.', - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - deadline: null, - noticeId: 1, - }, - ], - createdAt: dayjs('2023-02-14T11:57:18.740Z'), - updatedAt: dayjs('2023-02-14T11:57:18.740Z'), - views: 110, - author: '์ด์ •์šฐ', - tags: [], - files: [], + isReminded: false, + reactions: [], }, ], height: 300, diff --git a/src/generated/gql.ts b/src/generated/gql.ts index 9407b0c8..a59135ce 100644 --- a/src/generated/gql.ts +++ b/src/generated/gql.ts @@ -13,10 +13,10 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/ * Therefore it is highly recommended to use the babel or swc plugin for production. */ const documents = { - "\n query GetNotices($offset: Int, $limit: Int) {\n notices(offset: $offset, limit: $limit, orderBy: RECENT) {\n list {\n id\n views\n currentDeadline\n createdAt\n updatedAt\n deletedAt\n author\n imagesUrl\n tags {\n id\n name\n }\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n noticeId\n }\n }\n total\n }\n }\n": types.GetNoticesDocument, - "\n mutation CreateNotice($title: String!, $body: String!, $deadline: Date, $tags: [Int!], $images: [String!]) {\n createNotice(title: $title, body: $body, deadline: $deadline, tags: $tags, images: $images) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n noticeId\n }\n }\n }\n": types.CreateNoticeDocument, - "\n mutation AttachInternationalNotice($title: String!, $body: String!, $deadline: Date, $noticeId: Int!, $contentId: Int!, $lang: String!) {\n attachInternationalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId, contentId: $contentId, lang: $lang) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n }\n }\n }\n": types.AttachInternationalNoticeDocument, - "\n mutation CreateAdditionalNotice($title: String, $body: String!, $deadline: Date, $noticeId: Int!) {\n createAdditionalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n noticeId\n }\n }\n }\n": types.CreateAdditionalNoticeDocument, + "\n query GetNotices($offset: Int, $limit: Int) {\n notices(offset: $offset, limit: $limit, orderBy: RECENT) {\n list {\n id\n title\n deadline\n currentDeadline\n langs\n content\n author {\n name\n uuid\n }\n createdAt\n tags\n views\n imageUrls\n documentUrls\n isReminded\n reactions {\n emoji\n count\n isReacted\n }\n }\n total\n }\n }\n": types.GetNoticesDocument, + "\n mutation CreateNotice($title: String!, $body: String!, $deadline: Date, $tags: [Int!], $images: [String!]) {\n createNotice(title: $title, body: $body, deadline: $deadline, tags: $tags, images: $images) {\n id\n additionalContents {\n id\n deadline\n content\n lang\n createdAt\n }\n }\n }\n": types.CreateNoticeDocument, + "\n mutation AttachInternationalNotice($title: String!, $body: String!, $deadline: Date, $noticeId: Int!, $contentId: Int!, $lang: String!) {\n attachInternationalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId, contentId: $contentId, lang: $lang) {\n id\n }\n }\n": types.AttachInternationalNoticeDocument, + "\n mutation CreateAdditionalNotice($title: String, $body: String!, $deadline: Date, $noticeId: Int!) {\n createAdditionalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId) {\n id\n additionalContents {\n id\n deadline\n content\n lang\n createdAt\n }\n }\n }\n": types.CreateAdditionalNoticeDocument, "\n mutation DeleteNotice($id: Int!) {\n deleteNotice(id: $id)\n }\n": types.DeleteNoticeDocument, "\n mutation AddReaction($noticeId: Int!, $emoji: String!) {\n addReaction(noticeId: $noticeId, emoji: $emoji)\n }\n": types.AddReactionDocument, "\n mutation DeleteReaction($noticeId: Int!, $emoji: String!) {\n deleteReaction(noticeId: $noticeId, emoji: $emoji)\n }\n": types.DeleteReactionDocument, @@ -39,19 +39,19 @@ export function gql(source: string): unknown; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function gql(source: "\n query GetNotices($offset: Int, $limit: Int) {\n notices(offset: $offset, limit: $limit, orderBy: RECENT) {\n list {\n id\n views\n currentDeadline\n createdAt\n updatedAt\n deletedAt\n author\n imagesUrl\n tags {\n id\n name\n }\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n noticeId\n }\n }\n total\n }\n }\n"): (typeof documents)["\n query GetNotices($offset: Int, $limit: Int) {\n notices(offset: $offset, limit: $limit, orderBy: RECENT) {\n list {\n id\n views\n currentDeadline\n createdAt\n updatedAt\n deletedAt\n author\n imagesUrl\n tags {\n id\n name\n }\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n noticeId\n }\n }\n total\n }\n }\n"]; +export function gql(source: "\n query GetNotices($offset: Int, $limit: Int) {\n notices(offset: $offset, limit: $limit, orderBy: RECENT) {\n list {\n id\n title\n deadline\n currentDeadline\n langs\n content\n author {\n name\n uuid\n }\n createdAt\n tags\n views\n imageUrls\n documentUrls\n isReminded\n reactions {\n emoji\n count\n isReacted\n }\n }\n total\n }\n }\n"): (typeof documents)["\n query GetNotices($offset: Int, $limit: Int) {\n notices(offset: $offset, limit: $limit, orderBy: RECENT) {\n list {\n id\n title\n deadline\n currentDeadline\n langs\n content\n author {\n name\n uuid\n }\n createdAt\n tags\n views\n imageUrls\n documentUrls\n isReminded\n reactions {\n emoji\n count\n isReacted\n }\n }\n total\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function gql(source: "\n mutation CreateNotice($title: String!, $body: String!, $deadline: Date, $tags: [Int!], $images: [String!]) {\n createNotice(title: $title, body: $body, deadline: $deadline, tags: $tags, images: $images) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n noticeId\n }\n }\n }\n"): (typeof documents)["\n mutation CreateNotice($title: String!, $body: String!, $deadline: Date, $tags: [Int!], $images: [String!]) {\n createNotice(title: $title, body: $body, deadline: $deadline, tags: $tags, images: $images) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n noticeId\n }\n }\n }\n"]; +export function gql(source: "\n mutation CreateNotice($title: String!, $body: String!, $deadline: Date, $tags: [Int!], $images: [String!]) {\n createNotice(title: $title, body: $body, deadline: $deadline, tags: $tags, images: $images) {\n id\n additionalContents {\n id\n deadline\n content\n lang\n createdAt\n }\n }\n }\n"): (typeof documents)["\n mutation CreateNotice($title: String!, $body: String!, $deadline: Date, $tags: [Int!], $images: [String!]) {\n createNotice(title: $title, body: $body, deadline: $deadline, tags: $tags, images: $images) {\n id\n additionalContents {\n id\n deadline\n content\n lang\n createdAt\n }\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function gql(source: "\n mutation AttachInternationalNotice($title: String!, $body: String!, $deadline: Date, $noticeId: Int!, $contentId: Int!, $lang: String!) {\n attachInternationalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId, contentId: $contentId, lang: $lang) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n }\n }\n }\n"): (typeof documents)["\n mutation AttachInternationalNotice($title: String!, $body: String!, $deadline: Date, $noticeId: Int!, $contentId: Int!, $lang: String!) {\n attachInternationalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId, contentId: $contentId, lang: $lang) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n }\n }\n }\n"]; +export function gql(source: "\n mutation AttachInternationalNotice($title: String!, $body: String!, $deadline: Date, $noticeId: Int!, $contentId: Int!, $lang: String!) {\n attachInternationalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId, contentId: $contentId, lang: $lang) {\n id\n }\n }\n"): (typeof documents)["\n mutation AttachInternationalNotice($title: String!, $body: String!, $deadline: Date, $noticeId: Int!, $contentId: Int!, $lang: String!) {\n attachInternationalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId, contentId: $contentId, lang: $lang) {\n id\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function gql(source: "\n mutation CreateAdditionalNotice($title: String, $body: String!, $deadline: Date, $noticeId: Int!) {\n createAdditionalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n noticeId\n }\n }\n }\n"): (typeof documents)["\n mutation CreateAdditionalNotice($title: String, $body: String!, $deadline: Date, $noticeId: Int!) {\n createAdditionalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId) {\n id\n contents {\n id\n lang\n title\n body\n deadline\n createdAt\n noticeId\n }\n }\n }\n"]; +export function gql(source: "\n mutation CreateAdditionalNotice($title: String, $body: String!, $deadline: Date, $noticeId: Int!) {\n createAdditionalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId) {\n id\n additionalContents {\n id\n deadline\n content\n lang\n createdAt\n }\n }\n }\n"): (typeof documents)["\n mutation CreateAdditionalNotice($title: String, $body: String!, $deadline: Date, $noticeId: Int!) {\n createAdditionalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId) {\n id\n additionalContents {\n id\n deadline\n content\n lang\n createdAt\n }\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/src/generated/graphql.ts b/src/generated/graphql.ts index 888df912..743899a1 100644 --- a/src/generated/graphql.ts +++ b/src/generated/graphql.ts @@ -17,31 +17,37 @@ export type Scalars = { Date: { input: any; output: any; } }; +export type Author = { + __typename?: 'Author'; + name: Scalars['String']['output']; + uuid: Scalars['String']['output']; +}; + export type Content = { __typename?: 'Content'; - body: Scalars['String']['output']; + content: Scalars['String']['output']; createdAt: Scalars['Date']['output']; deadline?: Maybe<Scalars['Date']['output']>; id: Scalars['Int']['output']; lang: Scalars['String']['output']; - noticeId: Scalars['Int']['output']; - title: Scalars['String']['output']; }; export type DetailedNotice = { __typename?: 'DetailedNotice'; - author: Scalars['String']['output']; - authorId: Scalars['String']['output']; - contents: Array<Content>; + additionalContents: Array<Content>; + author: Author; + content: Scalars['String']['output']; createdAt: Scalars['Date']['output']; currentDeadline?: Maybe<Scalars['Date']['output']>; - deletedAt?: Maybe<Scalars['Date']['output']>; - files?: Maybe<Array<NoticeFile>>; + deadline?: Maybe<Scalars['Date']['output']>; + documentUrls: Array<Scalars['String']['output']>; id: Scalars['Int']['output']; - imagesUrl: Array<Scalars['String']['output']>; - reminder: Scalars['Boolean']['output']; - tags: Array<Tag>; - updatedAt: Scalars['Date']['output']; + imageUrls: Array<Scalars['String']['output']>; + isReminded: Scalars['Boolean']['output']; + langs: Array<Scalars['String']['output']>; + reactions: Array<Reaction>; + tags: Array<Scalars['String']['output']>; + title: Scalars['String']['output']; views: Scalars['Int']['output']; }; @@ -106,29 +112,22 @@ export type MutationDeleteReactionArgs = { export type Notice = { __typename?: 'Notice'; - author: Scalars['String']['output']; - contents: Array<Content>; + author: Author; + content: Scalars['String']['output']; createdAt: Scalars['Date']['output']; - currentDeadline?: Maybe<Scalars['Date']['output']>; - deletedAt?: Maybe<Scalars['Date']['output']>; - files?: Maybe<Array<NoticeFile>>; + currentDeadline: Scalars['Date']['output']; + deadline: Scalars['Date']['output']; + documentUrls: Array<Scalars['String']['output']>; id: Scalars['Int']['output']; - imagesUrl: Array<Scalars['String']['output']>; - tags: Array<Tag>; - updatedAt: Scalars['Date']['output']; + imageUrls: Array<Scalars['String']['output']>; + isReminded: Scalars['Boolean']['output']; + langs: Array<Scalars['String']['output']>; + reactions: Array<Reaction>; + tags: Array<Scalars['String']['output']>; + title: Scalars['String']['output']; views: Scalars['Int']['output']; }; -export type NoticeFile = { - __typename?: 'NoticeFile'; - createdAt: Scalars['Date']['output']; - name: Scalars['String']['output']; - noticeId: Scalars['Int']['output']; - type: Scalars['String']['output']; - url: Scalars['String']['output']; - uuid: Scalars['String']['output']; -}; - export type Notices = { __typename?: 'Notices'; list: Array<Notice>; @@ -162,10 +161,11 @@ export type QueryNoticesArgs = { tags?: InputMaybe<Array<Scalars['String']['input']>>; }; -export type Tag = { - __typename?: 'Tag'; - id: Scalars['Int']['output']; - name: Scalars['String']['output']; +export type Reaction = { + __typename?: 'Reaction'; + count: Scalars['Int']['output']; + emoji: Scalars['String']['output']; + isReacted: Scalars['Boolean']['output']; }; export type GetNoticesQueryVariables = Exact<{ @@ -174,7 +174,7 @@ export type GetNoticesQueryVariables = Exact<{ }>; -export type GetNoticesQuery = { __typename?: 'Query', notices: { __typename?: 'Notices', total: number, list: Array<{ __typename?: 'Notice', id: number, views: number, currentDeadline?: any | null, createdAt: any, updatedAt: any, deletedAt?: any | null, author: string, imagesUrl: Array<string>, tags: Array<{ __typename?: 'Tag', id: number, name: string }>, contents: Array<{ __typename?: 'Content', id: number, lang: string, title: string, body: string, deadline?: any | null, createdAt: any, noticeId: number }> }> } }; +export type GetNoticesQuery = { __typename?: 'Query', notices: { __typename?: 'Notices', total: number, list: Array<{ __typename?: 'Notice', id: number, title: string, deadline: any, currentDeadline: any, langs: Array<string>, content: string, createdAt: any, tags: Array<string>, views: number, imageUrls: Array<string>, documentUrls: Array<string>, isReminded: boolean, author: { __typename?: 'Author', name: string, uuid: string }, reactions: Array<{ __typename?: 'Reaction', emoji: string, count: number, isReacted: boolean }> }> } }; export type CreateNoticeMutationVariables = Exact<{ title: Scalars['String']['input']; @@ -185,7 +185,7 @@ export type CreateNoticeMutationVariables = Exact<{ }>; -export type CreateNoticeMutation = { __typename?: 'Mutation', createNotice: { __typename?: 'DetailedNotice', id: number, contents: Array<{ __typename?: 'Content', id: number, lang: string, title: string, body: string, deadline?: any | null, createdAt: any, noticeId: number }> } }; +export type CreateNoticeMutation = { __typename?: 'Mutation', createNotice: { __typename?: 'DetailedNotice', id: number, additionalContents: Array<{ __typename?: 'Content', id: number, deadline?: any | null, content: string, lang: string, createdAt: any }> } }; export type AttachInternationalNoticeMutationVariables = Exact<{ title: Scalars['String']['input']; @@ -197,7 +197,7 @@ export type AttachInternationalNoticeMutationVariables = Exact<{ }>; -export type AttachInternationalNoticeMutation = { __typename?: 'Mutation', attachInternationalNotice: { __typename?: 'DetailedNotice', id: number, contents: Array<{ __typename?: 'Content', id: number, lang: string, title: string, body: string, deadline?: any | null, createdAt: any }> } }; +export type AttachInternationalNoticeMutation = { __typename?: 'Mutation', attachInternationalNotice: { __typename?: 'DetailedNotice', id: number } }; export type CreateAdditionalNoticeMutationVariables = Exact<{ title?: InputMaybe<Scalars['String']['input']>; @@ -207,7 +207,7 @@ export type CreateAdditionalNoticeMutationVariables = Exact<{ }>; -export type CreateAdditionalNoticeMutation = { __typename?: 'Mutation', createAdditionalNotice: { __typename?: 'DetailedNotice', id: number, contents: Array<{ __typename?: 'Content', id: number, lang: string, title: string, body: string, deadline?: any | null, createdAt: any, noticeId: number }> } }; +export type CreateAdditionalNoticeMutation = { __typename?: 'Mutation', createAdditionalNotice: { __typename?: 'DetailedNotice', id: number, additionalContents: Array<{ __typename?: 'Content', id: number, deadline?: any | null, content: string, lang: string, createdAt: any }> } }; export type DeleteNoticeMutationVariables = Exact<{ id: Scalars['Int']['input']; @@ -233,10 +233,10 @@ export type DeleteReactionMutationVariables = Exact<{ export type DeleteReactionMutation = { __typename?: 'Mutation', deleteReaction: boolean }; -export const GetNoticesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetNotices"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"offset"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"limit"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"notices"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"offset"},"value":{"kind":"Variable","name":{"kind":"Name","value":"offset"}}},{"kind":"Argument","name":{"kind":"Name","value":"limit"},"value":{"kind":"Variable","name":{"kind":"Name","value":"limit"}}},{"kind":"Argument","name":{"kind":"Name","value":"orderBy"},"value":{"kind":"EnumValue","value":"RECENT"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"list"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"views"}},{"kind":"Field","name":{"kind":"Name","value":"currentDeadline"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}},{"kind":"Field","name":{"kind":"Name","value":"deletedAt"}},{"kind":"Field","name":{"kind":"Name","value":"author"}},{"kind":"Field","name":{"kind":"Name","value":"imagesUrl"}},{"kind":"Field","name":{"kind":"Name","value":"tags"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"contents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"noticeId"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"total"}}]}}]}}]} as unknown as DocumentNode<GetNoticesQuery, GetNoticesQueryVariables>; -export const CreateNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"tags"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"images"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"tags"},"value":{"kind":"Variable","name":{"kind":"Name","value":"tags"}}},{"kind":"Argument","name":{"kind":"Name","value":"images"},"value":{"kind":"Variable","name":{"kind":"Name","value":"images"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"contents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"noticeId"}}]}}]}}]}}]} as unknown as DocumentNode<CreateNoticeMutation, CreateNoticeMutationVariables>; -export const AttachInternationalNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AttachInternationalNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"contentId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"lang"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attachInternationalNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"contentId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"contentId"}}},{"kind":"Argument","name":{"kind":"Name","value":"lang"},"value":{"kind":"Variable","name":{"kind":"Name","value":"lang"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"contents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]}}]}}]} as unknown as DocumentNode<AttachInternationalNoticeMutation, AttachInternationalNoticeMutationVariables>; -export const CreateAdditionalNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateAdditionalNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createAdditionalNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"contents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"body"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"noticeId"}}]}}]}}]}}]} as unknown as DocumentNode<CreateAdditionalNoticeMutation, CreateAdditionalNoticeMutationVariables>; +export const GetNoticesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetNotices"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"offset"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"limit"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"notices"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"offset"},"value":{"kind":"Variable","name":{"kind":"Name","value":"offset"}}},{"kind":"Argument","name":{"kind":"Name","value":"limit"},"value":{"kind":"Variable","name":{"kind":"Name","value":"limit"}}},{"kind":"Argument","name":{"kind":"Name","value":"orderBy"},"value":{"kind":"EnumValue","value":"RECENT"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"list"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"currentDeadline"}},{"kind":"Field","name":{"kind":"Name","value":"langs"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"author"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"uuid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"tags"}},{"kind":"Field","name":{"kind":"Name","value":"views"}},{"kind":"Field","name":{"kind":"Name","value":"imageUrls"}},{"kind":"Field","name":{"kind":"Name","value":"documentUrls"}},{"kind":"Field","name":{"kind":"Name","value":"isReminded"}},{"kind":"Field","name":{"kind":"Name","value":"reactions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"emoji"}},{"kind":"Field","name":{"kind":"Name","value":"count"}},{"kind":"Field","name":{"kind":"Name","value":"isReacted"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"total"}}]}}]}}]} as unknown as DocumentNode<GetNoticesQuery, GetNoticesQueryVariables>; +export const CreateNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"tags"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"images"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"tags"},"value":{"kind":"Variable","name":{"kind":"Name","value":"tags"}}},{"kind":"Argument","name":{"kind":"Name","value":"images"},"value":{"kind":"Variable","name":{"kind":"Name","value":"images"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"additionalContents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]}}]}}]} as unknown as DocumentNode<CreateNoticeMutation, CreateNoticeMutationVariables>; +export const AttachInternationalNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AttachInternationalNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"contentId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"lang"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attachInternationalNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"contentId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"contentId"}}},{"kind":"Argument","name":{"kind":"Name","value":"lang"},"value":{"kind":"Variable","name":{"kind":"Name","value":"lang"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode<AttachInternationalNoticeMutation, AttachInternationalNoticeMutationVariables>; +export const CreateAdditionalNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateAdditionalNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createAdditionalNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"additionalContents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]}}]}}]} as unknown as DocumentNode<CreateAdditionalNoticeMutation, CreateAdditionalNoticeMutationVariables>; export const DeleteNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}]}]}}]} as unknown as DocumentNode<DeleteNoticeMutation, DeleteNoticeMutationVariables>; export const AddReactionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AddReaction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"addReaction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"emoji"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}}}]}]}}]} as unknown as DocumentNode<AddReactionMutation, AddReactionMutationVariables>; export const DeleteReactionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteReaction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteReaction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"emoji"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}}}]}]}}]} as unknown as DocumentNode<DeleteReactionMutation, DeleteReactionMutationVariables>; \ No newline at end of file diff --git a/src/generated/server.ts b/src/generated/server.ts index b4fba62e..981f3526 100644 --- a/src/generated/server.ts +++ b/src/generated/server.ts @@ -18,31 +18,37 @@ export type Scalars = { Date: { input: any; output: any; } }; +export type Author = { + __typename?: 'Author'; + name: Scalars['String']['output']; + uuid: Scalars['String']['output']; +}; + export type Content = { __typename?: 'Content'; - body: Scalars['String']['output']; + content: Scalars['String']['output']; createdAt: Scalars['Date']['output']; deadline?: Maybe<Scalars['Date']['output']>; id: Scalars['Int']['output']; lang: Scalars['String']['output']; - noticeId: Scalars['Int']['output']; - title: Scalars['String']['output']; }; export type DetailedNotice = { __typename?: 'DetailedNotice'; - author: Scalars['String']['output']; - authorId: Scalars['String']['output']; - contents: Array<Content>; + additionalContents: Array<Content>; + author: Author; + content: Scalars['String']['output']; createdAt: Scalars['Date']['output']; currentDeadline?: Maybe<Scalars['Date']['output']>; - deletedAt?: Maybe<Scalars['Date']['output']>; - files?: Maybe<Array<NoticeFile>>; + deadline?: Maybe<Scalars['Date']['output']>; + documentUrls: Array<Scalars['String']['output']>; id: Scalars['Int']['output']; - imagesUrl: Array<Scalars['String']['output']>; - reminder: Scalars['Boolean']['output']; - tags: Array<Tag>; - updatedAt: Scalars['Date']['output']; + imageUrls: Array<Scalars['String']['output']>; + isReminded: Scalars['Boolean']['output']; + langs: Array<Scalars['String']['output']>; + reactions: Array<Reaction>; + tags: Array<Scalars['String']['output']>; + title: Scalars['String']['output']; views: Scalars['Int']['output']; }; @@ -107,29 +113,22 @@ export type MutationDeleteReactionArgs = { export type Notice = { __typename?: 'Notice'; - author: Scalars['String']['output']; - contents: Array<Content>; + author: Author; + content: Scalars['String']['output']; createdAt: Scalars['Date']['output']; - currentDeadline?: Maybe<Scalars['Date']['output']>; - deletedAt?: Maybe<Scalars['Date']['output']>; - files?: Maybe<Array<NoticeFile>>; + currentDeadline: Scalars['Date']['output']; + deadline: Scalars['Date']['output']; + documentUrls: Array<Scalars['String']['output']>; id: Scalars['Int']['output']; - imagesUrl: Array<Scalars['String']['output']>; - tags: Array<Tag>; - updatedAt: Scalars['Date']['output']; + imageUrls: Array<Scalars['String']['output']>; + isReminded: Scalars['Boolean']['output']; + langs: Array<Scalars['String']['output']>; + reactions: Array<Reaction>; + tags: Array<Scalars['String']['output']>; + title: Scalars['String']['output']; views: Scalars['Int']['output']; }; -export type NoticeFile = { - __typename?: 'NoticeFile'; - createdAt: Scalars['Date']['output']; - name: Scalars['String']['output']; - noticeId: Scalars['Int']['output']; - type: Scalars['String']['output']; - url: Scalars['String']['output']; - uuid: Scalars['String']['output']; -}; - export type Notices = { __typename?: 'Notices'; list: Array<Notice>; @@ -163,10 +162,11 @@ export type QueryNoticesArgs = { tags?: InputMaybe<Array<Scalars['String']['input']>>; }; -export type Tag = { - __typename?: 'Tag'; - id: Scalars['Int']['output']; - name: Scalars['String']['output']; +export type Reaction = { + __typename?: 'Reaction'; + count: Scalars['Int']['output']; + emoji: Scalars['String']['output']; + isReacted: Scalars['Boolean']['output']; }; @@ -240,6 +240,7 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs /** Mapping between all available schema types and the resolvers types */ export type ResolversTypes = { + Author: ResolverTypeWrapper<Author>; Boolean: ResolverTypeWrapper<Scalars['Boolean']['output']>; Content: ResolverTypeWrapper<Content>; Date: ResolverTypeWrapper<Scalars['Date']['output']>; @@ -248,16 +249,16 @@ export type ResolversTypes = { MineNotice: MineNotice; Mutation: ResolverTypeWrapper<{}>; Notice: ResolverTypeWrapper<Notice>; - NoticeFile: ResolverTypeWrapper<NoticeFile>; Notices: ResolverTypeWrapper<Notices>; OrderBy: OrderBy; Query: ResolverTypeWrapper<{}>; + Reaction: ResolverTypeWrapper<Reaction>; String: ResolverTypeWrapper<Scalars['String']['output']>; - Tag: ResolverTypeWrapper<Tag>; }; /** Mapping between all available schema types and the resolvers parents */ export type ResolversParentTypes = { + Author: Author; Boolean: Scalars['Boolean']['output']; Content: Content; Date: Scalars['Date']['output']; @@ -265,21 +266,24 @@ export type ResolversParentTypes = { Int: Scalars['Int']['output']; Mutation: {}; Notice: Notice; - NoticeFile: NoticeFile; Notices: Notices; Query: {}; + Reaction: Reaction; String: Scalars['String']['output']; - Tag: Tag; +}; + +export type AuthorResolvers<ContextType = MyContext, ParentType extends ResolversParentTypes['Author'] = ResolversParentTypes['Author']> = { + name?: Resolver<ResolversTypes['String'], ParentType, ContextType>; + uuid?: Resolver<ResolversTypes['String'], ParentType, ContextType>; + __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; export type ContentResolvers<ContextType = MyContext, ParentType extends ResolversParentTypes['Content'] = ResolversParentTypes['Content']> = { - body?: Resolver<ResolversTypes['String'], ParentType, ContextType>; + content?: Resolver<ResolversTypes['String'], ParentType, ContextType>; createdAt?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; deadline?: Resolver<Maybe<ResolversTypes['Date']>, ParentType, ContextType>; id?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; lang?: Resolver<ResolversTypes['String'], ParentType, ContextType>; - noticeId?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; - title?: Resolver<ResolversTypes['String'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; @@ -288,18 +292,20 @@ export interface DateScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes } export type DetailedNoticeResolvers<ContextType = MyContext, ParentType extends ResolversParentTypes['DetailedNotice'] = ResolversParentTypes['DetailedNotice']> = { - author?: Resolver<ResolversTypes['String'], ParentType, ContextType>; - authorId?: Resolver<ResolversTypes['String'], ParentType, ContextType>; - contents?: Resolver<Array<ResolversTypes['Content']>, ParentType, ContextType>; + additionalContents?: Resolver<Array<ResolversTypes['Content']>, ParentType, ContextType>; + author?: Resolver<ResolversTypes['Author'], ParentType, ContextType>; + content?: Resolver<ResolversTypes['String'], ParentType, ContextType>; createdAt?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; currentDeadline?: Resolver<Maybe<ResolversTypes['Date']>, ParentType, ContextType>; - deletedAt?: Resolver<Maybe<ResolversTypes['Date']>, ParentType, ContextType>; - files?: Resolver<Maybe<Array<ResolversTypes['NoticeFile']>>, ParentType, ContextType>; + deadline?: Resolver<Maybe<ResolversTypes['Date']>, ParentType, ContextType>; + documentUrls?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; id?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; - imagesUrl?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; - reminder?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>; - tags?: Resolver<Array<ResolversTypes['Tag']>, ParentType, ContextType>; - updatedAt?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; + imageUrls?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; + isReminded?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>; + langs?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; + reactions?: Resolver<Array<ResolversTypes['Reaction']>, ParentType, ContextType>; + tags?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; + title?: Resolver<ResolversTypes['String'], ParentType, ContextType>; views?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; @@ -314,30 +320,23 @@ export type MutationResolvers<ContextType = MyContext, ParentType extends Resolv }; export type NoticeResolvers<ContextType = MyContext, ParentType extends ResolversParentTypes['Notice'] = ResolversParentTypes['Notice']> = { - author?: Resolver<ResolversTypes['String'], ParentType, ContextType>; - contents?: Resolver<Array<ResolversTypes['Content']>, ParentType, ContextType>; + author?: Resolver<ResolversTypes['Author'], ParentType, ContextType>; + content?: Resolver<ResolversTypes['String'], ParentType, ContextType>; createdAt?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; - currentDeadline?: Resolver<Maybe<ResolversTypes['Date']>, ParentType, ContextType>; - deletedAt?: Resolver<Maybe<ResolversTypes['Date']>, ParentType, ContextType>; - files?: Resolver<Maybe<Array<ResolversTypes['NoticeFile']>>, ParentType, ContextType>; + currentDeadline?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; + deadline?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; + documentUrls?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; id?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; - imagesUrl?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; - tags?: Resolver<Array<ResolversTypes['Tag']>, ParentType, ContextType>; - updatedAt?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; + imageUrls?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; + isReminded?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>; + langs?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; + reactions?: Resolver<Array<ResolversTypes['Reaction']>, ParentType, ContextType>; + tags?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; + title?: Resolver<ResolversTypes['String'], ParentType, ContextType>; views?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; -export type NoticeFileResolvers<ContextType = MyContext, ParentType extends ResolversParentTypes['NoticeFile'] = ResolversParentTypes['NoticeFile']> = { - createdAt?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; - name?: Resolver<ResolversTypes['String'], ParentType, ContextType>; - noticeId?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; - type?: Resolver<ResolversTypes['String'], ParentType, ContextType>; - url?: Resolver<ResolversTypes['String'], ParentType, ContextType>; - uuid?: Resolver<ResolversTypes['String'], ParentType, ContextType>; - __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; -}; - export type NoticesResolvers<ContextType = MyContext, ParentType extends ResolversParentTypes['Notices'] = ResolversParentTypes['Notices']> = { list?: Resolver<Array<ResolversTypes['Notice']>, ParentType, ContextType>; total?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; @@ -349,21 +348,22 @@ export type QueryResolvers<ContextType = MyContext, ParentType extends Resolvers notices?: Resolver<ResolversTypes['Notices'], ParentType, ContextType, Partial<QueryNoticesArgs>>; }; -export type TagResolvers<ContextType = MyContext, ParentType extends ResolversParentTypes['Tag'] = ResolversParentTypes['Tag']> = { - id?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; - name?: Resolver<ResolversTypes['String'], ParentType, ContextType>; +export type ReactionResolvers<ContextType = MyContext, ParentType extends ResolversParentTypes['Reaction'] = ResolversParentTypes['Reaction']> = { + count?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; + emoji?: Resolver<ResolversTypes['String'], ParentType, ContextType>; + isReacted?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>; __isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>; }; export type Resolvers<ContextType = MyContext> = { + Author?: AuthorResolvers<ContextType>; Content?: ContentResolvers<ContextType>; Date?: GraphQLScalarType; DetailedNotice?: DetailedNoticeResolvers<ContextType>; Mutation?: MutationResolvers<ContextType>; Notice?: NoticeResolvers<ContextType>; - NoticeFile?: NoticeFileResolvers<ContextType>; Notices?: NoticesResolvers<ContextType>; Query?: QueryResolvers<ContextType>; - Tag?: TagResolvers<ContextType>; + Reaction?: ReactionResolvers<ContextType>; }; diff --git a/src/mock/dummy-mypage-articles.ts b/src/mock/dummy-mypage-articles.ts index 23444ecd..d566c05a 100644 --- a/src/mock/dummy-mypage-articles.ts +++ b/src/mock/dummy-mypage-articles.ts @@ -24,7 +24,7 @@ const articles1 = [ body: '', deadline: '', id: 0, - imagesUrl: [], + imageUrls: [], tags: [], views: 0, })); @@ -40,7 +40,7 @@ const articles2 = [ body: '', deadline: '', id: 0, - imagesUrl: [], + imageUrls: [], tags: [], views: 0, })); diff --git a/src/utils/getLocaleContents.ts b/src/utils/getLocaleContents.ts deleted file mode 100644 index 7d7310bf..00000000 --- a/src/utils/getLocaleContents.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Content } from '@/api/notice/notice'; - -const getLocaleContents = (contents: Content[], language: string) => { - const localeContents = contents.filter( - (content) => content.lang === language, - ); - - return localeContents.length > 0 ? localeContents : contents; -}; - -export default getLocaleContents; diff --git a/tsconfig.json b/tsconfig.json index 67ae7afe..19e7315d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,7 +29,7 @@ "next-env.d.ts", "**/*.ts", "**/*.tsx", - ".next/types/**/*.ts" + ".next/types/**/*.ts", ], "exclude": ["node_modules"] } diff --git a/yarn.lock b/yarn.lock index 3924f6a0..a6d892c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11249,6 +11249,13 @@ eslint@latest: languageName: node linkType: hard +"ignore-loader@npm:^0.1.2": + version: 0.1.2 + resolution: "ignore-loader@npm:0.1.2" + checksum: 26b5f81b24e59c575d5314e1416c4ae21fb88e65b3c60c90581288ef925fcaa2b39e7f8f96cd449e488c217337d5240fba5a916f9aec073ec04495d7a5716ac4 + languageName: node + linkType: hard + "ignore@npm:^5.2.0, ignore@npm:^5.2.4": version: 5.2.4 resolution: "ignore@npm:5.2.4" @@ -18180,6 +18187,7 @@ typescript@latest: i18next: ^23.5.1 i18next-browser-languagedetector: ^7.1.0 i18next-resources-to-backend: ^1.1.4 + ignore-loader: ^0.1.2 isomorphic-dompurify: ^1.9.0 jsdom: ^22.1.0 lottie-react: ^2.4.0 From 257fb2232e5a3897d7c76a93da40b57cf08325de Mon Sep 17 00:00:00 2001 From: Do-hyun Ko <dohyun682@gmail.com> Date: Wed, 14 Feb 2024 16:13:43 +0900 Subject: [PATCH 3/5] :sparkles: Add Reaction --- src/api/notice/get-notice.ts | 18 +++++ src/api/notice/notice.ts | 68 +++++++++++++------ .../notice/[id]/AdditionalNotices.tsx | 6 +- .../[lng]/(common)/notice/[id]/Reactions.tsx | 56 +++++++++++---- src/app/[lng]/(common)/notice/[id]/page.tsx | 6 +- src/app/api/graphql/notices-api.ts | 11 +-- src/app/api/graphql/route.ts | 4 +- src/app/api/graphql/schema.graphql | 4 +- .../templates/HowAboutThese/HowAboutThese.tsx | 9 ++- .../templates/ResultZabo/ResultImageZabo.tsx | 2 +- .../templates/ResultZabo/ResultTextZabo.tsx | 2 +- src/generated/gql.ts | 8 +-- src/generated/graphql.ts | 18 ++--- src/generated/server.ts | 16 ++--- 14 files changed, 158 insertions(+), 70 deletions(-) create mode 100644 src/api/notice/get-notice.ts diff --git a/src/api/notice/get-notice.ts b/src/api/notice/get-notice.ts new file mode 100644 index 00000000..4605179e --- /dev/null +++ b/src/api/notice/get-notice.ts @@ -0,0 +1,18 @@ +import { cookies } from 'next/headers'; + +import api from '..'; +import { NoticeDetail } from './notice'; + +export const getNotice = async (id: number) => { + return api + .get<NoticeDetail>(`/notice/${id}`, { + headers: { + Authorization: `Bearer ${cookies().get('access_token')?.value}`, + }, + }) + .then(({ data }) => ({ + ...data, + deadline: data.deadline || null, + currentDeadline: data.currentDeadline || null, + })); +}; diff --git a/src/api/notice/notice.ts b/src/api/notice/notice.ts index acbafcc3..a1c6d222 100644 --- a/src/api/notice/notice.ts +++ b/src/api/notice/notice.ts @@ -1,4 +1,5 @@ import dayjs from 'dayjs'; +import { cookies } from 'next/headers'; import { gql } from '@/generated'; @@ -56,7 +57,7 @@ export interface Reaction { export interface Content { id: number; - deadline: Date; + deadline: Date | null; content: string; lang: string; createdAt: Date; @@ -71,23 +72,6 @@ export interface Notices { total: number; } -export const getAllNotices = async ( - params: NoticePaginationParams & NoticeSearchParams = {}, -) => - api.get<Notices>('/notice', { params }).then(({ data }) => ({ - ...data, - list: data.list.map(({ currentDeadline, ...notice }) => ({ - ...notice, - currentDeadline: currentDeadline ?? null, - })), - })); - -export const getNotice = async (id: number) => - api.get<NoticeDetail>(`/notice/${id}`).then(({ data }) => ({ - ...data, - currentDeadline: data.currentDeadline || null, - })); - export const GET_NOTICES = gql(` query GetNotices($offset: Int, $limit: Int) { notices(offset: $offset, limit: $limit, orderBy: RECENT) { @@ -165,12 +149,56 @@ export const DELETE_NOTICE = gql(` export const ADD_REACTION = gql(` mutation AddReaction($noticeId: Int!, $emoji: String!) { - addReaction(noticeId: $noticeId, emoji: $emoji) + addReaction(noticeId: $noticeId, emoji: $emoji) { + id + title + deadline + currentDeadline + langs + content + author { + name + uuid + } + createdAt + tags + views + imageUrls + documentUrls + isReminded + reactions { + emoji + count + isReacted + } + } } `); export const DELETE_REACTION = gql(` mutation DeleteReaction($noticeId: Int!, $emoji: String!) { - deleteReaction(noticeId: $noticeId, emoji: $emoji) + deleteReaction(noticeId: $noticeId, emoji: $emoji) { + id + title + deadline + currentDeadline + langs + content + author { + name + uuid + } + createdAt + tags + views + imageUrls + documentUrls + isReminded + reactions { + emoji + count + isReacted + } + } } `); diff --git a/src/app/[lng]/(common)/notice/[id]/AdditionalNotices.tsx b/src/app/[lng]/(common)/notice/[id]/AdditionalNotices.tsx index 6b7a2cba..f700c740 100644 --- a/src/app/[lng]/(common)/notice/[id]/AdditionalNotices.tsx +++ b/src/app/[lng]/(common)/notice/[id]/AdditionalNotices.tsx @@ -22,9 +22,9 @@ const AdditionalNotices = async ({ const lastDeadline = index > 0 ? additionalContents[index - 1].deadline : notice.deadline; - const deadlineChanged = !dayjs(content.deadline).isSame( - dayjs(lastDeadline), - ); + const deadlineChanged = + content.deadline && + !dayjs(content.deadline).isSame(dayjs(lastDeadline)); return ( <div diff --git a/src/app/[lng]/(common)/notice/[id]/Reactions.tsx b/src/app/[lng]/(common)/notice/[id]/Reactions.tsx index 288086af..99519cf4 100644 --- a/src/app/[lng]/(common)/notice/[id]/Reactions.tsx +++ b/src/app/[lng]/(common)/notice/[id]/Reactions.tsx @@ -1,9 +1,20 @@ 'use client'; +import { FetchResult } from '@apollo/client'; +import { useState } from 'react'; import { toast } from 'react-toastify'; -import { ADD_REACTION, Notice, Reaction } from '@/api/notice/notice'; +import { + ADD_REACTION, + DELETE_REACTION, + Notice, + Reaction, +} from '@/api/notice/notice'; import Button from '@/app/components/atoms/Button'; +import { + AddReactionMutation, + DeleteReactionMutation, +} from '@/generated/graphql'; import { apolloClient } from '../../InitClient'; import AnguishedFace from './assets/anguished-face.svg'; @@ -21,7 +32,7 @@ const ReactionButton = ({ return ( <Button variant={isReacted ? 'contained' : 'outlined'} onClick={onClick}> {emoji === '๐Ÿ”ฅ' ? ( - <Fire width={20} /> + <Fire width={20} fill={'#eb6263'} /> ) : emoji === '๐Ÿ˜ญ' ? ( <LoudlyCryingFace width={20} /> ) : emoji === '๐Ÿ˜ง' ? ( @@ -44,18 +55,36 @@ interface ReactionsProps { const preReactionList = ['๐Ÿ”ฅ', '๐Ÿ˜ญ', '๐Ÿ˜ง', '๐Ÿค”', '๐Ÿ˜ฎ']; const Reactions = ({ notice: { id, reactions } }: ReactionsProps) => { - const handleEmojiClick = async (emoji: string) => { + const [currentReactions, setCurrentReactions] = + useState<Reaction[]>(reactions); + + const handleEmojiClick = async (emoji: string, isReacted: boolean) => { try { - const res = await apolloClient.mutate({ - mutation: ADD_REACTION, - variables: { - noticeId: id, - emoji, - }, - }); + const res = isReacted + ? await apolloClient.mutate({ + mutation: DELETE_REACTION, + variables: { + noticeId: id, + emoji, + }, + }) + : await apolloClient.mutate({ + mutation: ADD_REACTION, + variables: { + noticeId: id, + emoji, + }, + }); + + setCurrentReactions( + isReacted + ? // @ts-ignore // ts cannot recognize the type of res.data though there is boolean flag + res.data?.deleteReaction.reactions + : // @ts-ignore + res.data?.addReaction.reactions, + ); } catch (e) { toast.error('๋กœ๊ทธ์ธ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.'); - console.log(e); } }; @@ -63,7 +92,7 @@ const Reactions = ({ notice: { id, reactions } }: ReactionsProps) => { <div className={'flex gap-2'}> {preReactionList .map((emoji) => { - const reaction = reactions.find( + const reaction = currentReactions.find( (reaction) => reaction.emoji === emoji, ); @@ -76,8 +105,9 @@ const Reactions = ({ notice: { id, reactions } }: ReactionsProps) => { .map((reaction) => ( <ReactionButton key={reaction.emoji} - onClick={() => handleEmojiClick(reaction.emoji)} + onClick={() => handleEmojiClick(reaction.emoji, reaction.isReacted)} {...reaction} + isReacted={reaction.isReacted} /> ))} </div> diff --git a/src/app/[lng]/(common)/notice/[id]/page.tsx b/src/app/[lng]/(common)/notice/[id]/page.tsx index 68a6dde6..d070881d 100644 --- a/src/app/[lng]/(common)/notice/[id]/page.tsx +++ b/src/app/[lng]/(common)/notice/[id]/page.tsx @@ -1,7 +1,7 @@ import { Metadata, ResolvingMetadata } from 'next'; import { auth } from '@/api/auth/auth'; -import { getNotice } from '@/api/notice/notice'; +import { getNotice } from '@/api/notice/get-notice'; import ImageCarousel from '@/app/components/organisms/ImageCarousel'; import HowAboutThese from '@/app/components/templates/HowAboutThese'; import ZaboShowcase from '@/app/components/templates/ZaboShowcase'; @@ -121,7 +121,9 @@ const DetailedNoticePage = async ({ </> )} - <Reactions notice={notice} /> + <div className={'mt-6 flex justify-center'}> + <Reactions notice={notice} /> + </div> {notice.imageUrls.length > 0 && ( <> diff --git a/src/app/api/graphql/notices-api.ts b/src/app/api/graphql/notices-api.ts index 20ca8f14..c4278fcb 100644 --- a/src/app/api/graphql/notices-api.ts +++ b/src/app/api/graphql/notices-api.ts @@ -15,7 +15,7 @@ export default class NoticesAPI extends RESTDataSource { offset, limit, tags = [], - ...params + ...params // attach auth token if needed }: NoticeSearchParams & NoticePaginationParams = {}) { return this.get<Notices>('notice', { params: { @@ -27,8 +27,10 @@ export default class NoticesAPI extends RESTDataSource { }); } - async getNotice(id: number) { - return this.get<NoticeDetail>(`notice/${id}`); + async getNotice(data: { id: number }, token: string) { + return this.get<NoticeDetail>(`notice/${data.id}`, { + headers: { Authorization: `Bearer ${token}` }, + }); } async createNotice( @@ -102,7 +104,8 @@ export default class NoticesAPI extends RESTDataSource { } async deleteReaction(noticeId: number, emoji: string, token: string) { - return this.delete(`notice/${noticeId}/reaction/${emoji}`, { + return this.delete(`notice/${noticeId}/reaction`, { + body: { emoji }, headers: { Authorization: `Bearer ${token}` }, }); } diff --git a/src/app/api/graphql/route.ts b/src/app/api/graphql/route.ts index a1d6a725..3ed37ce9 100644 --- a/src/app/api/graphql/route.ts +++ b/src/app/api/graphql/route.ts @@ -32,8 +32,8 @@ const resolvers: Resolvers = { search: search ?? undefined, tags: tags ?? undefined, }), - notice: (_, { id }, { dataSources }) => - dataSources.noticesAPI.getNotice(id), + notice: (_, { id }, { dataSources, accessToken }) => + dataSources.noticesAPI.getNotice({ id }, accessToken!), }, Mutation: { createNotice: ( diff --git a/src/app/api/graphql/schema.graphql b/src/app/api/graphql/schema.graphql index cb5d8b83..f20d6f34 100644 --- a/src/app/api/graphql/schema.graphql +++ b/src/app/api/graphql/schema.graphql @@ -98,6 +98,6 @@ type Mutation { noticeId: Int! ): DetailedNotice! deleteNotice(id: Int!): Boolean! - addReaction(noticeId: Int!, emoji: String!): Boolean! - deleteReaction(noticeId: Int!, emoji: String!): Boolean! + addReaction(noticeId: Int!, emoji: String!): DetailedNotice! + deleteReaction(noticeId: Int!, emoji: String!): DetailedNotice! } diff --git a/src/app/components/templates/HowAboutThese/HowAboutThese.tsx b/src/app/components/templates/HowAboutThese/HowAboutThese.tsx index d2c58464..2a8136d4 100644 --- a/src/app/components/templates/HowAboutThese/HowAboutThese.tsx +++ b/src/app/components/templates/HowAboutThese/HowAboutThese.tsx @@ -56,7 +56,14 @@ const HowAboutThese = ({ lng }: PropsWithLng) => { > {notices.map((notice) => ( <Link key={notice.id} href={`/${lng}/notice/${notice.id}`}> - <Zabo t={t} width={300} {...notice} lng={lng} /> + <Zabo + t={t} + width={300} + {...notice} + lng={lng} + deadline={notice.deadline ?? null} + currentDeadline={notice.currentDeadline ?? null} // I don't know why it infers the type 'deadline' as optional + /> </Link> ))} </Masonry> diff --git a/src/app/components/templates/ResultZabo/ResultImageZabo.tsx b/src/app/components/templates/ResultZabo/ResultImageZabo.tsx index dfe70a74..79a1ed3e 100644 --- a/src/app/components/templates/ResultZabo/ResultImageZabo.tsx +++ b/src/app/components/templates/ResultZabo/ResultImageZabo.tsx @@ -66,7 +66,7 @@ const ResultImageZabo = async ({ {author.name} </HighlightedText> ) : ( - author + author.name )} </p> </div> diff --git a/src/app/components/templates/ResultZabo/ResultTextZabo.tsx b/src/app/components/templates/ResultZabo/ResultTextZabo.tsx index 99999440..0f17cb2b 100644 --- a/src/app/components/templates/ResultZabo/ResultTextZabo.tsx +++ b/src/app/components/templates/ResultZabo/ResultTextZabo.tsx @@ -57,7 +57,7 @@ const ResultTextZabo = async ({ {author.name} </HighlightedText> ) : ( - author + author.name )} </div> {/* organization here (for futer update) */} diff --git a/src/generated/gql.ts b/src/generated/gql.ts index a59135ce..3594a8a7 100644 --- a/src/generated/gql.ts +++ b/src/generated/gql.ts @@ -18,8 +18,8 @@ const documents = { "\n mutation AttachInternationalNotice($title: String!, $body: String!, $deadline: Date, $noticeId: Int!, $contentId: Int!, $lang: String!) {\n attachInternationalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId, contentId: $contentId, lang: $lang) {\n id\n }\n }\n": types.AttachInternationalNoticeDocument, "\n mutation CreateAdditionalNotice($title: String, $body: String!, $deadline: Date, $noticeId: Int!) {\n createAdditionalNotice(title: $title, body: $body, deadline: $deadline, noticeId: $noticeId) {\n id\n additionalContents {\n id\n deadline\n content\n lang\n createdAt\n }\n }\n }\n": types.CreateAdditionalNoticeDocument, "\n mutation DeleteNotice($id: Int!) {\n deleteNotice(id: $id)\n }\n": types.DeleteNoticeDocument, - "\n mutation AddReaction($noticeId: Int!, $emoji: String!) {\n addReaction(noticeId: $noticeId, emoji: $emoji)\n }\n": types.AddReactionDocument, - "\n mutation DeleteReaction($noticeId: Int!, $emoji: String!) {\n deleteReaction(noticeId: $noticeId, emoji: $emoji)\n }\n": types.DeleteReactionDocument, + "\n mutation AddReaction($noticeId: Int!, $emoji: String!) {\n addReaction(noticeId: $noticeId, emoji: $emoji) {\n id\n title\n deadline\n currentDeadline\n langs\n content\n author {\n name\n uuid\n }\n createdAt\n tags\n views\n imageUrls\n documentUrls\n isReminded\n reactions {\n emoji\n count\n isReacted\n }\n }\n }\n": types.AddReactionDocument, + "\n mutation DeleteReaction($noticeId: Int!, $emoji: String!) {\n deleteReaction(noticeId: $noticeId, emoji: $emoji) {\n id\n title\n deadline\n currentDeadline\n langs\n content\n author {\n name\n uuid\n }\n createdAt\n tags\n views\n imageUrls\n documentUrls\n isReminded\n reactions {\n emoji\n count\n isReacted\n }\n }\n }\n": types.DeleteReactionDocument, }; /** @@ -59,11 +59,11 @@ export function gql(source: "\n mutation DeleteNotice($id: Int!) {\n deleteN /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function gql(source: "\n mutation AddReaction($noticeId: Int!, $emoji: String!) {\n addReaction(noticeId: $noticeId, emoji: $emoji)\n }\n"): (typeof documents)["\n mutation AddReaction($noticeId: Int!, $emoji: String!) {\n addReaction(noticeId: $noticeId, emoji: $emoji)\n }\n"]; +export function gql(source: "\n mutation AddReaction($noticeId: Int!, $emoji: String!) {\n addReaction(noticeId: $noticeId, emoji: $emoji) {\n id\n title\n deadline\n currentDeadline\n langs\n content\n author {\n name\n uuid\n }\n createdAt\n tags\n views\n imageUrls\n documentUrls\n isReminded\n reactions {\n emoji\n count\n isReacted\n }\n }\n }\n"): (typeof documents)["\n mutation AddReaction($noticeId: Int!, $emoji: String!) {\n addReaction(noticeId: $noticeId, emoji: $emoji) {\n id\n title\n deadline\n currentDeadline\n langs\n content\n author {\n name\n uuid\n }\n createdAt\n tags\n views\n imageUrls\n documentUrls\n isReminded\n reactions {\n emoji\n count\n isReacted\n }\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function gql(source: "\n mutation DeleteReaction($noticeId: Int!, $emoji: String!) {\n deleteReaction(noticeId: $noticeId, emoji: $emoji)\n }\n"): (typeof documents)["\n mutation DeleteReaction($noticeId: Int!, $emoji: String!) {\n deleteReaction(noticeId: $noticeId, emoji: $emoji)\n }\n"]; +export function gql(source: "\n mutation DeleteReaction($noticeId: Int!, $emoji: String!) {\n deleteReaction(noticeId: $noticeId, emoji: $emoji) {\n id\n title\n deadline\n currentDeadline\n langs\n content\n author {\n name\n uuid\n }\n createdAt\n tags\n views\n imageUrls\n documentUrls\n isReminded\n reactions {\n emoji\n count\n isReacted\n }\n }\n }\n"): (typeof documents)["\n mutation DeleteReaction($noticeId: Int!, $emoji: String!) {\n deleteReaction(noticeId: $noticeId, emoji: $emoji) {\n id\n title\n deadline\n currentDeadline\n langs\n content\n author {\n name\n uuid\n }\n createdAt\n tags\n views\n imageUrls\n documentUrls\n isReminded\n reactions {\n emoji\n count\n isReacted\n }\n }\n }\n"]; export function gql(source: string) { return (documents as any)[source] ?? {}; diff --git a/src/generated/graphql.ts b/src/generated/graphql.ts index 743899a1..34b232f3 100644 --- a/src/generated/graphql.ts +++ b/src/generated/graphql.ts @@ -58,12 +58,12 @@ export enum MineNotice { export type Mutation = { __typename?: 'Mutation'; - addReaction: Scalars['Boolean']['output']; + addReaction: DetailedNotice; attachInternationalNotice: DetailedNotice; createAdditionalNotice: DetailedNotice; createNotice: DetailedNotice; deleteNotice: Scalars['Boolean']['output']; - deleteReaction: Scalars['Boolean']['output']; + deleteReaction: DetailedNotice; }; @@ -115,8 +115,8 @@ export type Notice = { author: Author; content: Scalars['String']['output']; createdAt: Scalars['Date']['output']; - currentDeadline: Scalars['Date']['output']; - deadline: Scalars['Date']['output']; + currentDeadline?: Maybe<Scalars['Date']['output']>; + deadline?: Maybe<Scalars['Date']['output']>; documentUrls: Array<Scalars['String']['output']>; id: Scalars['Int']['output']; imageUrls: Array<Scalars['String']['output']>; @@ -174,7 +174,7 @@ export type GetNoticesQueryVariables = Exact<{ }>; -export type GetNoticesQuery = { __typename?: 'Query', notices: { __typename?: 'Notices', total: number, list: Array<{ __typename?: 'Notice', id: number, title: string, deadline: any, currentDeadline: any, langs: Array<string>, content: string, createdAt: any, tags: Array<string>, views: number, imageUrls: Array<string>, documentUrls: Array<string>, isReminded: boolean, author: { __typename?: 'Author', name: string, uuid: string }, reactions: Array<{ __typename?: 'Reaction', emoji: string, count: number, isReacted: boolean }> }> } }; +export type GetNoticesQuery = { __typename?: 'Query', notices: { __typename?: 'Notices', total: number, list: Array<{ __typename?: 'Notice', id: number, title: string, deadline?: any | null, currentDeadline?: any | null, langs: Array<string>, content: string, createdAt: any, tags: Array<string>, views: number, imageUrls: Array<string>, documentUrls: Array<string>, isReminded: boolean, author: { __typename?: 'Author', name: string, uuid: string }, reactions: Array<{ __typename?: 'Reaction', emoji: string, count: number, isReacted: boolean }> }> } }; export type CreateNoticeMutationVariables = Exact<{ title: Scalars['String']['input']; @@ -222,7 +222,7 @@ export type AddReactionMutationVariables = Exact<{ }>; -export type AddReactionMutation = { __typename?: 'Mutation', addReaction: boolean }; +export type AddReactionMutation = { __typename?: 'Mutation', addReaction: { __typename?: 'DetailedNotice', id: number, title: string, deadline?: any | null, currentDeadline?: any | null, langs: Array<string>, content: string, createdAt: any, tags: Array<string>, views: number, imageUrls: Array<string>, documentUrls: Array<string>, isReminded: boolean, author: { __typename?: 'Author', name: string, uuid: string }, reactions: Array<{ __typename?: 'Reaction', emoji: string, count: number, isReacted: boolean }> } }; export type DeleteReactionMutationVariables = Exact<{ noticeId: Scalars['Int']['input']; @@ -230,7 +230,7 @@ export type DeleteReactionMutationVariables = Exact<{ }>; -export type DeleteReactionMutation = { __typename?: 'Mutation', deleteReaction: boolean }; +export type DeleteReactionMutation = { __typename?: 'Mutation', deleteReaction: { __typename?: 'DetailedNotice', id: number, title: string, deadline?: any | null, currentDeadline?: any | null, langs: Array<string>, content: string, createdAt: any, tags: Array<string>, views: number, imageUrls: Array<string>, documentUrls: Array<string>, isReminded: boolean, author: { __typename?: 'Author', name: string, uuid: string }, reactions: Array<{ __typename?: 'Reaction', emoji: string, count: number, isReacted: boolean }> } }; export const GetNoticesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetNotices"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"offset"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"limit"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"notices"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"offset"},"value":{"kind":"Variable","name":{"kind":"Name","value":"offset"}}},{"kind":"Argument","name":{"kind":"Name","value":"limit"},"value":{"kind":"Variable","name":{"kind":"Name","value":"limit"}}},{"kind":"Argument","name":{"kind":"Name","value":"orderBy"},"value":{"kind":"EnumValue","value":"RECENT"}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"list"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"currentDeadline"}},{"kind":"Field","name":{"kind":"Name","value":"langs"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"author"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"uuid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"tags"}},{"kind":"Field","name":{"kind":"Name","value":"views"}},{"kind":"Field","name":{"kind":"Name","value":"imageUrls"}},{"kind":"Field","name":{"kind":"Name","value":"documentUrls"}},{"kind":"Field","name":{"kind":"Name","value":"isReminded"}},{"kind":"Field","name":{"kind":"Name","value":"reactions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"emoji"}},{"kind":"Field","name":{"kind":"Name","value":"count"}},{"kind":"Field","name":{"kind":"Name","value":"isReacted"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"total"}}]}}]}}]} as unknown as DocumentNode<GetNoticesQuery, GetNoticesQueryVariables>; @@ -238,5 +238,5 @@ export const CreateNoticeDocument = {"kind":"Document","definitions":[{"kind":"O export const AttachInternationalNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AttachInternationalNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"contentId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"lang"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"attachInternationalNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"contentId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"contentId"}}},{"kind":"Argument","name":{"kind":"Name","value":"lang"},"value":{"kind":"Variable","name":{"kind":"Name","value":"lang"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode<AttachInternationalNoticeMutation, AttachInternationalNoticeMutationVariables>; export const CreateAdditionalNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateAdditionalNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"title"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"body"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Date"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createAdditionalNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"title"},"value":{"kind":"Variable","name":{"kind":"Name","value":"title"}}},{"kind":"Argument","name":{"kind":"Name","value":"body"},"value":{"kind":"Variable","name":{"kind":"Name","value":"body"}}},{"kind":"Argument","name":{"kind":"Name","value":"deadline"},"value":{"kind":"Variable","name":{"kind":"Name","value":"deadline"}}},{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"additionalContents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"lang"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}}]}}]}}]} as unknown as DocumentNode<CreateAdditionalNoticeMutation, CreateAdditionalNoticeMutationVariables>; export const DeleteNoticeDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteNotice"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteNotice"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}]}]}}]} as unknown as DocumentNode<DeleteNoticeMutation, DeleteNoticeMutationVariables>; -export const AddReactionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AddReaction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"addReaction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"emoji"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}}}]}]}}]} as unknown as DocumentNode<AddReactionMutation, AddReactionMutationVariables>; -export const DeleteReactionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteReaction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteReaction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"emoji"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}}}]}]}}]} as unknown as DocumentNode<DeleteReactionMutation, DeleteReactionMutationVariables>; \ No newline at end of file +export const AddReactionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AddReaction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"addReaction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"emoji"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"currentDeadline"}},{"kind":"Field","name":{"kind":"Name","value":"langs"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"author"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"uuid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"tags"}},{"kind":"Field","name":{"kind":"Name","value":"views"}},{"kind":"Field","name":{"kind":"Name","value":"imageUrls"}},{"kind":"Field","name":{"kind":"Name","value":"documentUrls"}},{"kind":"Field","name":{"kind":"Name","value":"isReminded"}},{"kind":"Field","name":{"kind":"Name","value":"reactions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"emoji"}},{"kind":"Field","name":{"kind":"Name","value":"count"}},{"kind":"Field","name":{"kind":"Name","value":"isReacted"}}]}}]}}]}}]} as unknown as DocumentNode<AddReactionMutation, AddReactionMutationVariables>; +export const DeleteReactionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteReaction"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteReaction"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"noticeId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"noticeId"}}},{"kind":"Argument","name":{"kind":"Name","value":"emoji"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emoji"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"}},{"kind":"Field","name":{"kind":"Name","value":"currentDeadline"}},{"kind":"Field","name":{"kind":"Name","value":"langs"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"author"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"uuid"}}]}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"tags"}},{"kind":"Field","name":{"kind":"Name","value":"views"}},{"kind":"Field","name":{"kind":"Name","value":"imageUrls"}},{"kind":"Field","name":{"kind":"Name","value":"documentUrls"}},{"kind":"Field","name":{"kind":"Name","value":"isReminded"}},{"kind":"Field","name":{"kind":"Name","value":"reactions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"emoji"}},{"kind":"Field","name":{"kind":"Name","value":"count"}},{"kind":"Field","name":{"kind":"Name","value":"isReacted"}}]}}]}}]}}]} as unknown as DocumentNode<DeleteReactionMutation, DeleteReactionMutationVariables>; \ No newline at end of file diff --git a/src/generated/server.ts b/src/generated/server.ts index 981f3526..911a1d3d 100644 --- a/src/generated/server.ts +++ b/src/generated/server.ts @@ -59,12 +59,12 @@ export enum MineNotice { export type Mutation = { __typename?: 'Mutation'; - addReaction: Scalars['Boolean']['output']; + addReaction: DetailedNotice; attachInternationalNotice: DetailedNotice; createAdditionalNotice: DetailedNotice; createNotice: DetailedNotice; deleteNotice: Scalars['Boolean']['output']; - deleteReaction: Scalars['Boolean']['output']; + deleteReaction: DetailedNotice; }; @@ -116,8 +116,8 @@ export type Notice = { author: Author; content: Scalars['String']['output']; createdAt: Scalars['Date']['output']; - currentDeadline: Scalars['Date']['output']; - deadline: Scalars['Date']['output']; + currentDeadline?: Maybe<Scalars['Date']['output']>; + deadline?: Maybe<Scalars['Date']['output']>; documentUrls: Array<Scalars['String']['output']>; id: Scalars['Int']['output']; imageUrls: Array<Scalars['String']['output']>; @@ -311,20 +311,20 @@ export type DetailedNoticeResolvers<ContextType = MyContext, ParentType extends }; export type MutationResolvers<ContextType = MyContext, ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation']> = { - addReaction?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationAddReactionArgs, 'emoji' | 'noticeId'>>; + addReaction?: Resolver<ResolversTypes['DetailedNotice'], ParentType, ContextType, RequireFields<MutationAddReactionArgs, 'emoji' | 'noticeId'>>; attachInternationalNotice?: Resolver<ResolversTypes['DetailedNotice'], ParentType, ContextType, RequireFields<MutationAttachInternationalNoticeArgs, 'body' | 'contentId' | 'lang' | 'noticeId' | 'title'>>; createAdditionalNotice?: Resolver<ResolversTypes['DetailedNotice'], ParentType, ContextType, RequireFields<MutationCreateAdditionalNoticeArgs, 'body' | 'noticeId'>>; createNotice?: Resolver<ResolversTypes['DetailedNotice'], ParentType, ContextType, RequireFields<MutationCreateNoticeArgs, 'body' | 'title'>>; deleteNotice?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationDeleteNoticeArgs, 'id'>>; - deleteReaction?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType, RequireFields<MutationDeleteReactionArgs, 'emoji' | 'noticeId'>>; + deleteReaction?: Resolver<ResolversTypes['DetailedNotice'], ParentType, ContextType, RequireFields<MutationDeleteReactionArgs, 'emoji' | 'noticeId'>>; }; export type NoticeResolvers<ContextType = MyContext, ParentType extends ResolversParentTypes['Notice'] = ResolversParentTypes['Notice']> = { author?: Resolver<ResolversTypes['Author'], ParentType, ContextType>; content?: Resolver<ResolversTypes['String'], ParentType, ContextType>; createdAt?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; - currentDeadline?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; - deadline?: Resolver<ResolversTypes['Date'], ParentType, ContextType>; + currentDeadline?: Resolver<Maybe<ResolversTypes['Date']>, ParentType, ContextType>; + deadline?: Resolver<Maybe<ResolversTypes['Date']>, ParentType, ContextType>; documentUrls?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; id?: Resolver<ResolversTypes['Int'], ParentType, ContextType>; imageUrls?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>; From 2d5c62f92b423628d9cd17f59812602c0dafaf3a Mon Sep 17 00:00:00 2001 From: Do-hyun Ko <dohyun682@gmail.com> Date: Wed, 14 Feb 2024 17:11:18 +0900 Subject: [PATCH 4/5] :recycle: Reflect code review feedbacks --- .pnp.cjs | 11 --- ...loader-npm-0.1.2-317e1d3ef1-26b5f81b24.zip | Bin 1929 -> 0 bytes package.json | 1 - .../[lng]/(common)/notice/[id]/Reactions.tsx | 80 +++++++++--------- yarn.lock | 8 -- 5 files changed, 42 insertions(+), 58 deletions(-) delete mode 100644 .yarn/cache/ignore-loader-npm-0.1.2-317e1d3ef1-26b5f81b24.zip diff --git a/.pnp.cjs b/.pnp.cjs index 5d0b02fe..1026578e 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -75,7 +75,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["i18next", "npm:23.7.6"],\ ["i18next-browser-languagedetector", "npm:7.2.0"],\ ["i18next-resources-to-backend", "npm:1.2.0"],\ - ["ignore-loader", "npm:0.1.2"],\ ["isomorphic-dompurify", "npm:1.9.0"],\ ["jsdom", "virtual:83b023ebdab1314ff947ce99f7ade4167acbe4884bade3517f8af451f59f14135954817a677debeda585604140e91ee5221d2475b34f0fef082a5f253dd488c2#npm:22.1.0"],\ ["lottie-react", "virtual:87f60e1993a720750ca249cfb3b3cb49c78ef522f4777e0afa244d187678197cd7cf40543d5c4fff4efaea92efc9c1f391189683c0c2d8c070b9a281636b19a1#npm:2.4.0"],\ @@ -15315,15 +15314,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ - ["ignore-loader", [\ - ["npm:0.1.2", {\ - "packageLocation": "./.yarn/cache/ignore-loader-npm-0.1.2-317e1d3ef1-26b5f81b24.zip/node_modules/ignore-loader/",\ - "packageDependencies": [\ - ["ignore-loader", "npm:0.1.2"]\ - ],\ - "linkType": "HARD"\ - }]\ - ]],\ ["image-size", [\ ["npm:1.0.2", {\ "packageLocation": "./.yarn/cache/image-size-npm-1.0.2-ed5424d843-01745fdb47.zip/node_modules/image-size/",\ @@ -23595,7 +23585,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["i18next", "npm:23.7.6"],\ ["i18next-browser-languagedetector", "npm:7.2.0"],\ ["i18next-resources-to-backend", "npm:1.2.0"],\ - ["ignore-loader", "npm:0.1.2"],\ ["isomorphic-dompurify", "npm:1.9.0"],\ ["jsdom", "virtual:83b023ebdab1314ff947ce99f7ade4167acbe4884bade3517f8af451f59f14135954817a677debeda585604140e91ee5221d2475b34f0fef082a5f253dd488c2#npm:22.1.0"],\ ["lottie-react", "virtual:87f60e1993a720750ca249cfb3b3cb49c78ef522f4777e0afa244d187678197cd7cf40543d5c4fff4efaea92efc9c1f391189683c0c2d8c070b9a281636b19a1#npm:2.4.0"],\ diff --git a/.yarn/cache/ignore-loader-npm-0.1.2-317e1d3ef1-26b5f81b24.zip b/.yarn/cache/ignore-loader-npm-0.1.2-317e1d3ef1-26b5f81b24.zip deleted file mode 100644 index 534e7348a126c0c5c20644404edd501f7935a49d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1929 zcmWIWW@Zs#00D<}*EqloD8UP)^YT+t<8$*<N^??+^#gD!l}1;ZnVy$ll&YJPpO}(b z1l7pIzyY>n(ssU?Q-B)o1F<@OjRlFx*@@|?dRfK!d7*t9`3@QIxO}f`ohm7m@Wg$_ z<ttgbw=9ZcmaKZUf3k_rn)i3-=Dla|`NBO*T|!EkJ1+ejbJxxg(*!;z&(37uJsbS( z_AGRDkc?ty>Z<ArSSv4R;k5sf%?-29jwknb&fa_5eQ{H#vF7QpBXJ&yyOw@F?NQan z6_vU!CCK;Z%NWDUw{9Qk<`(Wc@$6sU?I_)|i>-H|c`Ph&N#AXthe8+`7*z0kEXdW- z#n)9YHzl^;G3&5_fa~|-E`Gixt+(#&{=#r``)W0Xqw_4hL{4TrSt3yLJ!+HrTek%> zzkl7wHRImT153Z|dhGD!<#o;|zCh{r$s2Vl=G=T}A$42w`s0Jg9k++SNZhdO>cxt1 zK~dH+zeU@od1$&y?|8_zxhG)SqW3XnHUFRcWSpw&d?%^DdyCH`k)TlRMRA>{erB$? z8ol-2T%Y(@m(<IyFP`nbSaj6BnLqGDqdH?Lul#wL4Ih$E_@>^|shF&ppsB>W@3Uxy z(xxM9U+sRHf4$vha^v62eMhGVxBr}zQFXrlCo3emz+yd?ZO5$=CI$vA76t|-{DI@+ z>Fnwk>>3;7-G9qKVBhcX9*ehL7rzz0SZJP~B(~a9#xhOw_ymbZT1Pa@T>tz&$5OU^ zZHq`{+P>>NttJz8U+X()H0{^r(xP^|L(acB;_d5yvSsEkf64W<apNgJck!mr$~zb$ zw(r)KS(etb%{#$9lDm#S_r4GNY=<uwdcrMkYAPIfpY+(xTy8<5Sg3^GF}cj9`^UYF zBW2z#;5@i}oul20nrgdShGrALe9POwD3_F<7<gZ>`*`G%&1VnX;kZ(reemefd-Iij z%#NJgdSqgQ^zDatCbn<?_Mq?GI)@LIRS6zdd@~wq)C#`Ly?y!mxs86$?>=yv@9?~% zs=P0PCuC0fjDSA>x~7EoM#X05`^DGz%Rlo(+Fx{fT<hAXHT|Caf8R$;x92YxRDIj? z(q>&w*q_wf9->nBe<ywr@4EJDWAPM?n)EXXt8f0iUv{o&_nQ~WQF|j7Fwe1DSC!wo zPm=A%&EJOt#IN7}Bbu)CQ{dx=b&?OBERTHue}?~x{Xzk&m)<PUb+{Ig`Blq!;=!it zKjKt2OiWvPjjh1x^Q9a|-NxzBKNL^vFn-*8Y0)~zOto&U=}g(1d_I?|offZfi&^>M zy*78|gew{f2d$@ym`)URTCQF5DSf8*X5Sk@vnE+g_hN4E%2vKydd@T?J9cH%f||B1 zOLeA8g}NwueQsG5!Thm{e?_>>dC#torn{~`;SUPU-C7eV8L`qvIHE@EMUVaSM{2DL zFU>iv)Yv2b$MuXxtIn*8H_poDgf)3BIsS3F)Jm_eiK{MU)Tqq}nqB_F?V1wfx>R58 z$gEJ6o@<>Prjr%ciI|H;nf@sjlv((Fm)QH337qqk!+jIFewh6^@{a*E%`zYTsvQAL ztC>Koj6cn0=B1=o0L!V^Gqzj}20RWAZI_?8GXE&I2!C+$lGa&Xvzrv|-95LizdzkQ z{mm_-mAnk;cikVhzF%$jcE=;b7L)M85ZA~nkC{7W6~$`=J=!7amRxuAr$K14tnY<$ zAGzfNycwD7nQ<4?K-Yo6TSpLuR&3+e3M#l^;H{%Jkcpxdy%>iW1k2Ls1v$*1C5<Wg z4MHx~VIG4Sie88!47CLot9V=oFH+G>L@#*|CPo3vBRnQT%OQ00&{GA%JU&*u=E2fP VfHx}}ND~_no&kDlIZzt|0|4cZ>%;&6 diff --git a/package.json b/package.json index dd6d0fcf..ca936665 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-storybook": "^0.6.14", "http-proxy-middleware": "^2.0.6", - "ignore-loader": "^0.1.2", "node-fetch": "2", "postcss": "latest", "prettier": "^3.1.0", diff --git a/src/app/[lng]/(common)/notice/[id]/Reactions.tsx b/src/app/[lng]/(common)/notice/[id]/Reactions.tsx index 99519cf4..035111a9 100644 --- a/src/app/[lng]/(common)/notice/[id]/Reactions.tsx +++ b/src/app/[lng]/(common)/notice/[id]/Reactions.tsx @@ -23,6 +23,16 @@ import LoudlyCryingFace from './assets/loudly-crying-face.svg'; import SurprisedFace from './assets/surprised-face-with-open-mouth.svg'; import ThinkingFace from './assets/thinking-face.svg'; +const preReactionList = ['๐Ÿ”ฅ', '๐Ÿ˜ญ', '๐Ÿ˜ง', '๐Ÿค”', '๐Ÿ˜ฎ']; + +const emojis = { + '๐Ÿ”ฅ': <Fire width={20} fill={'#eb6263'} />, + '๐Ÿ˜ญ': <LoudlyCryingFace width={20} />, + '๐Ÿ˜ง': <AnguishedFace width={20} />, + '๐Ÿค”': <ThinkingFace width={20} />, + '๐Ÿ˜ฎ': <SurprisedFace width={20} />, +}; + const ReactionButton = ({ emoji, count, @@ -31,17 +41,7 @@ const ReactionButton = ({ }: Reaction & { onClick: () => void }) => { return ( <Button variant={isReacted ? 'contained' : 'outlined'} onClick={onClick}> - {emoji === '๐Ÿ”ฅ' ? ( - <Fire width={20} fill={'#eb6263'} /> - ) : emoji === '๐Ÿ˜ญ' ? ( - <LoudlyCryingFace width={20} /> - ) : emoji === '๐Ÿ˜ง' ? ( - <AnguishedFace width={20} /> - ) : emoji === '๐Ÿค”' ? ( - <ThinkingFace width={20} /> - ) : emoji === '๐Ÿ˜ฎ' ? ( - <SurprisedFace width={20} /> - ) : null} + {emojis[emoji as keyof typeof emojis] ?? <p>{emoji}</p>} <p>{count}</p> </Button> @@ -52,45 +52,49 @@ interface ReactionsProps { notice: Notice; } -const preReactionList = ['๐Ÿ”ฅ', '๐Ÿ˜ญ', '๐Ÿ˜ง', '๐Ÿค”', '๐Ÿ˜ฎ']; - const Reactions = ({ notice: { id, reactions } }: ReactionsProps) => { const [currentReactions, setCurrentReactions] = useState<Reaction[]>(reactions); - const handleEmojiClick = async (emoji: string, isReacted: boolean) => { + const toggleReaction = async (emoji: string, isReacted: boolean) => { try { - const res = isReacted - ? await apolloClient.mutate({ - mutation: DELETE_REACTION, - variables: { - noticeId: id, - emoji, - }, - }) - : await apolloClient.mutate({ - mutation: ADD_REACTION, - variables: { - noticeId: id, - emoji, - }, - }); - - setCurrentReactions( - isReacted - ? // @ts-ignore // ts cannot recognize the type of res.data though there is boolean flag - res.data?.deleteReaction.reactions - : // @ts-ignore - res.data?.addReaction.reactions, - ); + if (isReacted) { + const res = await apolloClient.mutate({ + mutation: DELETE_REACTION, + variables: { + noticeId: id, + emoji, + }, + }); + + return res.data?.deleteReaction.reactions; + } else { + const res = await apolloClient.mutate({ + mutation: ADD_REACTION, + variables: { + noticeId: id, + emoji, + }, + }); + + return res.data?.addReaction.reactions; + } } catch (e) { toast.error('๋กœ๊ทธ์ธ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.'); } }; + const handleEmojiClick = async (emoji: string, isReacted: boolean) => { + const reactions = await toggleReaction(emoji, isReacted); + + if (reactions) { + setCurrentReactions(reactions); + } + }; + return ( <div className={'flex gap-2'}> - {preReactionList + {Object.keys(emojis) .map((emoji) => { const reaction = currentReactions.find( (reaction) => reaction.emoji === emoji, diff --git a/yarn.lock b/yarn.lock index a6d892c9..3924f6a0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11249,13 +11249,6 @@ eslint@latest: languageName: node linkType: hard -"ignore-loader@npm:^0.1.2": - version: 0.1.2 - resolution: "ignore-loader@npm:0.1.2" - checksum: 26b5f81b24e59c575d5314e1416c4ae21fb88e65b3c60c90581288ef925fcaa2b39e7f8f96cd449e488c217337d5240fba5a916f9aec073ec04495d7a5716ac4 - languageName: node - linkType: hard - "ignore@npm:^5.2.0, ignore@npm:^5.2.4": version: 5.2.4 resolution: "ignore@npm:5.2.4" @@ -18187,7 +18180,6 @@ typescript@latest: i18next: ^23.5.1 i18next-browser-languagedetector: ^7.1.0 i18next-resources-to-backend: ^1.1.4 - ignore-loader: ^0.1.2 isomorphic-dompurify: ^1.9.0 jsdom: ^22.1.0 lottie-react: ^2.4.0 From 2981881cb5bb407760b4423e1f1b185ad30bd6a5 Mon Sep 17 00:00:00 2001 From: Do-hyun Ko <30494557+dohyun-ko@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:15:37 +0900 Subject: [PATCH 5/5] Update src/app/[lng]/(common)/notice/[id]/Reactions.tsx --- src/app/[lng]/(common)/notice/[id]/Reactions.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/[lng]/(common)/notice/[id]/Reactions.tsx b/src/app/[lng]/(common)/notice/[id]/Reactions.tsx index 035111a9..346e0891 100644 --- a/src/app/[lng]/(common)/notice/[id]/Reactions.tsx +++ b/src/app/[lng]/(common)/notice/[id]/Reactions.tsx @@ -23,7 +23,6 @@ import LoudlyCryingFace from './assets/loudly-crying-face.svg'; import SurprisedFace from './assets/surprised-face-with-open-mouth.svg'; import ThinkingFace from './assets/thinking-face.svg'; -const preReactionList = ['๐Ÿ”ฅ', '๐Ÿ˜ญ', '๐Ÿ˜ง', '๐Ÿค”', '๐Ÿ˜ฎ']; const emojis = { '๐Ÿ”ฅ': <Fire width={20} fill={'#eb6263'} />,