Autosave local storage and commentThreadcount
This commit is contained in:
Vendored
+1
@@ -31,6 +31,7 @@
|
||||
"!javascript",
|
||||
"!json",
|
||||
"!typescript",
|
||||
"!typescriptreact",
|
||||
"md",
|
||||
"mdx"
|
||||
],
|
||||
|
||||
@@ -630,7 +630,7 @@ export enum CommentableType {
|
||||
|
||||
export type Company = {
|
||||
__typename?: 'Company';
|
||||
_commentCount: Scalars['Int'];
|
||||
_commentThreadCount: Scalars['Int'];
|
||||
accountOwner?: Maybe<User>;
|
||||
accountOwnerId?: Maybe<Scalars['String']>;
|
||||
address: Scalars['String'];
|
||||
@@ -1149,7 +1149,7 @@ export type NullableStringFieldUpdateOperationsInput = {
|
||||
|
||||
export type Person = {
|
||||
__typename?: 'Person';
|
||||
_commentCount: Scalars['Int'];
|
||||
_commentThreadCount: Scalars['Int'];
|
||||
city: Scalars['String'];
|
||||
commentThreads: Array<CommentThread>;
|
||||
comments: Array<Comment>;
|
||||
@@ -1941,7 +1941,7 @@ export type GetCommentThreadQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GetCommentThreadQuery = { __typename?: 'Query', findManyCommentThreads: Array<{ __typename?: 'CommentThread', id: string, createdAt: string, author: { __typename?: 'User', id: string, firstName: string, lastName: string }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName: string, lastName: string, avatarUrl?: string | null } }> | null, commentThreadTargets?: Array<{ __typename?: 'CommentThreadTarget', id: string, commentableId: string, commentableType: CommentableType }> | null }> };
|
||||
export type GetCommentThreadQuery = { __typename?: 'Query', findManyCommentThreads: Array<{ __typename?: 'CommentThread', id: string, createdAt: string, body?: string | null, title?: string | null, author: { __typename?: 'User', id: string, firstName: string, lastName: string }, comments?: Array<{ __typename?: 'Comment', id: string, body: string, createdAt: string, updatedAt: string, author: { __typename?: 'User', id: string, displayName: string, firstName: string, lastName: string, avatarUrl?: string | null } }> | null, commentThreadTargets?: Array<{ __typename?: 'CommentThreadTarget', id: string, commentableId: string, commentableType: CommentableType }> | null }> };
|
||||
|
||||
export type AddCommentThreadTargetOnCommentThreadMutationVariables = Exact<{
|
||||
commentThreadId: Scalars['String'];
|
||||
@@ -1975,14 +1975,14 @@ export type GetCompaniesQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GetCompaniesQuery = { __typename?: 'Query', companies: Array<{ __typename?: 'Company', id: string, domainName: string, name: string, createdAt: string, address: string, employees?: number | null, _commentCount: number, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, firstName: string, lastName: string } | null }> };
|
||||
export type GetCompaniesQuery = { __typename?: 'Query', companies: Array<{ __typename?: 'Company', id: string, domainName: string, name: string, createdAt: string, address: string, employees?: number | null, _commentThreadCount: number, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string, firstName: string, lastName: string } | null }> };
|
||||
|
||||
export type GetCompanyQueryVariables = Exact<{
|
||||
id: Scalars['String'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetCompanyQuery = { __typename?: 'Query', findUniqueCompany: { __typename?: 'Company', id: string, domainName: string, name: string, createdAt: string, address: string, employees?: number | null, _commentCount: number, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string } | null } };
|
||||
export type GetCompanyQuery = { __typename?: 'Query', findUniqueCompany: { __typename?: 'Company', id: string, domainName: string, name: string, createdAt: string, address: string, employees?: number | null, _commentThreadCount: number, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string } | null } };
|
||||
|
||||
export type UpdateCompanyMutationVariables = Exact<{
|
||||
id?: InputMaybe<Scalars['String']>;
|
||||
@@ -2023,7 +2023,7 @@ export type GetPeopleQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GetPeopleQuery = { __typename?: 'Query', people: Array<{ __typename?: 'Person', id: string, phone: string, email: string, city: string, firstName: string, lastName: string, createdAt: string, _commentCount: number, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null }> };
|
||||
export type GetPeopleQuery = { __typename?: 'Query', people: Array<{ __typename?: 'Person', id: string, phone: string, email: string, city: string, firstName: string, lastName: string, createdAt: string, _commentThreadCount: number, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null }> };
|
||||
|
||||
export type UpdatePeopleMutationVariables = Exact<{
|
||||
id?: InputMaybe<Scalars['String']>;
|
||||
@@ -2521,6 +2521,8 @@ export const GetCommentThreadDocument = gql`
|
||||
findManyCommentThreads(where: {id: {equals: $commentThreadId}}) {
|
||||
id
|
||||
createdAt
|
||||
body
|
||||
title
|
||||
author {
|
||||
id
|
||||
firstName
|
||||
@@ -2712,7 +2714,7 @@ export const GetCompaniesDocument = gql`
|
||||
createdAt
|
||||
address
|
||||
employees
|
||||
_commentCount
|
||||
_commentThreadCount
|
||||
accountOwner {
|
||||
id
|
||||
email
|
||||
@@ -2761,7 +2763,7 @@ export const GetCompanyDocument = gql`
|
||||
createdAt
|
||||
address
|
||||
employees
|
||||
_commentCount
|
||||
_commentThreadCount
|
||||
accountOwner {
|
||||
id
|
||||
email
|
||||
@@ -2940,7 +2942,7 @@ export const GetPeopleDocument = gql`
|
||||
firstName
|
||||
lastName
|
||||
createdAt
|
||||
_commentCount
|
||||
_commentThreadCount
|
||||
company {
|
||||
id
|
||||
name
|
||||
|
||||
@@ -65,18 +65,26 @@ const StyledEditableTitleInput = styled.input`
|
||||
|
||||
export function CommentThreadCreateMode({
|
||||
commentableEntityArray,
|
||||
editor,
|
||||
title,
|
||||
handleTitleChange,
|
||||
}: {
|
||||
commentableEntityArray: CommentableEntity[];
|
||||
editor: BlockNoteEditor | null;
|
||||
title: string;
|
||||
handleTitleChange: (newTitle: string) => void;
|
||||
}) {
|
||||
const editor: BlockNoteEditor | null = useBlockNote({
|
||||
theme: 'light',
|
||||
});
|
||||
|
||||
return (
|
||||
<StyledContainer>
|
||||
<StyledTopContainer>
|
||||
<CommentThreadTypeDropdown />
|
||||
<StyledEditableTitleInput placeholder="Note title (optional)" />
|
||||
<StyledEditableTitleInput
|
||||
placeholder="Note title (optional)"
|
||||
value={title}
|
||||
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
|
||||
handleTitleChange(event.target.value)
|
||||
}
|
||||
/>
|
||||
<PropertyBox>
|
||||
<PropertyBoxItem
|
||||
icon={<IconArrowUpRight />}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { BlockNoteEditor } from '@blocknote/core';
|
||||
import React, { useState } from 'react';
|
||||
import { BlockNoteEditor, PartialBlock } from '@blocknote/core';
|
||||
import { BlockNoteView, useBlockNote } from '@blocknote/react';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { PropertyBox } from '@/ui/components/property-box/PropertyBox';
|
||||
@@ -78,11 +80,29 @@ export function CommentThreadEditMode({
|
||||
skip: !commentThreadId,
|
||||
});
|
||||
|
||||
const [editorReady, setEditorReady] = useState(false);
|
||||
|
||||
console.log();
|
||||
|
||||
const editor: BlockNoteEditor | null = useBlockNote({
|
||||
theme: 'light',
|
||||
// initialContent: commentThread.body,
|
||||
theme: useTheme().name === 'light' ? 'light' : 'dark',
|
||||
initialContent: undefined,
|
||||
onEditorContentChange: (editor) => {
|
||||
// Todo: save operation here
|
||||
console.log('save');
|
||||
},
|
||||
onEditorReady: (editor) => {
|
||||
setEditorReady(true);
|
||||
},
|
||||
});
|
||||
|
||||
React.useEffect(() => {
|
||||
if (editorReady && data?.findManyCommentThreads[0]?.body) {
|
||||
const newContent = JSON.parse(data.findManyCommentThreads[0].body);
|
||||
editor?.replaceBlocks(editor.topLevelBlocks, newContent);
|
||||
}
|
||||
}, [data, editor, editorReady]);
|
||||
|
||||
if (typeof data?.findManyCommentThreads[0] === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
@@ -95,7 +115,10 @@ export function CommentThreadEditMode({
|
||||
<StyledContainer>
|
||||
<StyledTopContainer>
|
||||
<CommentThreadTypeDropdown />
|
||||
<StyledEditableTitleInput placeholder="Note title (optional)" />
|
||||
<StyledEditableTitleInput
|
||||
placeholder="Note title (optional)"
|
||||
defaultValue={commentThread.title ?? ''}
|
||||
/>
|
||||
<PropertyBox>
|
||||
<PropertyBoxItem
|
||||
icon={<IconArrowUpRight />}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
import { BlockNoteEditor } from '@blocknote/core';
|
||||
import { useBlockNote } from '@blocknote/react';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
@@ -20,6 +24,8 @@ import { commentableEntityArrayState } from '../states/commentableEntityArraySta
|
||||
import { CommentThreadCreateMode } from './CommentThreadCreateMode';
|
||||
|
||||
export function RightDrawerCreateCommentThread() {
|
||||
const [title, setTitle] = useState('');
|
||||
|
||||
const [commentableEntityArray] = useRecoilState(commentableEntityArrayState);
|
||||
|
||||
const openRightDrawer = useOpenRightDrawer();
|
||||
@@ -29,8 +35,10 @@ export function RightDrawerCreateCommentThread() {
|
||||
|
||||
const currentUser = useRecoilValue(currentUserState);
|
||||
|
||||
function handleNewCommentThread(commentText: string) {
|
||||
if (!isNonEmptyString(commentText)) {
|
||||
const identifier = JSON.stringify(commentableEntityArray);
|
||||
|
||||
function handleNewCommentThread(title: string, body: string) {
|
||||
if (!(isNonEmptyString(title) || isNonEmptyString(body))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,7 +52,7 @@ export function RightDrawerCreateCommentThread() {
|
||||
createCommentThreadWithComment({
|
||||
variables: {
|
||||
authorId: currentUser.id,
|
||||
commentText: commentText,
|
||||
commentText: body,
|
||||
commentThreadId: v4(),
|
||||
createdAt: new Date().toISOString(),
|
||||
commentThreadTargetArray: commentableEntityArray.map(
|
||||
@@ -64,19 +72,52 @@ export function RightDrawerCreateCommentThread() {
|
||||
onCompleted(data) {
|
||||
// TODO : redirect to drawer comment thread with data.createOneCommentThread.id
|
||||
openRightDrawer('comments');
|
||||
localStorage.setItem('editorTitle' + identifier, '');
|
||||
localStorage.setItem('editorBody' + identifier, '');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const initialBody: string | null = localStorage.getItem(
|
||||
'editorBody' + identifier,
|
||||
);
|
||||
|
||||
const editor: BlockNoteEditor | null = useBlockNote({
|
||||
theme: useTheme().name === 'light' ? 'light' : 'dark',
|
||||
initialContent: initialBody ? JSON.parse(initialBody) : undefined,
|
||||
onEditorContentChange: (editor) => {
|
||||
localStorage.setItem(
|
||||
'editorBody' + identifier,
|
||||
JSON.stringify(editor.topLevelBlocks),
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const initialTitle: string =
|
||||
localStorage.getItem('editorTitle' + identifier) ?? '';
|
||||
setTitle(initialTitle);
|
||||
}, [identifier]);
|
||||
|
||||
function onTitleUpdate(newTitle: string) {
|
||||
setTitle(newTitle);
|
||||
localStorage.setItem('editorTitle' + identifier, newTitle);
|
||||
}
|
||||
|
||||
return (
|
||||
<RightDrawerPage>
|
||||
<RightDrawerTopBar
|
||||
title="New note"
|
||||
onClick={() => handleNewCommentThread('text')}
|
||||
onClick={() =>
|
||||
handleNewCommentThread(title, JSON.stringify(editor?.topLevelBlocks))
|
||||
}
|
||||
/>
|
||||
<RightDrawerBody>
|
||||
<CommentThreadCreateMode
|
||||
commentableEntityArray={commentableEntityArray}
|
||||
editor={editor}
|
||||
title={title}
|
||||
handleTitleChange={onTitleUpdate}
|
||||
/>
|
||||
</RightDrawerBody>
|
||||
</RightDrawerPage>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Tooltip } from 'react-tooltip';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { IconNotes, IconPlus } from '@/ui/icons/index';
|
||||
import { useOpenRightDrawer } from '@/ui/layout/right-drawer/hooks/useOpenRightDrawer';
|
||||
import {
|
||||
beautifyExactDate,
|
||||
beautifyPastDateRelativeToNow,
|
||||
@@ -181,7 +182,7 @@ export function Timeline({ entity }: { entity: CommentableEntity }) {
|
||||
},
|
||||
});
|
||||
|
||||
const openRightDrawer = useOpenCommentThreadRightDrawer();
|
||||
const openCommentThreadRightDrawer = useOpenCommentThreadRightDrawer();
|
||||
|
||||
const commentThreads: CommentThreadForDrawer[] =
|
||||
queryResult?.findManyCommentThreads ?? [];
|
||||
@@ -204,6 +205,8 @@ export function Timeline({ entity }: { entity: CommentableEntity }) {
|
||||
);
|
||||
const exactCreatedAt = beautifyExactDate(commentThread.createdAt);
|
||||
|
||||
console.log(JSON.parse(commentThread.body ?? '')[0].content[0].text);
|
||||
|
||||
return (
|
||||
<>
|
||||
<StyledTopActionBar>
|
||||
@@ -242,9 +245,13 @@ export function Timeline({ entity }: { entity: CommentableEntity }) {
|
||||
<StyledVerticalLine></StyledVerticalLine>
|
||||
</StyledVerticalLineContainer>
|
||||
<StyledCardContainer>
|
||||
<StyledCard onClick={() => openRightDrawer(commentThread.id)}>
|
||||
<StyledCard
|
||||
onClick={() => openCommentThreadRightDrawer(commentThread.id)}
|
||||
>
|
||||
<StyledCardTitle>{commentThread.title}</StyledCardTitle>
|
||||
<StyledCardContent>{commentThread.body}</StyledCardContent>
|
||||
<StyledCardContent>
|
||||
{JSON.parse(commentThread.body ?? '')[0].content[0].text}
|
||||
</StyledCardContent>
|
||||
</StyledCard>
|
||||
</StyledCardContainer>
|
||||
</StyledTimelineItemContainer>
|
||||
|
||||
@@ -49,6 +49,8 @@ export const GET_COMMENT_THREAD = gql`
|
||||
findManyCommentThreads(where: { id: { equals: $commentThreadId } }) {
|
||||
id
|
||||
createdAt
|
||||
body
|
||||
title
|
||||
author {
|
||||
id
|
||||
firstName
|
||||
|
||||
@@ -13,7 +13,7 @@ import CompanyChip from './CompanyChip';
|
||||
type OwnProps = {
|
||||
company: Pick<
|
||||
GetCompaniesQuery['companies'][0],
|
||||
'id' | 'name' | 'domainName' | '_commentCount' | 'accountOwner'
|
||||
'id' | 'name' | 'domainName' | '_commentThreadCount' | 'accountOwner'
|
||||
>;
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@ export function CompanyEditableNameChipCell({ company }: OwnProps) {
|
||||
ChipComponent={CompanyChip}
|
||||
rightEndContents={[
|
||||
<CellCommentChip
|
||||
count={company._commentCount ?? 0}
|
||||
count={company._commentThreadCount ?? 0}
|
||||
onClick={handleCommentClick}
|
||||
/>,
|
||||
]}
|
||||
|
||||
@@ -22,7 +22,7 @@ export const GET_COMPANIES = gql`
|
||||
createdAt
|
||||
address
|
||||
employees
|
||||
_commentCount
|
||||
_commentThreadCount
|
||||
accountOwner {
|
||||
id
|
||||
email
|
||||
|
||||
@@ -11,7 +11,7 @@ export const GET_COMPANY = gql`
|
||||
createdAt
|
||||
address
|
||||
employees
|
||||
_commentCount
|
||||
_commentThreadCount
|
||||
accountOwner {
|
||||
id
|
||||
email
|
||||
|
||||
@@ -9,7 +9,7 @@ import { CommentableType, Person } from '~/generated/graphql';
|
||||
import { PersonChip } from './PersonChip';
|
||||
|
||||
type OwnProps = {
|
||||
person: Pick<Person, 'id' | 'firstName' | 'lastName' | '_commentCount'>;
|
||||
person: Pick<Person, 'id' | 'firstName' | 'lastName' | '_commentThreadCount'>;
|
||||
onChange: (firstName: string, lastName: string) => void;
|
||||
};
|
||||
|
||||
@@ -63,7 +63,7 @@ export function EditablePeopleFullName({ person, onChange }: OwnProps) {
|
||||
<PersonChip name={person.firstName + ' ' + person.lastName} />
|
||||
<RightContainer>
|
||||
<CellCommentChip
|
||||
count={person._commentCount ?? 0}
|
||||
count={person._commentThreadCount ?? 0}
|
||||
onClick={handleCommentClick}
|
||||
/>
|
||||
</RightContainer>
|
||||
|
||||
@@ -24,7 +24,7 @@ export const GET_PEOPLE = gql`
|
||||
firstName
|
||||
lastName
|
||||
createdAt
|
||||
_commentCount
|
||||
_commentThreadCount
|
||||
company {
|
||||
id
|
||||
name
|
||||
|
||||
@@ -32,6 +32,7 @@ export const lightTheme = {
|
||||
selectedCardHover: color.blue20,
|
||||
selectedCard: color.blue10,
|
||||
font: fontLight,
|
||||
name: 'light',
|
||||
},
|
||||
};
|
||||
export type ThemeType = typeof lightTheme;
|
||||
@@ -45,6 +46,7 @@ export const darkTheme: ThemeType = {
|
||||
selectedCardHover: color.blue70,
|
||||
selectedCard: color.blue80,
|
||||
font: fontDark,
|
||||
name: 'dark',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ type MockedCompany = Pick<
|
||||
| 'createdAt'
|
||||
| 'address'
|
||||
| 'employees'
|
||||
| '_commentCount'
|
||||
| '_commentThreadCount'
|
||||
> & {
|
||||
accountOwner: Pick<
|
||||
User,
|
||||
@@ -25,7 +25,7 @@ export const mockedCompaniesData: Array<MockedCompany> = [
|
||||
createdAt: '2023-04-26T10:08:54.724515+00:00',
|
||||
address: '17 rue de clignancourt',
|
||||
employees: 12,
|
||||
_commentCount: 1,
|
||||
_commentThreadCount: 1,
|
||||
accountOwner: {
|
||||
email: 'charles@test.com',
|
||||
displayName: 'Charles Test',
|
||||
@@ -43,7 +43,7 @@ export const mockedCompaniesData: Array<MockedCompany> = [
|
||||
createdAt: '2023-04-26T10:12:42.33625+00:00',
|
||||
address: '',
|
||||
employees: 1,
|
||||
_commentCount: 1,
|
||||
_commentThreadCount: 1,
|
||||
accountOwner: null,
|
||||
__typename: 'Company',
|
||||
},
|
||||
@@ -54,7 +54,7 @@ export const mockedCompaniesData: Array<MockedCompany> = [
|
||||
createdAt: '2023-04-26T10:10:32.530184+00:00',
|
||||
address: '',
|
||||
employees: 1,
|
||||
_commentCount: 1,
|
||||
_commentThreadCount: 1,
|
||||
accountOwner: null,
|
||||
__typename: 'Company',
|
||||
},
|
||||
@@ -65,7 +65,7 @@ export const mockedCompaniesData: Array<MockedCompany> = [
|
||||
createdAt: '2023-03-21T06:30:25.39474+00:00',
|
||||
address: '',
|
||||
employees: 10,
|
||||
_commentCount: 0,
|
||||
_commentThreadCount: 0,
|
||||
accountOwner: null,
|
||||
__typename: 'Company',
|
||||
},
|
||||
@@ -76,7 +76,7 @@ export const mockedCompaniesData: Array<MockedCompany> = [
|
||||
createdAt: '2023-04-26T10:13:29.712485+00:00',
|
||||
address: '10 rue de la Paix',
|
||||
employees: 1,
|
||||
_commentCount: 2,
|
||||
_commentThreadCount: 2,
|
||||
accountOwner: null,
|
||||
__typename: 'Company',
|
||||
},
|
||||
@@ -87,7 +87,7 @@ export const mockedCompaniesData: Array<MockedCompany> = [
|
||||
createdAt: '2023-04-26T10:09:25.656555+00:00',
|
||||
address: '',
|
||||
employees: 1,
|
||||
_commentCount: 13,
|
||||
_commentThreadCount: 13,
|
||||
accountOwner: null,
|
||||
__typename: 'Company',
|
||||
},
|
||||
@@ -98,7 +98,7 @@ export const mockedCompaniesData: Array<MockedCompany> = [
|
||||
createdAt: '2023-04-26T10:09:25.656555+00:00',
|
||||
address: '',
|
||||
employees: 1,
|
||||
_commentCount: 1,
|
||||
_commentThreadCount: 1,
|
||||
accountOwner: null,
|
||||
__typename: 'Company',
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@ type MockedPerson = Pick<
|
||||
| '__typename'
|
||||
| 'phone'
|
||||
| 'city'
|
||||
| '_commentCount'
|
||||
| '_commentThreadCount'
|
||||
| 'createdAt'
|
||||
> & {
|
||||
company: Pick<Company, 'id' | 'name' | 'domainName' | '__typename'>;
|
||||
@@ -29,7 +29,7 @@ export const mockedPeopleData: Array<MockedPerson> = [
|
||||
__typename: 'Company',
|
||||
},
|
||||
phone: '06 12 34 56 78',
|
||||
_commentCount: 1,
|
||||
_commentThreadCount: 1,
|
||||
createdAt: '2023-04-20T13:20:09.158312+00:00',
|
||||
|
||||
city: 'Paris',
|
||||
@@ -47,7 +47,7 @@ export const mockedPeopleData: Array<MockedPerson> = [
|
||||
__typename: 'Company',
|
||||
},
|
||||
phone: '06 12 34 56 78',
|
||||
_commentCount: 1,
|
||||
_commentThreadCount: 1,
|
||||
createdAt: '2023-04-20T13:20:09.158312+00:00',
|
||||
|
||||
city: 'Paris',
|
||||
@@ -65,7 +65,7 @@ export const mockedPeopleData: Array<MockedPerson> = [
|
||||
__typename: 'Company',
|
||||
},
|
||||
phone: '06 12 34 56 78',
|
||||
_commentCount: 1,
|
||||
_commentThreadCount: 1,
|
||||
createdAt: '2023-04-20T13:20:09.158312+00:00',
|
||||
|
||||
city: 'Paris',
|
||||
@@ -83,7 +83,7 @@ export const mockedPeopleData: Array<MockedPerson> = [
|
||||
__typename: 'Company',
|
||||
},
|
||||
phone: '06 12 34 56 78',
|
||||
_commentCount: 2,
|
||||
_commentThreadCount: 2,
|
||||
createdAt: '2023-04-20T13:20:09.158312+00:00',
|
||||
|
||||
city: 'Paris',
|
||||
|
||||
@@ -45,19 +45,25 @@ export class CommentThreadResolver {
|
||||
@PrismaSelector({ modelName: 'CommentThread' })
|
||||
prismaSelect: PrismaSelect<'CommentThread'>,
|
||||
): Promise<Partial<CommentThread>> {
|
||||
const newCommentData = args.data.comments?.createMany?.data
|
||||
/*const newCommentData = args.data.comments?.createMany?.data
|
||||
? args.data.comments?.createMany?.data?.map((comment) => ({
|
||||
...comment,
|
||||
...{ workspaceId: workspace.id },
|
||||
}))
|
||||
: [];
|
||||
|
||||
TODO: check/discuss (strange bug)
|
||||
|
||||
*/
|
||||
|
||||
const createData = {
|
||||
...args.data,
|
||||
// comments: { createMany: { data: newCommentData } },
|
||||
workspace: { connect: { id: workspace.id } },
|
||||
};
|
||||
|
||||
const createdCommentThread = await this.commentThreadService.create({
|
||||
data: {
|
||||
...args.data,
|
||||
...{ comments: { createMany: { data: newCommentData } } },
|
||||
...{ workspace: { connect: { id: workspace.id } } },
|
||||
},
|
||||
data: createData,
|
||||
select: prismaSelect.value,
|
||||
});
|
||||
|
||||
|
||||
@@ -63,15 +63,13 @@ export class CompanyRelationsResolver {
|
||||
@ResolveField(() => Int, {
|
||||
nullable: false,
|
||||
})
|
||||
async _commentCount(@Root() company: Company): Promise<number> {
|
||||
return this.commentService.count({
|
||||
async _commentThreadCount(@Root() company: Company): Promise<number> {
|
||||
return this.commentThreadService.count({
|
||||
where: {
|
||||
commentThread: {
|
||||
commentThreadTargets: {
|
||||
some: {
|
||||
commentableId: company.id,
|
||||
commentableType: 'Company',
|
||||
},
|
||||
commentThreadTargets: {
|
||||
some: {
|
||||
commentableId: company.id,
|
||||
commentableType: 'Company',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -63,15 +63,13 @@ export class PersonRelationsResolver {
|
||||
@ResolveField(() => Int, {
|
||||
nullable: false,
|
||||
})
|
||||
async _commentCount(@Root() person: Person): Promise<number> {
|
||||
return this.commentService.count({
|
||||
async _commentThreadCount(@Root() person: Person): Promise<number> {
|
||||
return this.commentThreadService.count({
|
||||
where: {
|
||||
commentThread: {
|
||||
commentThreadTargets: {
|
||||
some: {
|
||||
commentableId: person.id,
|
||||
commentableType: 'Person',
|
||||
},
|
||||
commentThreadTargets: {
|
||||
some: {
|
||||
commentableId: person.id,
|
||||
commentableType: 'Person',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -7,7 +7,7 @@ export const seedComments = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
title: 'Performance update',
|
||||
body: 'In the North American region, we have observed a strong growth rate of 18% in sales. Europe followed suit with a significant 14% increase, while Asia-Pacific sustained its performance with a steady 10% rise. Special kudos to the North American team for the excellent work done in penetrating new markets and establishing stronger footholds in the existing ones.',
|
||||
body: '[{"id":"555df0c3-ab88-4c62-abae-c9b557c37c5b","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[{"type":"text","text":"In the North American region, we have observed a strong growth rate of 18% in sales. Europe followed suit with a significant 14% increase, while Asia-Pacific sustained its performance with a steady 10% rise. Special kudos to the North American team for the excellent work done in penetrating new markets and establishing stronger footholds in the existing ones.","styles":{}}],"children":[]},{"id":"13530934-b3ce-4332-9238-3760aa4acb3e","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[],"children":[]}]',
|
||||
authorId: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
},
|
||||
});
|
||||
@@ -54,7 +54,7 @@ export const seedComments = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
title: 'Buyout Proposal',
|
||||
body: 'We are considering the potential acquisition of [Company], a leading company in [Industry/Specific Technology]. This company has demonstrated remarkable success and pioneering advancements in their field, paralleling our own commitment to progress. By integrating their expertise with our own, we believe that we can amplify our growth, broaden our offerings, and fortify our position at the forefront of technology. This prospective partnership could help to ensure our continued leadership in the industry and allow us to deliver even more innovative solutions for our customers.',
|
||||
body: '[{"id":"333df0c3-ab88-4c62-abae-c9b557c37c5b","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[{"type":"text","text":"We are considering the potential acquisition of [Company], a leading company in [Industry/Specific Technology]. This company has demonstrated remarkable success and pioneering advancements in their field, paralleling our own commitment to progress. By integrating their expertise with our own, we believe that we can amplify our growth, broaden our offerings, and fortify our position at the forefront of technology. This prospective partnership could help to ensure our continued leadership in the industry and allow us to deliver even more innovative solutions for our customers.","styles":{}}],"children":[]},{"id":"13530934-b3ce-4332-9238-3760aa4acb3e","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[],"children":[]}]',
|
||||
authorId: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
},
|
||||
});
|
||||
@@ -89,7 +89,7 @@ export const seedComments = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408',
|
||||
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
|
||||
title: 'Call summary',
|
||||
body: 'Valuation & Due Diligence: The CFO highlighted the financial implications, pointing out that the acquisition will be accretive to earnings. The M&A team has been directed to commence due diligence and work closely with legal counsel to assess all aspects of the acquisition.',
|
||||
body: '[{"id":"555df0c3-ab88-4c62-abae-c9b557c37c5b","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[{"type":"text","text":"Valuation & Due Diligence: The CFO highlighted the financial implications, pointing out that the acquisition will be accretive to earnings. The M&A team has been directed to commence due diligence and work closely with legal counsel to assess all aspects of the acquisition.","styles":{}}],"children":[]},{"id":"13530934-b3ce-4332-9238-3760aa4acb3e","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[],"children":[]}]',
|
||||
authorId: 'twenty-dev-gk256b39-3ec3-4fe3-8997-b76aa0boa408',
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user