diff --git a/apps/portal/src/pages/offers/test/createProfile.tsx b/apps/portal/src/pages/offers/test/createProfile.tsx
index d0360533..618ba886 100644
--- a/apps/portal/src/pages/offers/test/createProfile.tsx
+++ b/apps/portal/src/pages/offers/test/createProfile.tsx
@@ -74,17 +74,18 @@ function Test() {
const handleCreate = () => {
createCommentMutation.mutate({
- message: 'hello',
- profileId: 'cl96stky5002ew32gx2kale2x',
- // UserId: 'cl97dl51k001e7iygd5v5gt58'
+ message: 'wassup bro',
+ profileId: 'cl9efyn9p004ww3u42mjgl1vn',
+ replyingToId: 'cl9el4xj10001w3w21o3p2iny',
+ userId: 'cl9ehvpng0000w3ec2mpx0bdd'
});
};
const handleLink = () => {
addToUserProfileMutation.mutate({
- profileId: 'cl96stky5002ew32gx2kale2x',
+ profileId: 'cl9efyn9p004ww3u42mjgl1vn',
token: 'afca11e436d21bde24543718fa957c6c625335439dc504f24ee35eae7b5ef1ba',
- userId: 'cl97dl51k001e7iygd5v5gt58',
+ userId: 'cl9ehvpng0000w3ec2mpx0bdd',
});
};
@@ -216,6 +217,7 @@ function Test() {
},
);
+ // Console.log(replies.data?.data)
const deleteMutation = trpc.useMutation(['offers.profile.delete']);
const handleDelete = (id: string) => {
@@ -600,7 +602,7 @@ function Test() {
return (
<>
{createdData}
- {JSON.stringify(replies.data)}
+ {JSON.stringify(replies.data?.data)}
diff --git a/apps/portal/src/server/router/offers/offers-comments-router.ts b/apps/portal/src/server/router/offers/offers-comments-router.ts
index cd0b4799..20c79248 100644
--- a/apps/portal/src/server/router/offers/offers-comments-router.ts
+++ b/apps/portal/src/server/router/offers/offers-comments-router.ts
@@ -36,38 +36,57 @@ export const offersCommentsRouter = createRouter()
},
});
- result?.discussion
- .filter((x) => x.replyingToId === null)
- .map((x) => {
- if (x.user == null) {
- x.user = {
- email: '',
- emailVerified: null,
- id: '',
- image: '',
- name: profile?.profileName ?? '',
- };
- }
+ const discussions: OffersDiscussion = {
+ data: result?.discussion
+ .filter((x) => {
+ return x.replyingToId === null
+ })
+ .map((x) => {
+ if (x.user == null) {
+ x.user = {
+ email: '',
+ emailVerified: null,
+ id: '',
+ image: '',
+ name: profile?.profileName ?? '',
+ };
+ }
- x.replies?.map((y) => {
- if (y.user == null) {
- y.user = {
- email: '',
- emailVerified: null,
- id: '',
- image: '',
- name: profile?.profileName ?? '',
- };
- }
- });
- return x;
- });
+ x.replies?.map((y) => {
+ if (y.user == null) {
+ y.user = {
+ email: '',
+ emailVerified: null,
+ id: '',
+ image: '',
+ name: profile?.profileName ?? '',
+ };
+ }
+ });
- const discussions: OffersDiscussion = {
- data: result ? result.discussion : []
- }
+ const replyType: Reply = {
+ createdAt: x.createdAt,
+ id: x.id,
+ message: x.message,
+ replies: x.replies.map((reply) => {
+ return {
+ createdAt: reply.createdAt,
+ id: reply.id,
+ message: reply.message,
+ replies: [],
+ replyingToId: reply.replyingToId,
+ user: reply.user
+ }
+ }),
+ replyingToId: x.replyingToId,
+ user: x.user
+ }
+
+ return replyType
+ }) ?? []
+ }
- return discussions
+ return discussions
},
})
.mutation('create', {
diff --git a/apps/portal/src/types/offers.d.ts b/apps/portal/src/types/offers.d.ts
index 578c8135..ad5bce5f 100644
--- a/apps/portal/src/types/offers.d.ts
+++ b/apps/portal/src/types/offers.d.ts
@@ -138,7 +138,7 @@ export type CreateOfferProfileResponse = {
};
export type OffersDiscussion = {
- data: Array;
+ data: Array;
};
export type OffersAnalysis = {