Skip to content

Commit

Permalink
🚑️ Optimize for build
Browse files Browse the repository at this point in the history
  • Loading branch information
mit-27 committed Apr 17, 2024
1 parent 5e0e307 commit 03b02e0
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ const AddAuthCredentialsForm = (prop : propType) => {
<CardHeader>
<CardTitle>Add 0Auth Credentials</CardTitle>
<CardDescription>
Add your provider's credentials for connection.
Add your provider&apos; credentials for connection.
</CardDescription>
</CardHeader>
<CardContent className="grid gap-5">
Expand Down
106 changes: 0 additions & 106 deletions apps/client-ts/src/components/Configuration/RevealCredentialsCard.tsx

This file was deleted.

157 changes: 75 additions & 82 deletions apps/client-ts/src/components/Configuration/authColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="flex w-[100px] items-center">
{/* <Badge variant={row.getValue("activate")==false ? "destructive" : "primary"}>{row.getValue("activate")==false ? "Deactivated" : "Activated"}</Badge> */}
<Switch onCheckedChange={() => onSwitchChange()} disabled={isDisable} value={row.getValue("status")} defaultChecked={row.getValue("status")}/>
</div>
)
}

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 (
<Dialog open={open} onOpenChange={handleOpenChange}>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="h-8 w-8 p-0">
<span className="sr-only">Open menu</span>
<DotsHorizontalIcon className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DialogTrigger asChild>
<DropdownMenuItem>Edit</DropdownMenuItem>
</DialogTrigger>

<DropdownMenuItem onClick={() => deleteConnectionStrategy()}>Delete</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>

<DialogContent className="sm:w-[450px] lg:max-w-screen-lg overflow-y-scroll max-h-screen">
<AddAuthCredentialsForm data={row.original} closeDialog={() => setOpen(false)} performUpdate={true} />
</DialogContent>
</Dialog>

)

}

export const authColumns: ColumnDef<Mapping>[] = [
{
// acc: 'provider_name',
Expand Down Expand Up @@ -93,38 +162,7 @@ export const authColumns: ColumnDef<Mapping>[] = [
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Status" />
),
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 (
<div className="flex w-[100px] items-center">
{/* <Badge variant={row.getValue("activate")==false ? "destructive" : "primary"}>{row.getValue("activate")==false ? "Deactivated" : "Activated"}</Badge> */}
<Switch onCheckedChange={() => onSwitchChange()} disabled={isDisable} value={row.getValue("status")} defaultChecked={row.getValue("status")}/>
</div>
)
},

cell: UpdateStatusCellComponent
},


Expand All @@ -134,54 +172,9 @@ export const authColumns: ColumnDef<Mapping>[] = [
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Action" />
),
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 (
<Dialog open={open} onOpenChange={handleOpenChange}>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="h-8 w-8 p-0">
<span className="sr-only">Open menu</span>
<DotsHorizontalIcon className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DialogTrigger asChild>
<DropdownMenuItem>Edit</DropdownMenuItem>
</DialogTrigger>

<DropdownMenuItem onClick={() => deleteConnectionStrategy()}>Delete</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
cell: ({ row }) => ActionCellComponent

},

<DialogContent className="sm:w-[450px] lg:max-w-screen-lg overflow-y-scroll max-h-screen">
<AddAuthCredentialsForm data={row.original} closeDialog={() => setOpen(false)} performUpdate={true} />
</DialogContent>
</Dialog>
]

)
},
// filterFn: (row, id, value) => {
// return value.includes(row.getValue(id))
// },
},

]
4 changes: 2 additions & 2 deletions packages/shared/src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
6 changes: 5 additions & 1 deletion packages/shared/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""


}

0 comments on commit 03b02e0

Please sign in to comment.