Skip to content

The open alternative to Salesforce, designed for AI.

Partners app: application state model, auto-listing, and views (#24785)

Rashad Karanouh71727156ec65
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/application/navigation-menu-items/followup-applications.navigation-menu-item.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/application/navigation-menu-items/followup-applications.navigation-menu-item.ts
deleted file mode 100644
index 2a42d131c6a..00000000000
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/application/navigation-menu-items/followup-applications.navigation-menu-item.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { NavigationMenuItemType, defineNavigationMenuItem } from 'twenty-sdk/define';
-
-import { FOLLOWUP_APPLICATIONS_VIEW_UNIVERSAL_IDENTIFIER } from 'src/modules/application/views/followup-applications.view';
-
-export default defineNavigationMenuItem({
- universalIdentifier: '636cddf9-b104-432d-a5d3-3bad36b7a54a',
- type: NavigationMenuItemType.VIEW,
- icon: 'IconClock',
- position: 7,
- folderUniversalIdentifier: '0b2e499a-ae74-45e0-af08-243e19fc56aa',
- viewUniversalIdentifier: FOLLOWUP_APPLICATIONS_VIEW_UNIVERSAL_IDENTIFIER,
-});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/application/navigation-menu-items/pipeline.navigation-menu-item.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/application/navigation-menu-items/pipeline.navigation-menu-item.ts
new file mode 100644
index 00000000000..df85be4f805
--- /dev/null
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/application/navigation-menu-items/pipeline.navigation-menu-item.ts
@@ -0,0 +1,12 @@
+import { NavigationMenuItemType, defineNavigationMenuItem } from 'twenty-sdk/define';
+
+import { PIPELINE_VIEW_UNIVERSAL_IDENTIFIER } from 'src/modules/application/views/pipeline.view';
+
+export default defineNavigationMenuItem({
+ universalIdentifier: 'ae1632fc-c53c-4a27-8e07-ad1f3a2d08b9',
+ type: NavigationMenuItemType.VIEW,
+ icon: 'IconLayoutKanban',
+ position: 3,
+ folderUniversalIdentifier: '0b2e499a-ae74-45e0-af08-243e19fc56aa',
+ viewUniversalIdentifier: PIPELINE_VIEW_UNIVERSAL_IDENTIFIER,
+});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/application/objects/application.object.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/application/objects/application.object.ts
index c90e09df230..8fd3cc30406 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/application/objects/application.object.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/application/objects/application.object.ts
@@ -28,8 +28,6 @@ export const APPLICATION_STATE_FIELD_ID =
'c686db4f-f0e9-41a0-bdb3-3b4024ff59b6';
export const APPLICATION_PITCH_FIELD_ID =
'0a6cd9c9-e1e9-4315-8356-b72077443805';
-export const APPLICATION_LAST_ACTIVITY_AT_FIELD_ID =
- 'b184ac02-51b2-4442-9505-2b06f5c94112';
export default defineObject({
universalIdentifier: APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
@@ -130,13 +128,5 @@ export default defineObject({
icon: 'IconMessage',
isNullable: true,
},
- {
- universalIdentifier: APPLICATION_LAST_ACTIVITY_AT_FIELD_ID,
- type: FieldType.DATE_TIME,
- name: 'lastActivityAt',
- label: 'Last Activity At',
- icon: 'IconClock',
- isNullable: true,
- },
],
});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/application-record-page-fields.view.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/application-record-page-fields.view.ts
index 9661519c53b..d17e49d8c56 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/application-record-page-fields.view.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/application-record-page-fields.view.ts
@@ -1,7 +1,6 @@
import { ViewType, defineView } from 'twenty-sdk/define';
import {
- APPLICATION_LAST_ACTIVITY_AT_FIELD_ID,
APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
APPLICATION_OPPORTUNITY_FIELD_ID,
APPLICATION_PARTNER_FIELD_ID,
@@ -25,6 +24,5 @@ export default defineView({
{ universalIdentifier: '7d7ef49a-6d30-44de-b4eb-bb77d93b8982', fieldMetadataUniversalIdentifier: APPLICATION_PARTNER_FIELD_ID, position: 1, isVisible: true },
{ universalIdentifier: 'd0278990-928c-4660-ac27-3abca0e52a5e', fieldMetadataUniversalIdentifier: APPLICATION_STATE_FIELD_ID, position: 2, isVisible: true },
{ universalIdentifier: '28e0642b-76eb-4d41-83de-b84f07b3aad9', fieldMetadataUniversalIdentifier: APPLICATION_PITCH_FIELD_ID, position: 3, isVisible: true },
- { universalIdentifier: '97acca2b-bda4-43f3-b58a-3293807fab08', fieldMetadataUniversalIdentifier: APPLICATION_LAST_ACTIVITY_AT_FIELD_ID, position: 4, isVisible: true },
],
});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-by-opportunity.view.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-by-opportunity.view.ts
index 98741238034..7ca84a21860 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-by-opportunity.view.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-by-opportunity.view.ts
@@ -1,7 +1,6 @@
import { ViewSortDirection, ViewType, defineView } from 'twenty-sdk/define';
import {
- APPLICATION_LAST_ACTIVITY_AT_FIELD_ID,
APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
APPLICATION_OPPORTUNITY_FIELD_ID,
APPLICATION_PARTNER_FIELD_ID,
@@ -50,13 +49,6 @@ export default defineView({
isVisible: true,
size: 280,
},
- {
- universalIdentifier: '2f570d42-614d-4562-8d12-df5605874b9c',
- fieldMetadataUniversalIdentifier: APPLICATION_LAST_ACTIVITY_AT_FIELD_ID,
- position: 4,
- isVisible: true,
- size: 180,
- },
],
sorts: [
{
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-review.view.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-review.view.ts
index 9669a5656b6..8fa150ef02f 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-review.view.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-review.view.ts
@@ -1,7 +1,6 @@
import { ViewSortDirection, ViewType, defineView } from 'twenty-sdk/define';
import {
- APPLICATION_LAST_ACTIVITY_AT_FIELD_ID,
APPLICATION_NAME_FIELD_ID,
APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
APPLICATION_OPPORTUNITY_FIELD_ID,
@@ -95,13 +94,6 @@ export default defineView({
isVisible: true,
size: 280,
},
- {
- universalIdentifier: '651dfe47-a00f-4ad5-9af8-95a656ec0b31',
- fieldMetadataUniversalIdentifier: APPLICATION_LAST_ACTIVITY_AT_FIELD_ID,
- position: 5,
- isVisible: true,
- size: 180,
- },
],
sorts: [
{
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-widget.view.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-widget.view.ts
new file mode 100644
index 00000000000..671698a6488
--- /dev/null
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/applications-widget.view.ts
@@ -0,0 +1,43 @@
+import { ViewType, defineView } from 'twenty-sdk/define';
+
+import {
+ APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
+ APPLICATION_OPPORTUNITY_FIELD_ID,
+ APPLICATION_PARTNER_FIELD_ID,
+ APPLICATION_STATE_FIELD_ID,
+} from 'src/modules/application/objects/application.object';
+
+export const APPLICATIONS_WIDGET_VIEW_UNIVERSAL_IDENTIFIER =
+ 'cbaf92ec-c1a2-41c2-b471-cc131b060e4e';
+
+// TABLE_WIDGET rather than TABLE so this view stays out of the record index view pickers.
+export default defineView({
+ universalIdentifier: APPLICATIONS_WIDGET_VIEW_UNIVERSAL_IDENTIFIER,
+ name: 'Applications Widget',
+ icon: 'IconSend',
+ objectUniversalIdentifier: APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
+ type: ViewType.TABLE_WIDGET,
+ fields: [
+ {
+ universalIdentifier: '644e184f-82ec-4762-bc04-8c9998c2784f',
+ fieldMetadataUniversalIdentifier: APPLICATION_PARTNER_FIELD_ID,
+ position: 0,
+ isVisible: true,
+ size: 220,
+ },
+ {
+ universalIdentifier: '0b009608-bbf4-4b2f-b2c1-533be28abc76',
+ fieldMetadataUniversalIdentifier: APPLICATION_OPPORTUNITY_FIELD_ID,
+ position: 1,
+ isVisible: true,
+ size: 220,
+ },
+ {
+ universalIdentifier: '7fd677f5-01b9-4bef-9e9f-02ecb2e69eb3',
+ fieldMetadataUniversalIdentifier: APPLICATION_STATE_FIELD_ID,
+ position: 2,
+ isVisible: true,
+ size: 140,
+ },
+ ],
+});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/followup-applications.view.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/followup-applications.view.ts
deleted file mode 100644
index c7943c1ff4a..00000000000
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/followup-applications.view.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import { ViewFilterOperand, ViewType, defineView } from 'twenty-sdk/define';
-
-import {
- APPLICATION_LAST_ACTIVITY_AT_FIELD_ID,
- APPLICATION_NAME_FIELD_ID,
- APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
- APPLICATION_OPPORTUNITY_FIELD_ID,
- APPLICATION_PARTNER_FIELD_ID,
- APPLICATION_PITCH_FIELD_ID,
- APPLICATION_STATE_FIELD_ID,
-} from 'src/modules/application/objects/application.object';
-
-export const FOLLOWUP_APPLICATIONS_VIEW_UNIVERSAL_IDENTIFIER =
- 'c815e9f5-511b-467f-85b0-08ef341ff856';
-
-export default defineView({
- universalIdentifier: FOLLOWUP_APPLICATIONS_VIEW_UNIVERSAL_IDENTIFIER,
- name: 'Follow-up · Applications',
- icon: 'IconClock',
- objectUniversalIdentifier: APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
- type: ViewType.TABLE,
- position: 3,
- fields: [
- {
- universalIdentifier: '5f3632ec-797f-4b96-a228-c56830dc75d4',
- fieldMetadataUniversalIdentifier: APPLICATION_NAME_FIELD_ID,
- position: 0,
- isVisible: true,
- size: 220,
- },
- {
- universalIdentifier: '8844728f-9622-4554-9916-dba8328d3c9c',
- fieldMetadataUniversalIdentifier: APPLICATION_OPPORTUNITY_FIELD_ID,
- position: 1,
- isVisible: true,
- size: 200,
- },
- {
- universalIdentifier: '678c7516-1436-40fd-b3b4-6e5fefcecf0e',
- fieldMetadataUniversalIdentifier: APPLICATION_PARTNER_FIELD_ID,
- position: 2,
- isVisible: true,
- size: 200,
- },
- {
- universalIdentifier: '5f7884af-c5a4-4822-b8bf-0fb233e28f2f',
- fieldMetadataUniversalIdentifier: APPLICATION_STATE_FIELD_ID,
- position: 3,
- isVisible: true,
- size: 140,
- },
- {
- universalIdentifier: 'c1ea77ed-a4ab-4937-929e-d1b719a7a8d8',
- fieldMetadataUniversalIdentifier: APPLICATION_PITCH_FIELD_ID,
- position: 4,
- isVisible: true,
- size: 280,
- },
- {
- universalIdentifier: '4c5c5fb0-7a32-418e-a190-54d37547ddd3',
- fieldMetadataUniversalIdentifier: APPLICATION_LAST_ACTIVITY_AT_FIELD_ID,
- position: 5,
- isVisible: true,
- size: 180,
- },
- ],
- filters: [
- // TODO(B5): add lastActivityAt > 7d relative filter once operand form confirmed
- // ponytail: 7d literal in the filter, not config.
- {
- universalIdentifier: 'b89e349f-7b69-4917-8988-edb22d0314ac',
- fieldMetadataUniversalIdentifier: APPLICATION_STATE_FIELD_ID,
- operand: ViewFilterOperand.IS,
- value: ['APPLIED', 'INVITED', 'INTRODUCED'],
- },
- ],
-});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/my-applications.view.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/my-applications.view.ts
index a4339dc2929..f3ef18c0a59 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/my-applications.view.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/my-applications.view.ts
@@ -1,7 +1,6 @@
import { ViewType, defineView } from 'twenty-sdk/define';
import {
- APPLICATION_LAST_ACTIVITY_AT_FIELD_ID,
APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
APPLICATION_OPPORTUNITY_FIELD_ID,
APPLICATION_PITCH_FIELD_ID,
@@ -24,6 +23,5 @@ export default defineView({
{ universalIdentifier: 'fe004e19-5aee-4716-aa6f-3d27cdc52ae2', fieldMetadataUniversalIdentifier: APPLICATION_OPPORTUNITY_FIELD_ID, position: 0, isVisible: true, size: 200 },
{ universalIdentifier: '9cf77b15-fdd6-4123-bdbf-a50e422417c2', fieldMetadataUniversalIdentifier: APPLICATION_STATE_FIELD_ID, position: 1, isVisible: true, size: 140 },
{ universalIdentifier: '321a7f6c-0207-47c2-860f-706eaa5c2fa9', fieldMetadataUniversalIdentifier: APPLICATION_PITCH_FIELD_ID, position: 2, isVisible: true, size: 280 },
- { universalIdentifier: '5f862e3f-3db0-408a-9268-c04d5ee18a91', fieldMetadataUniversalIdentifier: APPLICATION_LAST_ACTIVITY_AT_FIELD_ID, position: 3, isVisible: true, size: 180 },
],
});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/pipeline.view.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/pipeline.view.ts
new file mode 100644
index 00000000000..e2bfd65cde1
--- /dev/null
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/application/views/pipeline.view.ts
@@ -0,0 +1,87 @@
+import { ViewType, defineView } from 'twenty-sdk/define';
+
+import {
+ APPLICATION_NAME_FIELD_ID,
+ APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
+ APPLICATION_OPPORTUNITY_FIELD_ID,
+ APPLICATION_PARTNER_FIELD_ID,
+ APPLICATION_PITCH_FIELD_ID,
+ APPLICATION_STATE_FIELD_ID,
+} from 'src/modules/application/objects/application.object';
+
+export const PIPELINE_VIEW_UNIVERSAL_IDENTIFIER =
+ 'aff718b3-9f2b-42c4-9f03-8710624a8f53';
+
+export default defineView({
+ universalIdentifier: PIPELINE_VIEW_UNIVERSAL_IDENTIFIER,
+ name: 'Pipeline',
+ icon: 'IconLayoutKanban',
+ objectUniversalIdentifier: APPLICATION_OBJECT_UNIVERSAL_IDENTIFIER,
+ position: 3,
+ type: ViewType.KANBAN,
+ mainGroupByFieldMetadataUniversalIdentifier: APPLICATION_STATE_FIELD_ID,
+ groups: [
+ {
+ universalIdentifier: 'f83ea54b-9123-4bac-9f70-f6ccae30a32e',
+ fieldValue: 'APPLIED',
+ position: 0,
+ isVisible: true,
+ },
+ {
+ universalIdentifier: '28d99cbc-27d0-41d6-9389-8cc4f900ffaf',
+ fieldValue: 'INVITED',
+ position: 1,
+ isVisible: true,
+ },
+ {
+ universalIdentifier: 'e37b029a-87c2-48dd-b0af-31692c61a8d0',
+ fieldValue: 'INTRODUCED',
+ position: 2,
+ isVisible: true,
+ },
+ {
+ universalIdentifier: '1454e5fe-742d-4ee4-9ac9-6e900db47c42',
+ fieldValue: 'BACKUP',
+ position: 3,
+ isVisible: true,
+ },
+ {
+ universalIdentifier: '811f5481-17d4-4f02-a72d-1ba68ba1b7b4',
+ fieldValue: 'WON',
+ position: 4,
+ isVisible: true,
+ },
+ {
+ universalIdentifier: '7b5eb05e-c07d-4c56-a20a-baaf262f7359',
+ fieldValue: 'DECLINED',
+ position: 5,
+ isVisible: true,
+ },
+ ],
+ fields: [
+ {
+ universalIdentifier: '9bd43629-07ff-4e4b-b9d5-d9fec80a6f12',
+ fieldMetadataUniversalIdentifier: APPLICATION_NAME_FIELD_ID,
+ position: 0,
+ isVisible: true,
+ },
+ {
+ universalIdentifier: '8b8f3084-bf14-428e-add5-9d2501b13c7d',
+ fieldMetadataUniversalIdentifier: APPLICATION_OPPORTUNITY_FIELD_ID,
+ position: 1,
+ isVisible: true,
+ },
+ {
+ universalIdentifier: '42ea9d40-c568-459e-9a39-367c0f07e384',
+ fieldMetadataUniversalIdentifier: APPLICATION_PARTNER_FIELD_ID,
+ position: 2,
+ isVisible: true,
+ },
+ {
+ universalIdentifier: 'a6052de9-961f-4323-9f73-0406c6c26283',
+ fieldMetadataUniversalIdentifier: APPLICATION_PITCH_FIELD_ID,
+ position: 3,
+ isVisible: true,
+ },
+ ],
+});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/intake/services/submit-client-brief.service.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/intake/services/submit-client-brief.service.ts
index b2ad9362b42..f917eeb4747 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/intake/services/submit-client-brief.service.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/intake/services/submit-client-brief.service.ts
@@ -52,7 +52,7 @@ export async function submitClientBrief(
const opportunityData: CoreSchema.OpportunityCreateInput = {
name,
need: input.need,
- isListed: false,
+ isListed: true,
stage: 'NEW',
companyId,
pointOfContactId,
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/intake/submit-client-brief.integration-test.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/intake/submit-client-brief.integration-test.ts
index 4c352801604..3321a5dd590 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/intake/submit-client-brief.integration-test.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/intake/submit-client-brief.integration-test.ts
@@ -70,7 +70,7 @@ describe('submit-client-brief handler', () => {
expect(result).toEqual({ ok: false, reason: 'unauthorized' });
});
- it('creates an unlisted opportunity with marketplace brief name suffix', async () => {
+ it('creates a listed opportunity with marketplace brief name suffix', async () => {
const input = baseInput({
requirements: 'French UI',
hostingType: 'CLOUD',
@@ -101,7 +101,7 @@ describe('submit-client-brief handler', () => {
expect(opp?.need).toBe(input.need);
expect(opp?.requirements).toContain('French UI');
expect(opp?.requirements).toContain('Additional context:');
- expect(opp?.isListed).toBe(false);
+ expect(opp?.isListed).toBe(true);
expect(opp?.stage).toBe('NEW');
expect(opp?.company?.name).toBe(input.companyName);
expect(opp?.pointOfContact?.emails?.primaryEmail).toBe(input.email);
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/graphql/mutations/update-opportunity-is-listed.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/graphql/mutations/update-opportunity-is-listed.ts
new file mode 100644
index 00000000000..f6670db5579
--- /dev/null
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/graphql/mutations/update-opportunity-is-listed.ts
@@ -0,0 +1,11 @@
+import type { CoreApiClient } from 'twenty-client-sdk/core';
+
+export function updateOpportunityIsListed(
+ client: CoreApiClient,
+ opportunityId: string,
+ isListed: boolean,
+) {
+ return client.mutation({
+ updateOpportunity: { __args: { id: opportunityId, data: { isListed } }, id: true },
+ });
+}
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/on-opportunity-intro-sent.logic-function.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/on-opportunity-intro-sent.logic-function.ts
new file mode 100644
index 00000000000..101374b0502
--- /dev/null
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/on-opportunity-intro-sent.logic-function.ts
@@ -0,0 +1,31 @@
+import { CoreApiClient, type CoreSchema } from 'twenty-client-sdk/core';
+import {
+ type DatabaseEventPayload,
+ defineLogicFunction,
+ type ObjectRecordUpdateEvent,
+} from 'twenty-sdk/define';
+
+import { ON_OPPORTUNITY_INTRO_SENT_FN_UNIVERSAL_IDENTIFIER } from 'src/constants/universal-identifiers';
+import { updateOpportunityIsListed } from 'src/modules/opportunity/matching/graphql/mutations/update-opportunity-is-listed';
+
+export const handler = async (
+ payload: DatabaseEventPayload<ObjectRecordUpdateEvent<CoreSchema.Opportunity>>,
+): Promise<Record<string, unknown>> => {
+ const { after, updatedFields } = payload.properties;
+ if (!updatedFields?.includes('introSentAt') || !after?.id) return {};
+ if (!after.introSentAt) return { skipped: true, reason: 'intro_sent_at_cleared' };
+
+ await updateOpportunityIsListed(new CoreApiClient(), after.id, false);
+ return { unlisted: true, opportunityId: after.id };
+};
+
+export default defineLogicFunction({
+ universalIdentifier: ON_OPPORTUNITY_INTRO_SENT_FN_UNIVERSAL_IDENTIFIER,
+ name: 'on-opportunity-intro-sent',
+ timeoutSeconds: 15,
+ handler,
+ databaseEventTriggerSettings: {
+ eventName: 'opportunity.updated',
+ updatedFields: ['introSentAt'],
+ },
+});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/on-opportunity-intro-sent.test.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/on-opportunity-intro-sent.test.ts
new file mode 100644
index 00000000000..259b29e9ff7
--- /dev/null
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/on-opportunity-intro-sent.test.ts
@@ -0,0 +1,48 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+const { mutationMock } = vi.hoisted(() => ({
+ mutationMock: vi.fn(),
+}));
+vi.mock('twenty-client-sdk/core', () => ({
+ CoreApiClient: vi.fn(function () {
+ return { mutation: mutationMock };
+ }),
+}));
+
+import { handler } from './on-opportunity-intro-sent.logic-function';
+
+const OPP = 'aaaaaaaa-0000-0000-0000-000000000001';
+
+const event = (after: Record<string, unknown>, updatedFields: string[]) =>
+ ({ properties: { after, updatedFields } }) as never;
+
+describe('on-opportunity-intro-sent', () => {
+ beforeEach(() => {
+ mutationMock.mockReset();
+ mutationMock.mockResolvedValue({ updateOpportunity: { id: OPP } });
+ });
+
+ it('sets isListed to false when introSentAt goes from empty to a date', async () => {
+ const result = await handler(
+ event({ id: OPP, introSentAt: '2026-08-19T00:00:00.000Z' }, ['introSentAt']),
+ );
+ expect(mutationMock).toHaveBeenCalledWith({
+ updateOpportunity: { __args: { id: OPP, data: { isListed: false } }, id: true },
+ });
+ expect(result).toEqual({ unlisted: true, opportunityId: OPP });
+ });
+
+ it('writes nothing when introSentAt is cleared', async () => {
+ const result = await handler(event({ id: OPP, introSentAt: null }, ['introSentAt']));
+ expect(mutationMock).not.toHaveBeenCalled();
+ expect(result).toEqual({ skipped: true, reason: 'intro_sent_at_cleared' });
+ });
+
+ it('returns without writing when the payload carries no record id', async () => {
+ const result = await handler(
+ event({ introSentAt: '2026-08-19T00:00:00.000Z' }, ['introSentAt']),
+ );
+ expect(mutationMock).not.toHaveBeenCalled();
+ expect(result).toEqual({});
+ });
+});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/on-opportunity-partner-won.test.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/on-opportunity-partner-won.test.ts
index b3336518b22..6cd2beca58a 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/on-opportunity-partner-won.test.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/on-opportunity-partner-won.test.ts
@@ -41,7 +41,7 @@ describe('on-opportunity-partner-won cascade', () => {
expect(queryMock).not.toHaveBeenCalled();
});
- it('on assign: winner -> WON, other active apps -> BACKUP, DECLINED untouched', async () => {
+ it('on assign: winner -> WON, every other contender -> DECLINED', async () => {
queryMock.mockResolvedValue(
apps(
{ id: 'app-win', partnerId: P_WIN, state: 'APPLIED' },
@@ -52,23 +52,56 @@ describe('on-opportunity-partner-won cascade', () => {
await handler(event({ id: OPP, partnerId: P_WIN }, ['partnerId']));
const updates = stateUpdates();
expect(updates).toContainEqual({ id: 'app-win', state: 'WON' });
- expect(updates).toContainEqual({ id: 'app-other', state: 'BACKUP' });
+ expect(updates).toContainEqual({ id: 'app-other', state: 'DECLINED' });
expect(updates.find((u) => u.id === 'app-declined')).toBeUndefined();
});
- it('on unassign: WON and BACKUP -> APPLIED, DECLINED untouched', async () => {
+ it('on assign: a losing BACKUP keeps its shortlist state', async () => {
queryMock.mockResolvedValue(
apps(
- { id: 'app-win', partnerId: P_WIN, state: 'WON' },
+ { id: 'app-win', partnerId: P_WIN, state: 'APPLIED' },
{ id: 'app-bk', partnerId: P_OTHER, state: 'BACKUP' },
- { id: 'app-declined', partnerId: 'p3', state: 'DECLINED' },
+ ),
+ );
+ await handler(event({ id: OPP, partnerId: P_WIN }, ['partnerId']));
+ const updates = stateUpdates();
+ expect(updates).toContainEqual({ id: 'app-win', state: 'WON' });
+ expect(updates.find((u) => u.id === 'app-bk')).toBeUndefined();
+ });
+
+ it('on assign: a winner sitting at BACKUP still moves to WON', async () => {
+ queryMock.mockResolvedValue(
+ apps({ id: 'app-win-was-backup', partnerId: P_WIN, state: 'BACKUP' }),
+ );
+ await handler(event({ id: OPP, partnerId: P_WIN }, ['partnerId']));
+ expect(stateUpdates()).toContainEqual({
+ id: 'app-win-was-backup',
+ state: 'WON',
+ });
+ });
+
+ it('on assign: a winner sitting at DECLINED still moves to WON (no longer frozen)', async () => {
+ queryMock.mockResolvedValue(
+ apps({ id: 'app-win-was-declined', partnerId: P_WIN, state: 'DECLINED' }),
+ );
+ await handler(event({ id: OPP, partnerId: P_WIN }, ['partnerId']));
+ const updates = stateUpdates();
+ expect(updates).toContainEqual({ id: 'app-win-was-declined', state: 'WON' });
+ });
+
+ it('on unassign: only WON -> APPLIED; DECLINED and BACKUP untouched', async () => {
+ queryMock.mockResolvedValue(
+ apps(
+ { id: 'app-win', partnerId: P_WIN, state: 'WON' },
+ { id: 'app-declined', partnerId: P_OTHER, state: 'DECLINED' },
+ { id: 'app-bk', partnerId: 'p3', state: 'BACKUP' },
),
);
await handler(event({ id: OPP, partnerId: null }, ['partnerId']));
const updates = stateUpdates();
expect(updates).toContainEqual({ id: 'app-win', state: 'APPLIED' });
- expect(updates).toContainEqual({ id: 'app-bk', state: 'APPLIED' });
expect(updates.find((u) => u.id === 'app-declined')).toBeUndefined();
+ expect(updates.find((u) => u.id === 'app-bk')).toBeUndefined();
});
it('does not rewrite an app already in its target state', async () => {
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/services/sync-application-outcomes.service.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/services/sync-application-outcomes.service.ts
index cad07c1c546..ce625bc9b34 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/services/sync-application-outcomes.service.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/matching/services/sync-application-outcomes.service.ts
@@ -4,9 +4,13 @@ import { collectAll } from 'src/modules/shared/utils/paginate.util';
import { listApplicationsByOpportunity } from 'src/modules/opportunity/matching/graphql/queries/list-applications-by-opportunity';
import { updateApplicationState } from 'src/modules/opportunity/matching/graphql/mutations/update-application-state';
-// WON/BACKUP mirror of Opportunity.partner: on assign, winner -> WON and other active apps ->
-// BACKUP; on unassign, WON/BACKUP -> APPLIED. DECLINED is never touched. Runs under the app
-// identity, bypassing partner locks.
+// WON/DECLINED mirror of Opportunity.partner: on assign, winner -> WON and every other
+// contender -> DECLINED (a loss); on unassign, only WON re-opens to APPLIED. Runs under the
+// app identity, bypassing partner locks.
+//
+// Two states stay out of the mirror. BACKUP is a standing shortlist set before the
+// introduction, so it survives the decision and its reversal. DECLINED is terminal because
+// an admin can also set it by hand — reopening it here would undo that call.
export async function syncApplicationOutcomes(
client: CoreApiClient,
params: { opportunityId: string; newPartnerId: string | null },
@@ -21,21 +25,18 @@ export async function syncApplicationOutcomes(
const setState = (id: string, state: string) => updateApplicationState(client, id, state);
if (newPartnerId) {
- // Winner -> WON; every other active (non-DECLINED) application -> BACKUP.
for (const node of applications) {
- if (node.state === 'DECLINED') continue;
- const target = node.partnerId === newPartnerId ? 'WON' : 'BACKUP';
+ const isWinner = node.partnerId === newPartnerId;
+ if (!isWinner && node.state === 'BACKUP') continue;
+ const target = isWinner ? 'WON' : 'DECLINED';
if (node.state !== target) await setState(node.id, target);
}
const winner = applications.find((node) => node.partnerId === newPartnerId);
return { won: winner?.id ?? null };
}
- // Unassigned: WON and BACKUP applications re-open to APPLIED. DECLINED untouched.
for (const node of applications) {
- if (node.state === 'WON' || node.state === 'BACKUP') {
- await setState(node.id, 'APPLIED');
- }
+ if (node.state === 'WON') await setState(node.id, 'APPLIED');
}
return { won: null, cleared: true };
}
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/navigation-menu-items/followup-briefs.navigation-menu-item.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/navigation-menu-items/followup-briefs.navigation-menu-item.ts
deleted file mode 100644
index b4a64afbc3d..00000000000
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/navigation-menu-items/followup-briefs.navigation-menu-item.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { NavigationMenuItemType, defineNavigationMenuItem } from 'twenty-sdk/define';
-
-import { FOLLOWUP_BRIEFS_VIEW_UNIVERSAL_IDENTIFIER } from 'src/modules/opportunity/views/followup-briefs.view';
-
-export default defineNavigationMenuItem({
- universalIdentifier: 'd4017fb3-0bfd-4099-94e8-e1ceffa8faca',
- type: NavigationMenuItemType.VIEW,
- icon: 'IconClockExclamation',
- position: 8,
- folderUniversalIdentifier: '0b2e499a-ae74-45e0-af08-243e19fc56aa',
- viewUniversalIdentifier: FOLLOWUP_BRIEFS_VIEW_UNIVERSAL_IDENTIFIER,
-});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/page-layouts/opportunity.page-layout.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/page-layouts/opportunity.page-layout.ts
index 7ef9ba82403..256f4657fed 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/page-layouts/opportunity.page-layout.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/page-layouts/opportunity.page-layout.ts
@@ -4,6 +4,9 @@ import {
definePageLayout,
} from 'twenty-sdk/define';
+import { APPLICATIONS_ON_OPPORTUNITY_FIELD_ID } from 'src/modules/application/objects/application.object';
+import { APPLICATIONS_WIDGET_VIEW_UNIVERSAL_IDENTIFIER } from 'src/modules/application/views/applications-widget.view';
+
const OPPORTUNITY_RECORD_PAGE_FIELDS_VIEW_ID =
STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.opportunity.views
.opportunityRecordPageFields.universalIdentifier;
@@ -34,6 +37,21 @@ export default definePageLayout({
viewUniversalIdentifier: OPPORTUNITY_RECORD_PAGE_FIELDS_VIEW_ID,
},
},
+ {
+ universalIdentifier: '6d634c81-c1a5-4c8d-9e96-c4bd049327f1',
+ title: 'Partners',
+ type: 'FIELD',
+ configuration: {
+ configurationType: 'FIELD',
+ // A FIELD widget in TABLE mode is the only configuration scoped to the parent
+ // record; a RECORD_TABLE widget would list every Application in the workspace.
+ // Both ids below are typed `string` instead of being renamed to
+ // `...UniversalIdentifier`, but the sync resolves them as universal identifiers.
+ fieldMetadataId: APPLICATIONS_ON_OPPORTUNITY_FIELD_ID,
+ fieldDisplayMode: 'TABLE',
+ viewId: APPLICATIONS_WIDGET_VIEW_UNIVERSAL_IDENTIFIER,
+ },
+ },
],
},
{
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/views/deals-board.view.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/views/deals-board.view.ts
index 5d58d4ee191..25ab42c146a 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/views/deals-board.view.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/views/deals-board.view.ts
@@ -1,6 +1,5 @@
import {
STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS,
- ViewFilterOperand,
ViewType,
defineView,
} from 'twenty-sdk/define';
@@ -98,12 +97,4 @@ export default defineView({
isVisible: true,
},
],
- filters: [
- {
- universalIdentifier: 'a536f770-ecc2-4046-822d-5b414ff1a7de',
- fieldMetadataUniversalIdentifier: PARTNER_ON_OPPORTUNITY_FIELD_ID,
- operand: ViewFilterOperand.IS_NOT_EMPTY,
- value: '',
- },
- ],
});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/views/followup-briefs.view.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/views/followup-briefs.view.ts
deleted file mode 100644
index 9cad56d2985..00000000000
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/opportunity/views/followup-briefs.view.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import {
- STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS,
- ViewFilterOperand,
- ViewType,
- defineView,
-} from 'twenty-sdk/define';
-
-import { OPPORTUNITY_IS_LISTED_FIELD_ID } from 'src/modules/opportunity/fields/opportunity-is-listed.field';
-import { OPPORTUNITY_NEED_FIELD_ID } from 'src/modules/opportunity/fields/opportunity-need.field';
-import { OPPORTUNITY_REQUIREMENTS_FIELD_ID } from 'src/modules/opportunity/fields/opportunity-requirements.field';
-import { PARTNER_ON_OPPORTUNITY_FIELD_ID } from 'src/modules/opportunity/fields/partner-on-opportunity.field';
-
-export const FOLLOWUP_BRIEFS_VIEW_UNIVERSAL_IDENTIFIER =
- '208374b1-ab8c-414a-ab6e-cf667e58e82c';
-
-const OPPORTUNITY_CREATED_AT_FIELD_ID =
- STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.opportunity.fields.createdAt
- .universalIdentifier;
-
-export default defineView({
- universalIdentifier: FOLLOWUP_BRIEFS_VIEW_UNIVERSAL_IDENTIFIER,
- name: 'Follow-up · Briefs',
- icon: 'IconClockExclamation',
- objectUniversalIdentifier:
- STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.opportunity.universalIdentifier,
- type: ViewType.TABLE,
- position: 4,
- fields: [
- {
- universalIdentifier: '6c05d4b4-9a9e-4aa6-b3be-b0b2eeec1247',
- fieldMetadataUniversalIdentifier:
- STANDARD_OBJECT_UNIVERSAL_IDENTIFIERS.opportunity.fields.name
- .universalIdentifier,
- position: 0,
- isVisible: true,
- size: 200,
- },
- {
- universalIdentifier: '3bb4a39b-db7f-4976-84ce-983263fc1d39',
- fieldMetadataUniversalIdentifier: OPPORTUNITY_NEED_FIELD_ID,
- position: 1,
- isVisible: true,
- size: 280,
- },
- {
- universalIdentifier: 'e74e0e43-ae5f-4548-a9c1-a24775f94650',
- fieldMetadataUniversalIdentifier: OPPORTUNITY_REQUIREMENTS_FIELD_ID,
- position: 2,
- isVisible: true,
- size: 280,
- },
- {
- universalIdentifier: '76005fd9-2501-4004-bc92-bcbe3cb7927f',
- fieldMetadataUniversalIdentifier: OPPORTUNITY_CREATED_AT_FIELD_ID,
- position: 3,
- isVisible: true,
- size: 180,
- },
- ],
- filters: [
- {
- universalIdentifier: 'aca50fdf-e3a7-417c-ba28-411ac67c952a',
- fieldMetadataUniversalIdentifier: OPPORTUNITY_IS_LISTED_FIELD_ID,
- operand: ViewFilterOperand.IS,
- value: 'true',
- },
- {
- universalIdentifier: 'fb283e36-abab-4764-ba19-c9761eb82e57',
- fieldMetadataUniversalIdentifier: PARTNER_ON_OPPORTUNITY_FIELD_ID,
- operand: ViewFilterOperand.IS_EMPTY,
- value: '',
- },
- // TODO(B5): add createdAt > 7d relative filter once operand form confirmed
- ],
-});
diff --git a/packages/twenty-apps/internal/twenty-partners/src/modules/partner/directory/page-layouts/partner.page-layout.ts b/packages/twenty-apps/internal/twenty-partners/src/modules/partner/directory/page-layouts/partner.page-layout.ts
index e2b3eddb04a..08972d49338 100644
--- a/packages/twenty-apps/internal/twenty-partners/src/modules/partner/directory/page-layouts/partner.page-layout.ts
+++ b/packages/twenty-apps/internal/twenty-partners/src/modules/partner/directory/page-layouts/partner.page-layout.ts
@@ -1,6 +1,8 @@
import { PageLayoutTabLayoutMode, definePageLayout } from 'twenty-sdk/define';
import { PARTNER_OBJECT_UNIVERSAL_IDENTIFIER } from 'src/constants/universal-identifiers';
+import { APPLICATIONS_ON_PARTNER_FIELD_ID } from 'src/modules/application/objects/application.object';
+import { APPLICATIONS_WIDGET_VIEW_UNIVERSAL_IDENTIFIER } from 'src/modules/application/views/applications-widget.view';
import { PARTNER_RECORD_PAGE_FIELDS_VIEW_ID } from 'src/modules/partner/directory/views/partner-record-page-fields.view';
// Partner is a custom (app-owned) object, so we fully control its record page. The
@@ -30,6 +32,30 @@ export default definePageLayout({
},
],
},
+ {
+ universalIdentifier: '3061f017-11ea-4082-99d8-e17ec384c741',
+ title: 'Briefs',
+ position: 15,
+ icon: 'IconBriefcase',
+ layoutMode: PageLayoutTabLayoutMode.VERTICAL_LIST,
+ widgets: [
+ {
+ universalIdentifier: 'b8e9aae6-d0d8-4902-9031-a7530c70229a',
+ title: 'Briefs',
+ type: 'FIELD',
+ configuration: {
+ configurationType: 'FIELD',
+ // A FIELD widget in TABLE mode is the only configuration scoped to the parent
+ // record; a RECORD_TABLE widget would list every Application in the workspace.
+ // Both ids below are typed `string` instead of being renamed to
+ // `...UniversalIdentifier`, but the sync resolves them as universal identifiers.
+ fieldMetadataId: APPLICATIONS_ON_PARTNER_FIELD_ID,
+ fieldDisplayMode: 'TABLE',
+ viewId: APPLICATIONS_WIDGET_VIEW_UNIVERSAL_IDENTIFIER,
+ },
+ },
+ ],
+ },
{
universalIdentifier: '2f59d88d-d07b-4a34-9e95-c8c6eea2522b',
title: 'Timeline',