Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

4.3 KB
Raw Blame
import { MakeLogicType, actions, kea, key, path, props } from 'kea'
import { loaders } from 'kea-loaders'

import api from 'lib/api'

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface clickupIntegrationLogicValues {
    clickUpLists:
        | {
              id: string
              name: string
          }[]
        | null
    clickUpListsLoading: boolean
    clickUpSpaces:
        | {
              id: string
              name: string
          }[]
        | null
    clickUpSpacesLoading: boolean
    clickUpWorkspaces:
        | {
              id: string
              name: string
          }[]
        | null
    clickUpWorkspacesLoading: boolean
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface clickupIntegrationLogicActions {
    loadClickUpLists: (spaceId: string) => {
        spaceId: string
    }
    loadClickUpListsFailure: (
        error: string,
        errorObject?: any
    ) => {
        error: string
        errorObject?: any
    }
    loadClickUpListsSuccess: (
        clickUpLists: {
            id: string
            name: string
        }[],
        payload?: {
            spaceId: string
        }
    ) => {
        clickUpLists: {
            id: string
            name: string
        }[]
        payload?: {
            spaceId: string
        }
    }
    loadClickUpSpaces: (workspaceId: string) => {
        workspaceId: string
    }
    loadClickUpSpacesFailure: (
        error: string,
        errorObject?: any
    ) => {
        error: string
        errorObject?: any
    }
    loadClickUpSpacesSuccess: (
        clickUpSpaces: {
            id: string
            name: string
        }[],
        payload?: {
            workspaceId: string
        }
    ) => {
        clickUpSpaces: {
            id: string
            name: string
        }[]
        payload?: {
            workspaceId: string
        }
    }
    loadClickUpWorkspaces: () => {
        value: true
    }
    loadClickUpWorkspacesFailure: (
        error: string,
        errorObject?: any
    ) => {
        error: string
        errorObject?: any
    }
    loadClickUpWorkspacesSuccess: (
        clickUpWorkspaces: {
            id: string
            name: string
        }[],
        payload?: {
            value: true
        }
    ) => {
        clickUpWorkspaces: {
            id: string
            name: string
        }[]
        payload?: {
            value: true
        }
    }
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface clickupIntegrationLogicProps {
    id: number
}

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface clickupIntegrationLogicMeta {
    key: number
}

export type clickupIntegrationLogicType = MakeLogicType<
    clickupIntegrationLogicValues,
    clickupIntegrationLogicActions,
    clickupIntegrationLogicProps,
    clickupIntegrationLogicMeta
>

export const clickupIntegrationLogic = kea<clickupIntegrationLogicType>([
    props({} as { id: number }),
    key((props) => props.id),
    path((key) => ['lib', 'integrations', 'clickupIntegrationLogic', key]),
    actions({
        loadClickUpLists: (spaceId: string) => ({ spaceId }),
        loadClickUpSpaces: (workspaceId: string) => ({ workspaceId }),
        loadClickUpWorkspaces: true,
    }),
    loaders(({ props }) => ({
        clickUpSpaces: [
            null as { id: string; name: string }[] | null,
            {
                loadClickUpSpaces: async ({ workspaceId }) => {
                    const res = await api.integrations.clickUpSpaces(props.id, workspaceId)
                    return res.spaces
                },
            },
        ],
        clickUpLists: [
            null as { id: string; name: string }[] | null,
            {
                loadClickUpLists: async ({ spaceId }) => {
                    const res = await api.integrations.clickUpLists(props.id, spaceId)
                    return res.lists
                },
            },
        ],
        clickUpWorkspaces: [
            null as { id: string; name: string }[] | null,
            {
                loadClickUpWorkspaces: async () => {
                    const res = await api.integrations.clickUpWorkspaces(props.id)
                    return res.workspaces
                },
            },
        ],
    })),
])