diff --git a/apps/client-ts/src/components/Configuration/AddAuthCredentialsForm.tsx b/apps/client-ts/src/components/Configuration/AddAuthCredentialsForm.tsx index b0cc78bee..30f2c2406 100644 --- a/apps/client-ts/src/components/Configuration/AddAuthCredentialsForm.tsx +++ b/apps/client-ts/src/components/Configuration/AddAuthCredentialsForm.tsx @@ -373,7 +373,7 @@ const AddAuthCredentialsForm = (prop : propType) => { Add 0Auth Credentials - Add your provider's credentials for connection. + Add your provider' credentials for connection. diff --git a/apps/client-ts/src/components/Configuration/RevealCredentialsCard.tsx b/apps/client-ts/src/components/Configuration/RevealCredentialsCard.tsx deleted file mode 100644 index 169466860..000000000 --- a/apps/client-ts/src/components/Configuration/RevealCredentialsCard.tsx +++ /dev/null @@ -1,106 +0,0 @@ -import React,{useState} from 'react' -import { - Dialog, - DialogContent, - DialogTrigger, - } from "@/components/ui/dialog" -import { Badge,badgeVariants } from "@/components/ui/badge" -import { - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, - } from "@/components/ui/card" -import useProjectStore from "@/state/projectStore"; -import { Input } from '@/components/ui/input'; -import {Skeleton} from '@/components/ui/skeleton' -import useAuthCredentials from '@/hooks/useAuthCredentials'; -import { AuthStrategy } from '@panora/shared'; - -interface propType { - data: { - status: boolean; - provider_name: string; - auth_type: number; - id_cs: string; - vertical: string; - type: string; - } - - -} - -const RevealCredentialsCard = (data : propType) => { - - const {type,auth_type} = data.data - const {idProject} = useProjectStore(); - - const {data: authCredentialsData, isLoading: isAuthCredentialsLoading,error: isAuthCredentialsError} = useAuthCredentials( - idProject, - type, - auth_type===AuthStrategy.oauth2? ["client_id","client_secret"] : auth_type===AuthStrategy.api_key? ["api_key"] : ["username","secret"] - ) - - if(authCredentialsData) - { - console.log(authCredentialsData) - } - - - if(isAuthCredentialsError) - { - console.log("error in AuthCredentials Fetching!!") - } - - - const [open, setOpen] = useState(false); - // const [loading,setLoading] = useState(true); - - return ( - - - Reveal Credentials - - - - Credentials - - - - {/*
{JSON.stringify(data.data)}
*/} - - {isAuthCredentialsLoading && ( -
-
- - - - - - -
-
- )} - - - - {authCredentialsData && ( - <> -
{authCredentialsData.authValues}
- - )} - - - - - -
- -
- -
- ) -} - -export default RevealCredentialsCard \ No newline at end of file diff --git a/apps/client-ts/src/components/Configuration/authColumns.tsx b/apps/client-ts/src/components/Configuration/authColumns.tsx index 3943a6bf8..2054ecc91 100644 --- a/apps/client-ts/src/components/Configuration/authColumns.tsx +++ b/apps/client-ts/src/components/Configuration/authColumns.tsx @@ -28,12 +28,81 @@ import { import { DotsHorizontalIcon, } from "@radix-ui/react-icons" -import RevealCredentialsCard from "./RevealCredentialsCard"; import AddAuthCredentialsForm from "./AddAuthCredentialsForm"; import {getLogoURL,AuthStrategy} from '@panora/shared' import useUpdateConnectionStrategyMutation from "@/hooks/mutations/useUpdateConnectionStrategy"; import useDeleteConnectionStrategyMutation from "@/hooks/mutations/useDeleteConnectionStrategy"; +const UpdateStatusCellComponent = ({row}:{row:any}) => { + const [isDisable,setDisable] = useState(false) + const {mutate} = useUpdateConnectionStrategyMutation() + const onSwitchChange = () => { + setDisable(true) + mutate( + { + id_cs:row.original.id_cs, + ToUpdateToggle:true + }, { + onSuccess : () => setDisable(false), + onError : () => setDisable(false) + }) + // console.log("Changed switch") + } + + return ( +
+ {/* {row.getValue("activate")==false ? "Deactivated" : "Activated"} */} + onSwitchChange()} disabled={isDisable} value={row.getValue("status")} defaultChecked={row.getValue("status")}/> +
+ ) +} + +const ActionCellComponent = ({row}:{row:any}) => { + + const [open,setOpen] = useState(false) + + const handleOpenChange = (open: boolean) => { + setOpen(open) + // form.reset() + }; + + const {mutate} = useDeleteConnectionStrategyMutation() + + const deleteConnectionStrategy = () => { + mutate( + { + id_cs:row.original.id_cs + } + ) + } + + return ( + + + + + + + + Edit + + + deleteConnectionStrategy()}>Delete + + + + + setOpen(false)} performUpdate={true} /> + + + + ) + +} + export const authColumns: ColumnDef[] = [ { // acc: 'provider_name', @@ -93,38 +162,7 @@ export const authColumns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row }) => { - - const [isDisable,setDisable] = useState(false) - - const {mutate} = useUpdateConnectionStrategyMutation() - - - - const onSwitchChange = () => { - setDisable(true) - mutate( - { - id_cs:row.original.id_cs, - ToUpdateToggle:true - }, { - onSuccess : () => setDisable(false), - onError : () => setDisable(false) - }) - // console.log("Changed switch") - } - - - - - return ( -
- {/* {row.getValue("activate")==false ? "Deactivated" : "Activated"} */} - onSwitchChange()} disabled={isDisable} value={row.getValue("status")} defaultChecked={row.getValue("status")}/> -
- ) - }, - + cell: UpdateStatusCellComponent }, @@ -134,54 +172,9 @@ export const authColumns: ColumnDef[] = [ header: ({ column }) => ( ), - cell: ({ row }) => { - - const [open,setOpen] = useState(false) - - const handleOpenChange = (open: boolean) => { - setOpen(open) - // form.reset() - }; - - const {mutate} = useDeleteConnectionStrategyMutation() - - const deleteConnectionStrategy = () => { - mutate( - { - id_cs:row.original.id_cs - } - ) - } - - - return ( - - - - - - - - Edit - - - deleteConnectionStrategy()}>Delete - - + cell: ({ row }) => ActionCellComponent + + }, - - setOpen(false)} performUpdate={true} /> - - +] - ) - }, - // filterFn: (row, id, value) => { - // return value.includes(row.getValue(id)) - // }, - }, - -] \ No newline at end of file diff --git a/packages/shared/src/providers.ts b/packages/shared/src/providers.ts index a16199bda..37aef631b 100644 --- a/packages/shared/src/providers.ts +++ b/packages/shared/src/providers.ts @@ -37,8 +37,8 @@ export function getProviderVertical(providerName: string): ProviderVertical { return ProviderVertical.Unknown; } -function mergeAllProviders(...arrays) { - const result = []; +function mergeAllProviders(...arrays: string[][]): { vertical: string, value: string }[] { + const result: { vertical: string, value: string }[] = []; arrays.forEach((arr, index) => { const arrayName = Object.keys({ CRM_PROVIDERS, HRIS_PROVIDERS, ATS_PROVIDERS, ACCOUNTING_PROVIDERS, TICKETING_PROVIDERS, MARKETING_AUTOMATION_PROVIDERS, FILE_STORAGE_PROVIDERS })[index]; arr.forEach(item => { diff --git a/packages/shared/src/utils.ts b/packages/shared/src/utils.ts index 69fa7d224..64823f8e3 100644 --- a/packages/shared/src/utils.ts +++ b/packages/shared/src/utils.ts @@ -1691,7 +1691,11 @@ export function findProviderByName(providerName: string): Provider | null { export function getLogoURL(providerName: string): string { const vertical = findProviderVertical(providerName); - return providersConfig[vertical][providerName].logoPath + if (vertical !== null) { + return providersConfig[vertical][providerName].logoPath + } + + return "" } \ No newline at end of file