Add back pickers on all pages, fix command menu (#2662)
* Add back pickers on all pages, fix command menu * Fix lint
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
_env_?: Record<string, string>;
|
||||
__APOLLO_CLIENT__?: any;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -102,8 +102,6 @@ export const ActivityComments = ({
|
||||
});
|
||||
};
|
||||
|
||||
console.log('asd', { activity, comments });
|
||||
|
||||
return (
|
||||
<>
|
||||
{comments.length > 0 && (
|
||||
|
||||
@ -5,6 +5,9 @@ import { useApolloFactory } from '@/apollo/hooks/useApolloFactory';
|
||||
export const ApolloProvider = ({ children }: React.PropsWithChildren) => {
|
||||
const apolloClient = useApolloFactory();
|
||||
|
||||
// This will attach the right apollo client to Apollo Dev Tools
|
||||
window.__APOLLO_CLIENT__ = apolloClient;
|
||||
|
||||
return (
|
||||
<ApolloProviderBase client={apolloClient}>{children}</ApolloProviderBase>
|
||||
);
|
||||
|
||||
@ -83,6 +83,18 @@ export class ApolloFactory<TCacheShape> implements ApolloManager<TCacheShape> {
|
||||
onErrorCb?.(graphQLErrors);
|
||||
|
||||
for (const graphQLError of graphQLErrors) {
|
||||
if (graphQLError.message === 'Unauthorized') {
|
||||
return fromPromise(
|
||||
renewToken(uri, this.tokenPair)
|
||||
.then((tokens) => {
|
||||
onTokenPairChange?.(tokens);
|
||||
})
|
||||
.catch(() => {
|
||||
onUnauthenticatedError?.();
|
||||
}),
|
||||
).flatMap(() => forward(operation));
|
||||
}
|
||||
|
||||
switch (graphQLError?.extensions?.code) {
|
||||
case 'UNAUTHENTICATED': {
|
||||
return fromPromise(
|
||||
|
||||
@ -2,8 +2,13 @@ import { useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { useOpenActivityRightDrawer } from '@/activities/hooks/useOpenActivityRightDrawer';
|
||||
import { useFindManyObjectRecords } from '@/object-record/hooks/useFindManyObjectRecords';
|
||||
import { Person } from '@/people/types/Person';
|
||||
import { IconNotes } from '@/ui/display/icon';
|
||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
|
||||
import { Avatar } from '@/users/components/Avatar';
|
||||
import { getLogoUrlFromDomainName } from '~/utils';
|
||||
|
||||
import { useCommandMenu } from '../hooks/useCommandMenu';
|
||||
import { commandMenuCommandsState } from '../states/commandMenuCommandsState';
|
||||
@ -36,47 +41,38 @@ export const CommandMenu = () => {
|
||||
[openCommandMenu, setSearch],
|
||||
);
|
||||
|
||||
// const { data: peopleData } = useSearchPeopleQuery({
|
||||
// skip: !isCommandMenuOpened,
|
||||
// variables: {
|
||||
// where: {
|
||||
// OR: [
|
||||
// { firstName: { contains: search, mode: QueryMode.Insensitive } },
|
||||
// { lastName: { contains: search, mode: QueryMode.Insensitive } },
|
||||
// ],
|
||||
// },
|
||||
// limit: 3,
|
||||
// },
|
||||
// });
|
||||
const { objects: people } = useFindManyObjectRecords<Person>({
|
||||
skip: !isCommandMenuOpened,
|
||||
objectNamePlural: 'people',
|
||||
filter: {
|
||||
or: [
|
||||
{ name: { firstName: { like: `%${search}%` } } },
|
||||
{ name: { firstName: { like: `%${search}%` } } },
|
||||
],
|
||||
},
|
||||
limit: 3,
|
||||
});
|
||||
|
||||
// const people = peopleData?.searchResults ?? [];
|
||||
const { objects: companies } = useFindManyObjectRecords<Person>({
|
||||
skip: !isCommandMenuOpened,
|
||||
objectNamePlural: 'companies',
|
||||
filter: {
|
||||
name: { like: `%${search}%` },
|
||||
},
|
||||
limit: 3,
|
||||
});
|
||||
|
||||
// const { data: companyData } = useSearchCompanyQuery({
|
||||
// skip: !isCommandMenuOpened,
|
||||
// variables: {
|
||||
// where: {
|
||||
// OR: [{ name: { contains: search, mode: QueryMode.Insensitive } }],
|
||||
// },
|
||||
// limit: 3,
|
||||
// },
|
||||
// });
|
||||
|
||||
// const companies = companyData?.searchResults ?? [];
|
||||
|
||||
// const { data: activityData } = useSearchActivityQuery({
|
||||
// skip: !isCommandMenuOpened,
|
||||
// variables: {
|
||||
// where: {
|
||||
// OR: [
|
||||
// { title: { contains: search, mode: QueryMode.Insensitive } },
|
||||
// { body: { contains: search, mode: QueryMode.Insensitive } },
|
||||
// ],
|
||||
// },
|
||||
// limit: 3,
|
||||
// },
|
||||
// });
|
||||
|
||||
// const activities = activityData?.searchResults ?? [];
|
||||
const { objects: activities } = useFindManyObjectRecords<Person>({
|
||||
skip: !isCommandMenuOpened,
|
||||
objectNamePlural: 'activities',
|
||||
filter: {
|
||||
or: [
|
||||
{ title: { like: `%${search}%` } },
|
||||
{ body: { like: `%${search}%` } },
|
||||
],
|
||||
},
|
||||
limit: 3,
|
||||
});
|
||||
|
||||
const checkInShortcuts = (cmd: Command, search: string) => {
|
||||
return (cmd.firstHotKey + (cmd.secondHotKey ?? ''))
|
||||
@ -149,12 +145,12 @@ export const CommandMenu = () => {
|
||||
/>
|
||||
))}
|
||||
</CommandGroup>
|
||||
{/* <CommandGroup heading="People">
|
||||
<CommandGroup heading="People">
|
||||
{people.map((person) => (
|
||||
<CommandMenuItem
|
||||
key={person.id}
|
||||
to={`person/${person.id}`}
|
||||
label={person.displayName}
|
||||
to={`object/person/${person.id}`}
|
||||
label={person.name?.firstName + ' ' + person.name?.lastName}
|
||||
Icon={() => (
|
||||
<Avatar
|
||||
type="rounded"
|
||||
@ -171,7 +167,7 @@ export const CommandMenu = () => {
|
||||
<CommandMenuItem
|
||||
key={company.id}
|
||||
label={company.name}
|
||||
to={`companies/${company.id}`}
|
||||
to={`object/company/${company.id}`}
|
||||
Icon={() => (
|
||||
<Avatar
|
||||
colorId={company.id}
|
||||
@ -191,7 +187,7 @@ export const CommandMenu = () => {
|
||||
onClick={() => openActivityRightDrawer(activity.id)}
|
||||
/>
|
||||
))}
|
||||
</CommandGroup> */}
|
||||
</CommandGroup>
|
||||
</StyledList>
|
||||
</StyledDialog>
|
||||
);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { useMutation, useQuery } from '@apollo/client';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
import styled from '@emotion/styled';
|
||||
import { flip, offset, useFloating } from '@floating-ui/react';
|
||||
@ -8,11 +8,14 @@ import { v4 } from 'uuid';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { IconPlus } from '@/ui/display/icon';
|
||||
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||
import { RelationPicker } from '@/ui/input/components/internal/relation-picker/components/RelationPicker';
|
||||
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
||||
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
|
||||
import { DoubleTextInput } from '@/ui/object/field/meta-types/input/components/internal/DoubleTextInput';
|
||||
import { FieldDoubleText } from '@/ui/object/field/types/FieldDoubleText';
|
||||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
||||
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
position: static;
|
||||
@ -65,43 +68,29 @@ export const AddPersonToCompany = ({
|
||||
goBackToPreviousHotkeyScope,
|
||||
} = usePreviousHotkeyScope();
|
||||
|
||||
// TODO: refactor with useObjectMetadataItem V2 with typed hooks
|
||||
const { findManyQuery, updateOneMutation, createOneMutation } =
|
||||
useObjectMetadataItem({
|
||||
objectNameSingular: 'person',
|
||||
});
|
||||
|
||||
const { data: peopleNotInCompany } = useQuery(findManyQuery, {
|
||||
variables: {
|
||||
filter: {
|
||||
companyId: {
|
||||
neq: companyId,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const [updatePerson] = useMutation(updateOneMutation);
|
||||
const [createPerson] = useMutation(createOneMutation);
|
||||
|
||||
const handlePersonSelected = async ({
|
||||
selectedPersonId,
|
||||
companyId,
|
||||
}: {
|
||||
selectedPersonId: string;
|
||||
companyId: string | null;
|
||||
}) => {
|
||||
await updatePerson({
|
||||
variables: {
|
||||
idToUpdate: selectedPersonId,
|
||||
input: {
|
||||
companyId: companyId,
|
||||
const handlePersonSelected =
|
||||
(companyId: string) => async (newPerson: EntityForSelect | null) => {
|
||||
if (!newPerson) return;
|
||||
await updatePerson({
|
||||
variables: {
|
||||
idToUpdate: newPerson.id,
|
||||
input: {
|
||||
companyId: companyId,
|
||||
},
|
||||
},
|
||||
},
|
||||
refetchQueries: [getOperationName(findManyQuery) ?? ''],
|
||||
});
|
||||
handleClosePicker();
|
||||
};
|
||||
refetchQueries: [getOperationName(findManyQuery) ?? ''],
|
||||
});
|
||||
|
||||
handleClosePicker();
|
||||
};
|
||||
|
||||
const handleClosePicker = () => {
|
||||
if (isDropdownOpen) {
|
||||
@ -111,21 +100,12 @@ export const AddPersonToCompany = ({
|
||||
};
|
||||
|
||||
const handleOpenPicker = () => {
|
||||
// TODO: TEMPORARY - example to implement when the picker is back
|
||||
handleCreatePerson({
|
||||
firstValue: 'John',
|
||||
secondValue: 'Doe',
|
||||
});
|
||||
// handlePersonSelected({
|
||||
// companyId,
|
||||
// selectedPersonId: peopleNotInCompany.people.edges[0].node.id,
|
||||
// });
|
||||
// if (!isDropdownOpen) {
|
||||
// setIsDropdownOpen(true);
|
||||
// setHotkeyScopeAndMemorizePreviousScope(
|
||||
// RelationPickerHotkeyScope.RelationPicker,
|
||||
// );
|
||||
// }
|
||||
if (!isDropdownOpen) {
|
||||
setIsDropdownOpen(true);
|
||||
setHotkeyScopeAndMemorizePreviousScope(
|
||||
RelationPickerHotkeyScope.RelationPicker,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreatePerson = async ({
|
||||
@ -178,14 +158,23 @@ export const AddPersonToCompany = ({
|
||||
/>
|
||||
</StyledInputContainer>
|
||||
) : (
|
||||
<>todo</>
|
||||
// <PeoplePicker
|
||||
// personId={''}
|
||||
// onSubmit={handlePersonSelected(companyId)}
|
||||
// onCancel={handleClosePicker}
|
||||
// onCreate={() => setIsCreationDropdownOpen(true)}
|
||||
// excludePersonIds={peopleIds}
|
||||
// />
|
||||
<RelationPicker
|
||||
recordId={''}
|
||||
onSubmit={handlePersonSelected(companyId)}
|
||||
onCancel={handleClosePicker}
|
||||
excludeRecordIds={peopleIds ?? []}
|
||||
fieldDefinition={{
|
||||
label: 'Person',
|
||||
iconName: 'IconUser',
|
||||
fieldMetadataId: '',
|
||||
type: FieldMetadataType.Relation,
|
||||
metadata: {
|
||||
relationObjectMetadataNameSingular: 'person',
|
||||
relationObjectMetadataNamePlural: 'people',
|
||||
fieldName: 'person',
|
||||
},
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@ -18,7 +18,7 @@ export const CompanyChip = ({
|
||||
}: CompanyChipProps) => (
|
||||
<EntityChip
|
||||
entityId={id}
|
||||
linkToEntity={`/objects/companies/${id}`}
|
||||
linkToEntity={`/object/company/${id}`}
|
||||
name={name}
|
||||
avatarType="squared"
|
||||
avatarUrl={avatarUrl}
|
||||
|
||||
@ -17,7 +17,7 @@ const StyledContainer = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: ${({ theme }) => theme.spacing(2)};
|
||||
margin-bottom: ${({ theme }) => theme.spacing(2)};
|
||||
margin-bottom: ${({ theme }) => theme.spacing(6)};
|
||||
`;
|
||||
|
||||
const StyledTitleContainer = styled.div`
|
||||
|
||||
@ -9,8 +9,8 @@ import { PaginatedObjectTypeResults } from '@/object-record/types/PaginatedObjec
|
||||
import { filterAvailableTableColumns } from '@/object-record/utils/filterAvailableTableColumns';
|
||||
import { Opportunity } from '@/pipeline/types/Opportunity';
|
||||
import { PipelineStep } from '@/pipeline/types/PipelineStep';
|
||||
import { turnFiltersIntoWhereClauseV2 } from '@/ui/object/object-filter-dropdown/utils/turnFiltersIntoWhereClauseV2';
|
||||
import { turnSortsIntoOrderByV2 } from '@/ui/object/object-sort-dropdown/utils/turnSortsIntoOrderByV2';
|
||||
import { turnFiltersIntoWhereClause } from '@/ui/object/object-filter-dropdown/utils/turnFiltersIntoWhereClause';
|
||||
import { turnSortsIntoOrderBy } from '@/ui/object/object-sort-dropdown/utils/turnSortsIntoOrderBy';
|
||||
import { useBoardActionBarEntries } from '@/ui/object/record-board/hooks/useBoardActionBarEntries';
|
||||
import { useBoardContext } from '@/ui/object/record-board/hooks/useBoardContext';
|
||||
import { useBoardContextMenuEntries } from '@/ui/object/record-board/hooks/useBoardContextMenuEntries';
|
||||
@ -88,12 +88,12 @@ export const HooksCompanyBoardEffect = () => {
|
||||
),
|
||||
});
|
||||
|
||||
const filter = turnFiltersIntoWhereClauseV2(
|
||||
const filter = turnFiltersIntoWhereClause(
|
||||
mapViewFiltersToFilters(currentViewFilters),
|
||||
objectMetadataItem?.fields ?? [],
|
||||
);
|
||||
|
||||
const orderBy = turnSortsIntoOrderByV2(
|
||||
const orderBy = turnSortsIntoOrderBy(
|
||||
mapViewSortsToSorts(currentViewSorts),
|
||||
objectMetadataItem?.fields ?? [],
|
||||
);
|
||||
|
||||
@ -1,6 +1,12 @@
|
||||
import { useCallback, useContext, useState } from 'react';
|
||||
import { useQuery } from '@apollo/client';
|
||||
|
||||
import { useCreateOpportunity } from '@/companies/hooks/useCreateOpportunity';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { useRelationPicker } from '@/ui/input/components/internal/relation-picker/hooks/useRelationPicker';
|
||||
import { SingleEntitySelect } from '@/ui/input/relation-picker/components/SingleEntitySelect';
|
||||
import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picker/states/relationPickerSearchFilterScopedState';
|
||||
import { RelationPickerHotkeyScope } from '@/ui/input/relation-picker/types/RelationPickerHotkeyScope';
|
||||
import { NewButton } from '@/ui/object/record-board/components/NewButton';
|
||||
@ -8,13 +14,14 @@ import { BoardColumnContext } from '@/ui/object/record-board/contexts/BoardColum
|
||||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
||||
|
||||
export const NewCompanyProgressButton = () => {
|
||||
export const NewOpportunityButton = () => {
|
||||
const [isCreatingCard, setIsCreatingCard] = useState(false);
|
||||
const column = useContext(BoardColumnContext);
|
||||
|
||||
const pipelineStepId = column?.columnDefinition.id || '';
|
||||
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
const { createOpportunity } = useCreateOpportunity();
|
||||
|
||||
const {
|
||||
goBackToPreviousHotkeyScope,
|
||||
@ -33,7 +40,7 @@ export const NewCompanyProgressButton = () => {
|
||||
throw new Error('Pipeline stage id is not defined');
|
||||
}
|
||||
|
||||
//createCompanyProgress(company.id, pipelineStepId);
|
||||
createOpportunity(company.id, pipelineStepId);
|
||||
};
|
||||
|
||||
const handleNewClick = useCallback(() => {
|
||||
@ -52,23 +59,38 @@ export const NewCompanyProgressButton = () => {
|
||||
relationPickerSearchFilterScopedState,
|
||||
);
|
||||
|
||||
// const companies = useFilteredSearchCompanyQuery({
|
||||
// searchFilter: relationPickerSearchFilter,
|
||||
// });
|
||||
const { findManyQuery } = useObjectMetadataItem({
|
||||
objectNameSingular: 'company',
|
||||
});
|
||||
const useFindManyQuery = (options: any) => useQuery(findManyQuery, options);
|
||||
const { identifiersMapper, searchQuery } = useRelationPicker();
|
||||
|
||||
const filteredSearchEntityResults = useFilteredSearchEntityQuery({
|
||||
queryHook: useFindManyQuery,
|
||||
filters: [
|
||||
{
|
||||
fieldNames: searchQuery?.computeFilterFields?.('company') ?? [],
|
||||
filter: relationPickerSearchFilter,
|
||||
},
|
||||
],
|
||||
orderByField: 'createdAt',
|
||||
selectedIds: [],
|
||||
mappingFunction: (record: any) => identifiersMapper?.(record, 'company'),
|
||||
objectNamePlural: 'companies',
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
{isCreatingCard ? (
|
||||
<>TODO</>
|
||||
<SingleEntitySelect
|
||||
disableBackgroundBlur
|
||||
entitiesToSelect={filteredSearchEntityResults.entitiesToSelect}
|
||||
loading={filteredSearchEntityResults.loading}
|
||||
onCancel={handleCancel}
|
||||
onEntitySelected={handleEntitySelect}
|
||||
selectedEntity={filteredSearchEntityResults.selectedEntities[0]}
|
||||
/>
|
||||
) : (
|
||||
// <SingleEntitySelect
|
||||
// disableBackgroundBlur
|
||||
// entitiesToSelect={companies.entitiesToSelect}
|
||||
// loading={companies.loading}
|
||||
// onCancel={handleCancel}
|
||||
// onEntitySelected={handleEntitySelect}
|
||||
// selectedEntity={companies.selectedEntities[0]}
|
||||
// />
|
||||
<NewButton onClick={handleNewClick} />
|
||||
)}
|
||||
</>
|
||||
@ -1,8 +1,13 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { useQuery } from '@apollo/client';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { currentPipelineState } from '@/pipeline/states/currentPipelineState';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { currentPipelineStepsState } from '@/pipeline/states/currentPipelineStepsState';
|
||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||
import { IconChevronDown } from '@/ui/display/icon';
|
||||
import { useRelationPicker } from '@/ui/input/components/internal/relation-picker/hooks/useRelationPicker';
|
||||
import { SingleEntitySelectBase } from '@/ui/input/relation-picker/components/SingleEntitySelectBase';
|
||||
import { useEntitySelectSearch } from '@/ui/input/relation-picker/hooks/useEntitySelectSearch';
|
||||
import { EntityForSelect } from '@/ui/input/relation-picker/types/EntityForSelect';
|
||||
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
||||
@ -13,7 +18,7 @@ import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownM
|
||||
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
||||
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
||||
|
||||
export type CompanyProgressPickerProps = {
|
||||
export type OpportunityPickerProps = {
|
||||
companyId: string | null;
|
||||
onSubmit: (
|
||||
newCompanyId: EntityForSelect | null,
|
||||
@ -22,19 +27,33 @@ export type CompanyProgressPickerProps = {
|
||||
onCancel?: () => void;
|
||||
};
|
||||
|
||||
export const CompanyProgressPicker = ({
|
||||
companyId,
|
||||
export const OpportunityPicker = ({
|
||||
onSubmit,
|
||||
onCancel,
|
||||
}: CompanyProgressPickerProps) => {
|
||||
}: OpportunityPickerProps) => {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const { searchFilter, handleSearchFilterChange } = useEntitySelectSearch();
|
||||
|
||||
// const companies = useFilteredSearchCompanyQuery({
|
||||
// searchFilter,
|
||||
// selectedIds: companyId ? [companyId] : [],
|
||||
// });
|
||||
const { findManyQuery } = useObjectMetadataItem({
|
||||
objectNameSingular: 'company',
|
||||
});
|
||||
const useFindManyQuery = (options: any) => useQuery(findManyQuery, options);
|
||||
const { identifiersMapper, searchQuery } = useRelationPicker();
|
||||
|
||||
const filteredSearchEntityResults = useFilteredSearchEntityQuery({
|
||||
queryHook: useFindManyQuery,
|
||||
filters: [
|
||||
{
|
||||
fieldNames: searchQuery?.computeFilterFields?.('company') ?? [],
|
||||
filter: searchFilter,
|
||||
},
|
||||
],
|
||||
orderByField: 'createdAt',
|
||||
selectedIds: [],
|
||||
mappingFunction: (record: any) => identifiersMapper?.(record, 'company'),
|
||||
objectNamePlural: 'companies',
|
||||
});
|
||||
|
||||
const [isProgressSelectionUnfolded, setIsProgressSelectionUnfolded] =
|
||||
useState(false);
|
||||
@ -43,12 +62,7 @@ export const CompanyProgressPicker = ({
|
||||
string | null
|
||||
>(null);
|
||||
|
||||
const [currentPipeline] = useRecoilState(currentPipelineState);
|
||||
|
||||
const currentPipelineSteps = useMemo(
|
||||
() => currentPipeline?.pipelineSteps ?? [],
|
||||
[currentPipeline],
|
||||
);
|
||||
const currentPipelineSteps = useRecoilValue(currentPipelineStepsState);
|
||||
|
||||
const handlePipelineStepChange = (newPipelineStepId: string) => {
|
||||
setSelectedPipelineStepId(newPipelineStepId);
|
||||
@ -110,13 +124,13 @@ export const CompanyProgressPicker = ({
|
||||
/>
|
||||
<DropdownMenuSeparator />
|
||||
<RecoilScope>
|
||||
{/* <SingleEntitySelectBase
|
||||
entitiesToSelect={companies.entitiesToSelect}
|
||||
loading={companies.loading}
|
||||
<SingleEntitySelectBase
|
||||
entitiesToSelect={filteredSearchEntityResults.entitiesToSelect}
|
||||
loading={filteredSearchEntityResults.loading}
|
||||
onCancel={onCancel}
|
||||
onEntitySelected={handleEntitySelected}
|
||||
selectedEntity={companies.selectedEntities[0]}
|
||||
/> */}
|
||||
selectedEntity={filteredSearchEntityResults.selectedEntities[0]}
|
||||
/>
|
||||
</RecoilScope>
|
||||
</>
|
||||
)}
|
||||
34
front/src/modules/companies/hooks/useCreateOpportunity.ts
Normal file
34
front/src/modules/companies/hooks/useCreateOpportunity.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
import { useCreateOneObjectRecord } from '@/object-record/hooks/useCreateOneObjectRecord';
|
||||
import { Opportunity } from '@/pipeline/types/Opportunity';
|
||||
import { boardCardIdsByColumnIdFamilyState } from '@/ui/object/record-board/states/boardCardIdsByColumnIdFamilyState';
|
||||
|
||||
export const useCreateOpportunity = () => {
|
||||
const { createOneObject: createOneOpportunity } =
|
||||
useCreateOneObjectRecord<Opportunity>({
|
||||
objectNameSingular: 'opportunity',
|
||||
});
|
||||
|
||||
const createOpportunity = useRecoilCallback(
|
||||
({ set }) =>
|
||||
async (companyId: string, pipelineStepId: string) => {
|
||||
const newUuid = v4();
|
||||
|
||||
set(boardCardIdsByColumnIdFamilyState(pipelineStepId), (oldValue) => [
|
||||
...oldValue,
|
||||
newUuid,
|
||||
]);
|
||||
|
||||
await createOneOpportunity?.({
|
||||
id: newUuid,
|
||||
pipelineStepId,
|
||||
companyId: companyId,
|
||||
});
|
||||
},
|
||||
[createOneOpportunity],
|
||||
);
|
||||
|
||||
return { createOpportunity };
|
||||
};
|
||||
@ -172,7 +172,7 @@ export const useFavorites = ({
|
||||
favorites.filter((favorite: Favorite) => favorite.id !== idToDelete),
|
||||
);
|
||||
},
|
||||
[apolloClient, deleteOneMutation],
|
||||
[apolloClient, deleteOneMutation, performOptimisticEvict],
|
||||
);
|
||||
|
||||
const computeNewPosition = (destIndex: number, sourceIndex: number) => {
|
||||
|
||||
@ -15,7 +15,9 @@ export const useComputeDefinitionsFromFieldMetadata = (
|
||||
const activeFieldMetadataItems = useMemo(
|
||||
() =>
|
||||
objectMetadataItem
|
||||
? objectMetadataItem.fields.filter(({ isActive }) => isActive)
|
||||
? objectMetadataItem.fields.filter(
|
||||
({ isActive, isSystem }) => isActive && !isSystem,
|
||||
)
|
||||
: [],
|
||||
[objectMetadataItem],
|
||||
);
|
||||
|
||||
@ -3,6 +3,7 @@ import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { objectMetadataItemFamilySelector } from '@/object-metadata/states/objectMetadataItemFamilySelector';
|
||||
import { useGenerateCreateOneObjectMutation } from '@/object-record/utils/generateCreateOneObjectMutation';
|
||||
import { useGenerateCacheFragment } from '@/object-record/utils/useGenerateCacheFragment';
|
||||
import { useGenerateDeleteOneObjectMutation } from '@/object-record/utils/useGenerateDeleteOneObjectMutation';
|
||||
import { useGenerateFindManyCustomObjectsQuery } from '@/object-record/utils/useGenerateFindManyCustomObjectsQuery';
|
||||
import { useGenerateFindOneCustomObjectQuery } from '@/object-record/utils/useGenerateFindOneCustomObjectQuery';
|
||||
@ -36,6 +37,10 @@ export const useObjectMetadataItem = ({
|
||||
|
||||
const objectNotFoundInMetadata = !isDefined(objectMetadataItem);
|
||||
|
||||
const cacheFragment = useGenerateCacheFragment({
|
||||
objectMetadataItem,
|
||||
});
|
||||
|
||||
const findManyQuery = useGenerateFindManyCustomObjectsQuery({
|
||||
objectMetadataItem,
|
||||
});
|
||||
@ -67,6 +72,7 @@ export const useObjectMetadataItem = ({
|
||||
basePathToShowPage,
|
||||
objectMetadataItem,
|
||||
objectNotFoundInMetadata,
|
||||
cacheFragment,
|
||||
findManyQuery,
|
||||
findOneQuery,
|
||||
createOneMutation,
|
||||
|
||||
@ -8,6 +8,7 @@ import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadata
|
||||
import { formatFieldMetadataItemAsColumnDefinition } from '@/object-metadata/utils/formatFieldMetadataItemAsColumnDefinition';
|
||||
import { filterAvailableFieldMetadataItem } from '@/object-record/utils/filterAvailableFieldMetadataItem';
|
||||
import { IconBuildingSkyscraper } from '@/ui/display/icon';
|
||||
import { useRelationPicker } from '@/ui/input/components/internal/relation-picker/hooks/useRelationPicker';
|
||||
import { PageBody } from '@/ui/layout/page/PageBody';
|
||||
import { PageContainer } from '@/ui/layout/page/PageContainer';
|
||||
import { PageFavoriteButton } from '@/ui/layout/page/PageFavoriteButton';
|
||||
@ -40,6 +41,8 @@ export const RecordShowPage = () => {
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
const { identifiersMapper } = useRelationPicker();
|
||||
|
||||
const { favorites, createFavorite, deleteFavorite } = useFavorites({
|
||||
objectNamePlural: objectMetadataItem?.namePlural,
|
||||
});
|
||||
@ -118,6 +121,11 @@ export const RecordShowPage = () => {
|
||||
? object.name.firstName + ' ' + object.name.lastName
|
||||
: object.name;
|
||||
|
||||
const recordIdentifiers = identifiersMapper?.(
|
||||
object,
|
||||
objectMetadataItem?.nameSingular ?? '',
|
||||
);
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<PageTitle title={pageName} />
|
||||
@ -144,8 +152,8 @@ export const RecordShowPage = () => {
|
||||
<ShowPageLeftContainer>
|
||||
<ShowPageSummaryCard
|
||||
id={object.id}
|
||||
logoOrAvatar={''}
|
||||
title={object.name ?? 'No name'}
|
||||
logoOrAvatar={recordIdentifiers?.avatarUrl}
|
||||
title={recordIdentifiers?.name ?? 'No name'}
|
||||
date={object.createdAt ?? ''}
|
||||
renderTitleEditComponent={() => <></>}
|
||||
avatarType="squared"
|
||||
|
||||
@ -34,6 +34,7 @@ export const getRecordOptimisticEffectDefinition = ({
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
draft.edges.unshift({ node: newData, cursor: '' });
|
||||
});
|
||||
|
||||
|
||||
@ -30,24 +30,29 @@ export const useFindManyObjectRecords = <
|
||||
objectNamePlural,
|
||||
filter,
|
||||
orderBy,
|
||||
limit,
|
||||
onCompleted,
|
||||
skip,
|
||||
}: Pick<ObjectMetadataItemIdentifier, 'objectNamePlural'> & {
|
||||
filter?: any;
|
||||
orderBy?: any;
|
||||
limit?: number;
|
||||
onCompleted?: (data: PaginatedObjectTypeResults<ObjectType>) => void;
|
||||
skip?: boolean;
|
||||
}) => {
|
||||
const findManyQueryStateIdentifier =
|
||||
objectNamePlural + JSON.stringify(filter);
|
||||
|
||||
const [lastCursor, setLastCursor] = useRecoilState(
|
||||
cursorFamilyState(objectNamePlural),
|
||||
cursorFamilyState(findManyQueryStateIdentifier),
|
||||
);
|
||||
|
||||
const [hasNextPage, setHasNextPage] = useRecoilState(
|
||||
hasNextPageFamilyState(objectNamePlural),
|
||||
hasNextPageFamilyState(findManyQueryStateIdentifier),
|
||||
);
|
||||
|
||||
const [, setIsFetchingMoreObjects] = useRecoilState(
|
||||
isFetchingMoreObjectsFamilyState(objectNamePlural),
|
||||
isFetchingMoreObjectsFamilyState(findManyQueryStateIdentifier),
|
||||
);
|
||||
|
||||
const { objectMetadataItem, objectNotFoundInMetadata, findManyQuery } =
|
||||
@ -68,6 +73,7 @@ export const useFindManyObjectRecords = <
|
||||
variables: {
|
||||
filter: filter ?? {},
|
||||
orderBy: orderBy ?? {},
|
||||
limit: limit ?? 30,
|
||||
},
|
||||
onCompleted: (data) => {
|
||||
if (objectMetadataItem) {
|
||||
|
||||
@ -2,8 +2,8 @@ import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { useOptimisticEffect } from '@/apollo/optimistic-effect/hooks/useOptimisticEffect';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { turnFiltersIntoWhereClauseV2 } from '@/ui/object/object-filter-dropdown/utils/turnFiltersIntoWhereClauseV2';
|
||||
import { turnSortsIntoOrderByV2 } from '@/ui/object/object-sort-dropdown/utils/turnSortsIntoOrderByV2';
|
||||
import { turnFiltersIntoWhereClause } from '@/ui/object/object-filter-dropdown/utils/turnFiltersIntoWhereClause';
|
||||
import { turnSortsIntoOrderBy } from '@/ui/object/object-sort-dropdown/utils/turnSortsIntoOrderBy';
|
||||
import { useRecordTableScopedStates } from '@/ui/object/record-table/hooks/internal/useRecordTableScopedStates';
|
||||
import { useRecordTable } from '@/ui/object/record-table/hooks/useRecordTable';
|
||||
|
||||
@ -31,11 +31,11 @@ export const useObjectRecordTable = () => {
|
||||
const tableFilters = useRecoilValue(tableFiltersState);
|
||||
const tableSorts = useRecoilValue(tableSortsState);
|
||||
|
||||
const filter = turnFiltersIntoWhereClauseV2(
|
||||
const filter = turnFiltersIntoWhereClause(
|
||||
tableFilters,
|
||||
foundObjectMetadataItem?.fields ?? [],
|
||||
);
|
||||
const orderBy = turnSortsIntoOrderByV2(
|
||||
const orderBy = turnSortsIntoOrderBy(
|
||||
tableSorts,
|
||||
foundObjectMetadataItem?.fields ?? [],
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { useApolloClient, useMutation } from '@apollo/client';
|
||||
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { ObjectMetadataItemIdentifier } from '@/object-metadata/types/ObjectMetadataItemIdentifier';
|
||||
@ -11,10 +11,13 @@ export const useUpdateOneObjectRecord = <T>({
|
||||
objectMetadataItem: foundObjectMetadataItem,
|
||||
objectNotFoundInMetadata,
|
||||
updateOneMutation,
|
||||
cacheFragment,
|
||||
} = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
});
|
||||
|
||||
const { cache } = useApolloClient();
|
||||
|
||||
// TODO: type this with a minimal type at least with Record<string, any>
|
||||
const [mutate] = useMutation(updateOneMutation);
|
||||
|
||||
@ -29,6 +32,15 @@ export const useUpdateOneObjectRecord = <T>({
|
||||
return null;
|
||||
}
|
||||
|
||||
const cachedRecordId = cache.identify({
|
||||
__typename: capitalize(foundObjectMetadataItem?.nameSingular ?? ''),
|
||||
id: idToUpdate,
|
||||
});
|
||||
const cachedRecord = cache.readFragment({
|
||||
id: cachedRecordId,
|
||||
fragment: cacheFragment,
|
||||
});
|
||||
|
||||
const updatedObject = await mutate({
|
||||
variables: {
|
||||
idToUpdate: idToUpdate,
|
||||
@ -38,7 +50,7 @@ export const useUpdateOneObjectRecord = <T>({
|
||||
},
|
||||
optimisticResponse: {
|
||||
[`update${capitalize(objectNameSingular)}`]: {
|
||||
id: idToUpdate,
|
||||
...(cachedRecord ?? {}),
|
||||
...input,
|
||||
},
|
||||
},
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
import { useMapFieldMetadataToGraphQLQuery } from '@/object-metadata/hooks/useMapFieldMetadataToGraphQLQuery';
|
||||
import { EMPTY_MUTATION } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { capitalize } from '~/utils/string/capitalize';
|
||||
|
||||
export const useGenerateCacheFragment = ({
|
||||
objectMetadataItem,
|
||||
}: {
|
||||
objectMetadataItem: ObjectMetadataItem | undefined | null;
|
||||
}) => {
|
||||
const mapFieldMetadataToGraphQLQuery = useMapFieldMetadataToGraphQLQuery();
|
||||
|
||||
if (!objectMetadataItem) {
|
||||
return EMPTY_MUTATION;
|
||||
}
|
||||
|
||||
const capitalizedObjectName = capitalize(objectMetadataItem.nameSingular);
|
||||
|
||||
return gql`
|
||||
fragment ${capitalizedObjectName}Fragment on ${capitalizedObjectName} {
|
||||
id
|
||||
${objectMetadataItem.fields
|
||||
.map((field) => mapFieldMetadataToGraphQLQuery(field))
|
||||
.join('\n')}
|
||||
}
|
||||
`;
|
||||
};
|
||||
@ -1,4 +1,5 @@
|
||||
import { CompanyProgressPicker } from '@/companies/components/CompanyProgressPicker';
|
||||
import { OpportunityPicker } from '@/companies/components/OpportunityPicker';
|
||||
import { useCreateOpportunity } from '@/companies/hooks/useCreateOpportunity';
|
||||
import { PageHotkeyScope } from '@/types/PageHotkeyScope';
|
||||
import { IconPlus } from '@/ui/display/icon/index';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
@ -17,6 +18,8 @@ export const PipelineAddButton = () => {
|
||||
dropdownScopeId: 'add-pipeline-progress',
|
||||
});
|
||||
|
||||
const { createOpportunity } = useCreateOpportunity();
|
||||
|
||||
const handleCompanySelected = (
|
||||
selectedCompany: EntityForSelect | null,
|
||||
selectedPipelineStepId: string | null,
|
||||
@ -24,9 +27,7 @@ export const PipelineAddButton = () => {
|
||||
if (!selectedCompany?.id) {
|
||||
enqueueSnackBar(
|
||||
'There was a problem with the company selection, please retry.',
|
||||
{
|
||||
variant: 'error',
|
||||
},
|
||||
{ variant: 'error' },
|
||||
);
|
||||
|
||||
logError('There was a problem with the company selection, please retry.');
|
||||
@ -36,16 +37,14 @@ export const PipelineAddButton = () => {
|
||||
if (!selectedPipelineStepId) {
|
||||
enqueueSnackBar(
|
||||
'There was a problem with the pipeline stage selection, please retry.',
|
||||
{
|
||||
variant: 'error',
|
||||
},
|
||||
{ variant: 'error' },
|
||||
);
|
||||
|
||||
logError('There was a problem with the pipeline stage selection.');
|
||||
logError('There was a problem with the pipeline step selection.');
|
||||
return;
|
||||
}
|
||||
closeDropdown();
|
||||
//createCompanyProgress(selectedCompany.id, selectedPipelineStepId);
|
||||
createOpportunity(selectedCompany.id, selectedPipelineStepId);
|
||||
};
|
||||
|
||||
return (
|
||||
@ -62,7 +61,7 @@ export const PipelineAddButton = () => {
|
||||
/>
|
||||
}
|
||||
dropdownComponents={
|
||||
<CompanyProgressPicker
|
||||
<OpportunityPicker
|
||||
companyId={null}
|
||||
onSubmit={handleCompanySelected}
|
||||
onCancel={closeDropdown}
|
||||
|
||||
@ -3,7 +3,7 @@ import { useQuery } from '@apollo/client';
|
||||
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||
import { IconUserCircle } from '@/ui/display/icon';
|
||||
import { IconForbid } from '@/ui/display/icon';
|
||||
import { useRelationPicker } from '@/ui/input/components/internal/relation-picker/hooks/useRelationPicker';
|
||||
import { SingleEntitySelect } from '@/ui/input/relation-picker/components/SingleEntitySelect';
|
||||
import { relationPickerSearchFilterScopedState } from '@/ui/input/relation-picker/states/relationPickerSearchFilterScopedState';
|
||||
@ -17,6 +17,7 @@ export type RelationPickerProps = {
|
||||
onSubmit: (newUser: EntityForSelect | null) => void;
|
||||
onCancel?: () => void;
|
||||
width?: number;
|
||||
excludeRecordIds?: string[];
|
||||
initialSearchFilter?: string | null;
|
||||
fieldDefinition: FieldDefinition<FieldRelationMetadata>;
|
||||
};
|
||||
@ -25,6 +26,7 @@ export const RelationPicker = ({
|
||||
recordId,
|
||||
onSubmit,
|
||||
onCancel,
|
||||
excludeRecordIds,
|
||||
width,
|
||||
initialSearchFilter,
|
||||
fieldDefinition,
|
||||
@ -63,6 +65,7 @@ export const RelationPicker = ({
|
||||
fieldDefinition.metadata.relationObjectMetadataNameSingular,
|
||||
),
|
||||
selectedIds: recordId ? [recordId] : [],
|
||||
excludeEntityIds: excludeRecordIds,
|
||||
objectNamePlural: fieldDefinition.metadata.relationObjectMetadataNamePlural,
|
||||
});
|
||||
|
||||
@ -72,8 +75,8 @@ export const RelationPicker = ({
|
||||
|
||||
return (
|
||||
<SingleEntitySelect
|
||||
EmptyIcon={IconUserCircle}
|
||||
emptyLabel="No Owner"
|
||||
EmptyIcon={IconForbid}
|
||||
emptyLabel={'No ' + fieldDefinition.label}
|
||||
entitiesToSelect={records.entitiesToSelect}
|
||||
loading={records.loading}
|
||||
onCancel={onCancel}
|
||||
|
||||
@ -8,7 +8,7 @@ const StyledOuterContainer = styled.div`
|
||||
display: flex;
|
||||
|
||||
gap: ${({ theme }) => (useIsMobile() ? theme.spacing(3) : '0')};
|
||||
height: ${() => (useIsMobile() ? '100%' : 'auto')};
|
||||
height: ${() => (useIsMobile() ? '100%' : '100%')};
|
||||
overflow-x: ${() => (useIsMobile() ? 'hidden' : 'auto')};
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
@ -31,6 +31,12 @@ const StyledInnerContainer = styled.div`
|
||||
}};
|
||||
`;
|
||||
|
||||
const StyledIntermediateContainer = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: ${({ theme }) => theme.spacing(3)};
|
||||
`;
|
||||
|
||||
export type ShowPageLeftContainerProps = {
|
||||
children: ReactElement[];
|
||||
};
|
||||
@ -46,7 +52,9 @@ export const ShowPageLeftContainer = ({
|
||||
) : (
|
||||
<StyledOuterContainer>
|
||||
<ScrollWrapper>
|
||||
<StyledInnerContainer>{children}</StyledInnerContainer>
|
||||
<StyledIntermediateContainer>
|
||||
<StyledInnerContainer>{children}</StyledInnerContainer>
|
||||
</StyledIntermediateContainer>
|
||||
</ScrollWrapper>
|
||||
</StyledOuterContainer>
|
||||
);
|
||||
|
||||
@ -91,16 +91,18 @@ export const ShowPageSummaryCard = ({
|
||||
const onFileChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.target.files) onUploadPicture?.(e.target.files[0]);
|
||||
};
|
||||
const handleAvatarClick = () => {
|
||||
inputFileRef?.current?.click?.();
|
||||
};
|
||||
|
||||
// Todo - add back in when we have the ability to upload a picture
|
||||
// const handleAvatarClick = () => {
|
||||
// inputFileRef?.current?.click?.();
|
||||
// };
|
||||
|
||||
return (
|
||||
<StyledShowPageSummaryCard>
|
||||
<StyledAvatarWrapper>
|
||||
<Avatar
|
||||
avatarUrl={logoOrAvatar}
|
||||
onClick={onUploadPicture ? handleAvatarClick : undefined}
|
||||
// onClick={onUploadPicture ? handleAvatarClick : undefined}
|
||||
size="xl"
|
||||
colorId={id}
|
||||
placeholder={title}
|
||||
|
||||
@ -9,7 +9,7 @@ type FilterToTurnIntoWhereClause = Omit<Filter, 'definition'> & {
|
||||
};
|
||||
};
|
||||
|
||||
export const turnFiltersIntoWhereClauseV2 = (
|
||||
export const turnFiltersIntoWhereClause = (
|
||||
filters: FilterToTurnIntoWhereClause[],
|
||||
fields: Pick<Field, 'id' | 'name'>[],
|
||||
) => {
|
||||
@ -2,7 +2,7 @@ import { Field } from '~/generated/graphql';
|
||||
|
||||
import { Sort } from '../types/Sort';
|
||||
|
||||
export const turnSortsIntoOrderByV2 = (
|
||||
export const turnSortsIntoOrderBy = (
|
||||
sorts: Sort[],
|
||||
fields: Pick<Field, 'id' | 'name'>[],
|
||||
) => {
|
||||
@ -1,12 +1,6 @@
|
||||
import { ComponentType } from 'react';
|
||||
|
||||
import { Opportunity } from '@/pipeline/types/Opportunity';
|
||||
import { FilterDefinitionByEntity } from '@/ui/object/object-filter-dropdown/types/FilterDefinitionByEntity';
|
||||
import { SortDefinition } from '@/ui/object/object-sort-dropdown/types/SortDefinition';
|
||||
|
||||
export type BoardOptions = {
|
||||
newCardComponent: React.ReactNode;
|
||||
CardComponent: ComponentType;
|
||||
filterDefinitions: FilterDefinitionByEntity<Opportunity>[];
|
||||
sortDefinitions: SortDefinition[];
|
||||
};
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
import { useQuery } from '@apollo/client';
|
||||
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery';
|
||||
import { ObjectFilterDropdownEntitySearchSelect } from '@/ui/object/object-filter-dropdown/components/ObjectFilterDropdownEntitySearchSelect';
|
||||
import { useFilter } from '@/ui/object/object-filter-dropdown/hooks/useFilter';
|
||||
|
||||
export const FilterDropdownUserSearchSelect = () => {
|
||||
const {
|
||||
objectFilterDropdownSearchInput,
|
||||
objectFilterDropdownSelectedEntityId,
|
||||
} = useFilter();
|
||||
|
||||
const { findManyQuery } = useObjectMetadataItem({
|
||||
objectNameSingular: 'workspaceMember',
|
||||
});
|
||||
|
||||
const useFindManyWorkspaceMembers = (options: any) =>
|
||||
useQuery(findManyQuery, options);
|
||||
|
||||
const workspaceMembers = useFilteredSearchEntityQuery({
|
||||
queryHook: useFindManyWorkspaceMembers,
|
||||
filters: [
|
||||
{
|
||||
fieldNames: ['name.firstName', 'name.lastName'],
|
||||
filter: objectFilterDropdownSearchInput,
|
||||
},
|
||||
],
|
||||
orderByField: 'createdAt',
|
||||
mappingFunction: (workspaceMember) => ({
|
||||
entityType: 'WorkspaceMember',
|
||||
id: workspaceMember.id,
|
||||
name:
|
||||
workspaceMember.name.firstName + ' ' + workspaceMember.name.lastName,
|
||||
avatarType: 'rounded',
|
||||
avatarUrl: '',
|
||||
record: workspaceMember,
|
||||
}),
|
||||
selectedIds: objectFilterDropdownSelectedEntityId
|
||||
? [objectFilterDropdownSelectedEntityId]
|
||||
: [],
|
||||
objectNamePlural: 'workspaceMembers',
|
||||
});
|
||||
|
||||
return (
|
||||
<ObjectFilterDropdownEntitySearchSelect
|
||||
entitiesForSelect={workspaceMembers}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@ -1,5 +1,5 @@
|
||||
import { BoardFieldDefinition } from '@/ui/object/record-board/types/BoardFieldDefinition';
|
||||
import { FieldMetadata } from '@/ui/object/field/types/FieldMetadata';
|
||||
import { BoardFieldDefinition } from '@/ui/object/record-board/types/BoardFieldDefinition';
|
||||
import { ColumnDefinition } from '@/ui/object/record-table/types/ColumnDefinition';
|
||||
|
||||
export type ViewField = {
|
||||
|
||||
@ -1,13 +1,8 @@
|
||||
import { CompanyBoardCard } from '@/companies/components/CompanyBoardCard';
|
||||
import { NewCompanyProgressButton } from '@/companies/components/NewCompanyProgressButton';
|
||||
import { NewOpportunityButton } from '@/companies/components/NewOpportunityButton';
|
||||
import { BoardOptions } from '@/ui/object/record-board/types/BoardOptions';
|
||||
|
||||
import { opportunityBoardFilterDefinitions } from './constants/opportunityBoardFilterDefinitions';
|
||||
import { opportunityBoardSortDefinitions } from './constants/opportunityBoardSortDefinitions';
|
||||
|
||||
export const opportunitiesBoardOptions: BoardOptions = {
|
||||
newCardComponent: <NewCompanyProgressButton />,
|
||||
newCardComponent: <NewOpportunityButton />,
|
||||
CardComponent: CompanyBoardCard,
|
||||
filterDefinitions: opportunityBoardFilterDefinitions,
|
||||
sortDefinitions: opportunityBoardSortDefinitions,
|
||||
};
|
||||
|
||||
@ -89,7 +89,7 @@ export const seedCompanyFieldMetadata = async (
|
||||
description: undefined,
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isSystem: true,
|
||||
isSystem: false,
|
||||
defaultValue: { type: 'now' },
|
||||
},
|
||||
{
|
||||
|
||||
@ -84,7 +84,7 @@ export const seedOpportunityFieldMetadata = async (
|
||||
description: undefined,
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isSystem: true,
|
||||
isSystem: false,
|
||||
defaultValue: { type: 'now' },
|
||||
},
|
||||
{
|
||||
@ -175,7 +175,7 @@ export const seedOpportunityFieldMetadata = async (
|
||||
description: 'Opportunity pipeline step',
|
||||
icon: 'IconKanban',
|
||||
isNullable: true,
|
||||
isSystem: false,
|
||||
isSystem: true,
|
||||
defaultValue: undefined,
|
||||
},
|
||||
{
|
||||
@ -239,7 +239,7 @@ export const seedOpportunityFieldMetadata = async (
|
||||
description: 'Opportunity person',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
isSystem: false,
|
||||
isSystem: true,
|
||||
defaultValue: undefined,
|
||||
},
|
||||
{
|
||||
|
||||
@ -89,7 +89,7 @@ export const seedPersonFieldMetadata = async (
|
||||
description: undefined,
|
||||
icon: 'IconCalendar',
|
||||
isNullable: false,
|
||||
isSystem: true,
|
||||
isSystem: false,
|
||||
defaultValue: { type: 'now' },
|
||||
},
|
||||
{
|
||||
@ -126,7 +126,7 @@ export const seedPersonFieldMetadata = async (
|
||||
},
|
||||
description: 'Contact’s name',
|
||||
icon: 'IconUser',
|
||||
isNullable: false,
|
||||
isNullable: true,
|
||||
isSystem: false,
|
||||
defaultValue: { firstName: '', lastName: '' },
|
||||
},
|
||||
@ -301,11 +301,11 @@ export const seedPersonFieldMetadata = async (
|
||||
workspaceId: SeedWorkspaceId,
|
||||
isActive: true,
|
||||
type: FieldMetadataType.RELATION,
|
||||
name: 'pointOfContactForOpporunities',
|
||||
name: 'pointOfContactForOpportunities',
|
||||
label: 'POC for Opportunities',
|
||||
targetColumnMap: {},
|
||||
description: 'Point of Contact for Opportuniites',
|
||||
icon: 'IconArrowTarget',
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
isSystem: false,
|
||||
defaultValue: undefined,
|
||||
|
||||
@ -1,16 +1,25 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddCascadeDeleteOnRefreshTokenUser1700661180856 implements MigrationInterface {
|
||||
name = 'AddCascadeDeleteOnRefreshTokenUser1700661180856'
|
||||
export class AddCascadeDeleteOnRefreshTokenUser1700661180856
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddCascadeDeleteOnRefreshTokenUser1700661180856';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "core"."refreshToken" DROP CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e"`);
|
||||
await queryRunner.query(`ALTER TABLE "core"."refreshToken" ADD CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e" FOREIGN KEY ("userId") REFERENCES "core"."user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "core"."refreshToken" DROP CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e"`);
|
||||
await queryRunner.query(`ALTER TABLE "core"."refreshToken" ADD CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e" FOREIGN KEY ("userId") REFERENCES "core"."user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."refreshToken" DROP CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."refreshToken" ADD CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e" FOREIGN KEY ("userId") REFERENCES "core"."user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."refreshToken" DROP CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."refreshToken" ADD CONSTRAINT "FK_7008a2b0fb083127f60b5f4448e" FOREIGN KEY ("userId") REFERENCES "core"."user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,25 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddWorkspaceDeleteCascadeSetNullInUser1700663611659 implements MigrationInterface {
|
||||
name = 'AddWorkspaceDeleteCascadeSetNullInUser1700663611659'
|
||||
export class AddWorkspaceDeleteCascadeSetNullInUser1700663611659
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddWorkspaceDeleteCascadeSetNullInUser1700663611659';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "core"."user" DROP CONSTRAINT "FK_2ec910029395fa7655621c88908"`);
|
||||
await queryRunner.query(`ALTER TABLE "core"."user" ADD CONSTRAINT "FK_2ec910029395fa7655621c88908" FOREIGN KEY ("defaultWorkspaceId") REFERENCES "core"."workspace"("id") ON DELETE SET NULL ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "core"."user" DROP CONSTRAINT "FK_2ec910029395fa7655621c88908"`);
|
||||
await queryRunner.query(`ALTER TABLE "core"."user" ADD CONSTRAINT "FK_2ec910029395fa7655621c88908" FOREIGN KEY ("defaultWorkspaceId") REFERENCES "core"."workspace"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."user" DROP CONSTRAINT "FK_2ec910029395fa7655621c88908"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."user" ADD CONSTRAINT "FK_2ec910029395fa7655621c88908" FOREIGN KEY ("defaultWorkspaceId") REFERENCES "core"."workspace"("id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."user" DROP CONSTRAINT "FK_2ec910029395fa7655621c88908"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "core"."user" ADD CONSTRAINT "FK_2ec910029395fa7655621c88908" FOREIGN KEY ("defaultWorkspaceId") REFERENCES "core"."workspace"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,17 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddWorkspaceCacheVersion1700650554672 implements MigrationInterface {
|
||||
name = 'AddWorkspaceCacheVersion1700650554672'
|
||||
export class AddWorkspaceCacheVersion1700650554672
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddWorkspaceCacheVersion1700650554672';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE "metadata"."workspaceCacheVersion" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "workspaceId" character varying NOT NULL, "version" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_1a80ecf2638b477809403cc26ed" UNIQUE ("workspaceId"), CONSTRAINT "PK_5d502f8dbfb5b9a8bf2439320e9" PRIMARY KEY ("id"))`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "metadata"."workspaceCacheVersion"`);
|
||||
}
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "metadata"."workspaceCacheVersion" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "workspaceId" character varying NOT NULL, "version" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_1a80ecf2638b477809403cc26ed" UNIQUE ("workspaceId"), CONSTRAINT "PK_5d502f8dbfb5b9a8bf2439320e9" PRIMARY KEY ("id"))`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "metadata"."workspaceCacheVersion"`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,37 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddCascadeDeleteOnRelationObject1700661538754 implements MigrationInterface {
|
||||
name = 'AddCascadeDeleteOnRelationObject1700661538754'
|
||||
export class AddCascadeDeleteOnRelationObject1700661538754
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddCascadeDeleteOnRelationObject1700661538754';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824"`);
|
||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d"`);
|
||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d" FOREIGN KEY ("fromObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824" FOREIGN KEY ("toObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824"`);
|
||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d"`);
|
||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d" FOREIGN KEY ("fromObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824" FOREIGN KEY ("toObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d" FOREIGN KEY ("fromObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824" FOREIGN KEY ("toObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."relationMetadata" DROP CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d"`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_f2a0acd3a548ee446a1a35df44d" FOREIGN KEY ("fromObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "metadata"."relationMetadata" ADD CONSTRAINT "FK_0f781f589e5a527b8f3d3a4b824" FOREIGN KEY ("toObjectMetadataId") REFERENCES "metadata"."objectMetadata"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,6 +63,7 @@ const opportunityMetadata = {
|
||||
},
|
||||
description: 'Opportunity pipeline step',
|
||||
icon: 'IconKanban',
|
||||
isSystem: true,
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
@ -90,6 +91,7 @@ const opportunityMetadata = {
|
||||
description: 'Opportunity person',
|
||||
icon: 'IconUser',
|
||||
isNullable: true,
|
||||
isSystem: true,
|
||||
},
|
||||
{
|
||||
isCustom: false,
|
||||
|
||||
@ -23,7 +23,7 @@ const personMetadata = {
|
||||
},
|
||||
description: 'Contact’s name',
|
||||
icon: 'IconUser',
|
||||
isNullable: false,
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
isCustom: false,
|
||||
@ -116,7 +116,7 @@ const personMetadata = {
|
||||
},
|
||||
description: 'Contact’s avatar',
|
||||
icon: 'IconFileUpload',
|
||||
isNullable: false,
|
||||
isNullable: true,
|
||||
},
|
||||
// Relations
|
||||
{
|
||||
@ -151,8 +151,8 @@ const personMetadata = {
|
||||
label: 'POC for Opportunities',
|
||||
targetColumnMap: {},
|
||||
description: 'Point of Contact for Opportunities',
|
||||
icon: 'IconArrowTarget',
|
||||
isNullable: false,
|
||||
icon: 'IconTargetArrow',
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
isCustom: false,
|
||||
|
||||
@ -47,7 +47,7 @@ export const basicFieldsMetadata: Partial<FieldMetadataEntity>[] = [
|
||||
value: 'id',
|
||||
},
|
||||
isNullable: true,
|
||||
// isSystem: true,
|
||||
isSystem: true,
|
||||
isCustom: false,
|
||||
isActive: true,
|
||||
defaultValue: { type: 'uuid' },
|
||||
@ -75,6 +75,7 @@ export const basicFieldsMetadata: Partial<FieldMetadataEntity>[] = [
|
||||
icon: 'IconCalendar',
|
||||
isNullable: true,
|
||||
isCustom: false,
|
||||
isSystem: true,
|
||||
isActive: true,
|
||||
defaultValue: { type: 'now' },
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user