Skip to content

Commit

Permalink
✨ Updated webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Feb 10, 2024
1 parent efe7b06 commit 3f5adb5
Show file tree
Hide file tree
Showing 32 changed files with 125 additions and 93 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-jeans-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@panora/shared": major
---

updated constants
5 changes: 3 additions & 2 deletions apps/webapp/src/components/api-keys/data/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { DataTableColumnHeader } from "../../shared/data-table-column-header"
import { DataTableRowActions } from "../../shared/data-table-row-actions"

function insertDots(originalString: string): string {
if(!originalString) return "";
if (originalString.length <= 50) {
return originalString;
}
return originalString.substring(0, 50 - 3) + '...';
}
return originalString.substring(0, 50 - 3) + '...';
}

export const columns: ColumnDef<ApiKey>[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import useMapFieldMutation from "@/hooks/mutations/useMapFieldMutation"
import { useEffect, useState } from "react"
import useFieldMappings from "@/hooks/useFieldMappings"
import useProviderProperties from "@/hooks/useProviderProperties"
import { standardOjects } from "@panora/shared"
import { standardObjects } from "@panora/shared"
import useProjectStore from "@/state/projectStore"
import useLinkedUsers from "@/hooks/useLinkedUsers"
import { zodResolver } from "@hookform/resolvers/zod"
Expand Down Expand Up @@ -181,8 +181,8 @@ export function FModal({ onClose }: {onClose: () => void}) {
</SelectTrigger>
<SelectContent>
<SelectGroup>
{standardOjects && standardOjects
.map(sObject => (
{standardObjects && standardObjects
.map((sObject: string) => (
<SelectItem key={sObject} value={sObject}>{sObject}</SelectItem>
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ export function WebhooksPage({
mutate({
id: webhook_id,
active: status,
});
}, {
onSuccess: () => {
// Find the index of the webhook to update
const index = webhooks!.findIndex(webhook => webhook.id_webhook_endpoint === webhook_id);
if (index !== -1) {
// Create a new array with all previous webhooks
const updatedWebhooks = [...webhooks!];
// Update the specific webhook's active status
updatedWebhooks[index].active = status;
// Set the updated webhooks array to state
setWebhooks(updatedWebhooks);
}
}
});
}

useEffect(() => {
Expand Down Expand Up @@ -65,7 +78,8 @@ export function WebhooksPage({
id="necessary"
checked={webhook.active}
onCheckedChange={() => disableWebhook(webhook.id_webhook_endpoint, !webhook.active)}
/>}
/>
}
</div>
</div>
)
Expand Down
11 changes: 3 additions & 8 deletions apps/webapp/src/components/connections/components/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Checkbox } from "@/components/ui/checkbox"

import { Connection } from "../data/schema"
import { DataTableColumnHeader } from "../../shared/data-table-column-header"
import { DataTableRowActions } from "../../shared/data-table-row-actions"

function truncateMiddle(str: string, maxLength: number) {
if (str.length <= maxLength) {
Expand Down Expand Up @@ -54,15 +53,15 @@ export const columns: ColumnDef<Connection>[] = [
enableHiding: false,
},
{
accessorKey: "app",
accessorKey: "app",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="App" />
),
cell: ({ row }) => {
const provider = (row.getValue("app") as string).toLowerCase();
return (
<div className="flex space-x-2">
<Badge variant={"outline"} className="bg-neutral-950 p-1 pr-2">
<Badge variant={"outline"} className="p-1 pr-2">
<img src={
provider == "hubspot" ?
`/providers/crm/${provider}.jpg` :
Expand Down Expand Up @@ -158,9 +157,5 @@ export const columns: ColumnDef<Connection>[] = [
</div>
)
},
},
{
id: "actions",
cell: ({ row }) => <DataTableRowActions row={row} />,
},
}
]
16 changes: 0 additions & 16 deletions apps/webapp/src/components/connections/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Button } from "../ui/button";
import ConnectionTable from "./ConnectionTable";
import { toast } from "sonner"

export default function ConnectionsPage() {
return (
Expand All @@ -9,20 +7,6 @@ export default function ConnectionsPage() {
<div className="flex flex-col items-start justify-between space-y-2">
<h2 className="text-3xl font-bold tracking-tight">Connections</h2>
<h2 className="text-lg font-bold tracking-tight">Connections between your product and your users’ accounts on third-party software.</h2>
<Button
variant="outline"
onClick={() =>
toast("Event has been created", {
description: "Sunday, December 03, 2023 at 9:00 AM",
action: {
label: "Undo",
onClick: () => console.log("Undo"),
},
})
}
>
Show Toast
</Button>
</div>
<ConnectionTable />
</div>
Expand Down
11 changes: 7 additions & 4 deletions apps/webapp/src/hooks/mutations/useApiKeyMutation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import config from '@/utils/config';
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from "sonner"

interface IApiKeyDto {
Expand All @@ -8,9 +8,9 @@ interface IApiKeyDto {
keyName?: string;
}
const useApiKeyMutation = () => {
const addApiKey = async (data: IApiKeyDto) => {
console.log("user id is " + data.userId )
const queryClient = useQueryClient();

const addApiKey = async (data: IApiKeyDto) => {
//TODO: in cloud environment this step must be done when user logs in directly inside his dashboard
// Fetch the token
const loginResponse = await fetch(`${config.API_URL}/auth/login`, {
Expand Down Expand Up @@ -61,7 +61,10 @@ const useApiKeyMutation = () => {
},
})
},
onSuccess: () => {
onSuccess: (data) => {
queryClient.setQueryData<IApiKeyDto[]>(['api-keys'], (oldQueryData = []) => {
return [...oldQueryData, data];
});
toast("Api key has been generated !", {
description: "",
action: {
Expand Down
9 changes: 7 additions & 2 deletions apps/webapp/src/hooks/mutations/useDefineFieldMutation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import config from '@/utils/config';
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from "sonner"

interface IDefineTargetFieldDto{
Expand All @@ -10,6 +10,8 @@ interface IDefineTargetFieldDto{
}

const useDefineFieldMutation = () => {
const queryClient = useQueryClient()

const defineField = async (data: IDefineTargetFieldDto) => {
const response = await fetch(`${config.API_URL}/field-mapping/define`, {
method: 'POST',
Expand Down Expand Up @@ -45,7 +47,10 @@ const useDefineFieldMutation = () => {
},
})
},
onSuccess: () => {
onSuccess: (data) => {
queryClient.setQueryData<IDefineTargetFieldDto[]>(['mappings'], (oldQueryData = []) => {
return [...oldQueryData, data];
});
toast("Field mapping has been defined !", {
description: "",
action: {
Expand Down
13 changes: 9 additions & 4 deletions apps/webapp/src/hooks/mutations/useLinkedUserMutation.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import config from '@/utils/config';
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from "sonner"
interface ICreateTargetFieldDto {
interface ILinkedUserDto {
linked_user_origin_id: string;
alias: string;
id_project: string;
}
const useLinkedUserMutation = () => {
const addLinkedUser = async (linkedUserData: ICreateTargetFieldDto) => {
const queryClient = useQueryClient();

const addLinkedUser = async (linkedUserData: ILinkedUserDto) => {
const response = await fetch(`${config.API_URL}/linked-users/create`, {
method: 'POST',
body: JSON.stringify(linkedUserData),
Expand Down Expand Up @@ -42,7 +44,10 @@ const useLinkedUserMutation = () => {
},
})
},
onSuccess: () => {
onSuccess: (data) => {
queryClient.setQueryData<ILinkedUserDto[]>(['linked-users'], (oldQueryData = []) => {
return [...oldQueryData, data];
});
toast("New linked user has been created !", {
description: "",
action: {
Expand Down
5 changes: 4 additions & 1 deletion apps/webapp/src/hooks/mutations/useOrganisationMutation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ const useOrganisationMutation = () => {
},
})
},
onSuccess: () => {
onSuccess: (data) => {
queryClient.setQueryData<IOrgDto[]>(['organisations'], (oldQueryData = []) => {
return [...oldQueryData, data];
});
queryClient.invalidateQueries({
queryKey: ['organisations'],
refetchType: 'active',
Expand Down
10 changes: 7 additions & 3 deletions apps/webapp/src/hooks/mutations/useProjectMutation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import config from '@/utils/config';
import { useMutation,useQueryClient } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from "sonner"

interface IProDto {
Expand All @@ -8,7 +8,8 @@ interface IProDto {
}

const useProjectMutation = () => {
const queryClient = useQueryClient()
const queryClient = useQueryClient();

const addProject = async (data: IProDto) => {
const response = await fetch(`${config.API_URL}/projects/create`, {
method: 'POST',
Expand Down Expand Up @@ -44,11 +45,14 @@ const useProjectMutation = () => {
},
})
},
onSuccess: () => {
onSuccess: (data) => {
queryClient.invalidateQueries({
queryKey: ['projects'],
refetchType: 'active',
})
queryClient.setQueryData<IProDto[]>(['projects'], (oldQueryData = []) => {
return [...oldQueryData, data];
});
toast("Project has been created !", {
description: "",
action: {
Expand Down
8 changes: 6 additions & 2 deletions apps/webapp/src/hooks/mutations/useWebhookMutation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import config from '@/utils/config';
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from "sonner"

interface IWebhookDto {
Expand All @@ -9,6 +9,7 @@ interface IWebhookDto {
scope: string[];
}
const useWebhookMutation = () => {
const queryClient = useQueryClient();
const addWebhookEndpoint = async (data: IWebhookDto) => {
const response = await fetch(`${config.API_URL}/webhook`, {
method: 'POST',
Expand Down Expand Up @@ -44,7 +45,10 @@ const useWebhookMutation = () => {
},
})
},
onSuccess: () => {
onSuccess: (data) => {
queryClient.setQueryData<IWebhookDto[]>(['webhooks'], (oldQueryData = []) => {
return [...oldQueryData, data];
});
toast("Webhook endpoint has been created! ", {
description: "",
action: {
Expand Down
20 changes: 0 additions & 20 deletions apps/webapp/src/hooks/mutations/useWebhookUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ const useWebhookStatusMutation = () => {
};
return useMutation({
mutationFn: updateStatusWebhookEndpoint,
onMutate: () => {
toast("Webhook endpoint is being updated !", {
description: "",
action: {
label: "Close",
onClick: () => console.log("Close"),
},
})
},
onError: (error) => {
toast("Webhook endpoint update has failed !", {
description: error.message,
Expand All @@ -42,17 +33,6 @@ const useWebhookStatusMutation = () => {
},
})
},
onSuccess: () => {
toast("Webhook endpoint has been updated !", {
description: "",
action: {
label: "Close",
onClick: () => console.log("Close"),
},
})
},
onSettled: () => {
},
});
};

Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/crm/company/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class SyncService implements OnModuleInit {
await this.fieldMappingService.getCustomFieldMappings(
integrationId,
linkedUserId,
'company',
'ticketing.company',
);
const remoteProperties: string[] = customFieldMappings.map(
(mapping) => mapping.remote_id,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/crm/contact/services/contact.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class ContactService {
await this.fieldMappingService.getCustomFieldMappings(
integrationId,
linkedUserId,
'contact',
'crm.contact',
);
//desunify the data according to the target obj wanted
const desunifiedObject = await desunify<UnifiedContactInput>({
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/crm/contact/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class SyncContactsService implements OnModuleInit {
await this.fieldMappingService.getCustomFieldMappings(
integrationId,
linkedUserId,
'contact',
'crm.contact',
);
const remoteProperties: string[] = customFieldMappings.map(
(mapping) => mapping.remote_id,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/crm/deal/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class SyncService implements OnModuleInit {
await this.fieldMappingService.getCustomFieldMappings(
integrationId,
linkedUserId,
'deal',
'crm.deal',
);
const remoteProperties: string[] = customFieldMappings.map(
(mapping) => mapping.remote_id,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/crm/engagement/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class SyncService implements OnModuleInit {
await this.fieldMappingService.getCustomFieldMappings(
integrationId,
linkedUserId,
'engagement',
'crm.engagement',
);
const remoteProperties: string[] = customFieldMappings.map(
(mapping) => mapping.remote_id,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/crm/note/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class SyncService implements OnModuleInit {
await this.fieldMappingService.getCustomFieldMappings(
integrationId,
linkedUserId,
'note',
'crm.note',
);
const remoteProperties: string[] = customFieldMappings.map(
(mapping) => mapping.remote_id,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/crm/stage/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class SyncService implements OnModuleInit {
await this.fieldMappingService.getCustomFieldMappings(
integrationId,
linkedUserId,
'stage',
'crm.stage',
);
const remoteProperties: string[] = customFieldMappings.map(
(mapping) => mapping.remote_id,
Expand Down
Loading

0 comments on commit 3f5adb5

Please sign in to comment.