: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { MakeLogicType, actions, connect, kea, key, path, props, reducers } from 'kea'
import { loaders } from 'kea-loaders'
import api from 'lib/api'
import type { OrganizationType } from '../../types'
import { type ResourceTransferLogicProps, type SearchResponse, resourceTransferLogic } from './resourceTransferLogic'
export interface ResourceTransferRowLogicProps {
resourceKey: string
transferLogicProps: ResourceTransferLogicProps
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface resourceTransferRowLogicValues {
currentOrganization: OrganizationType | null // resourceTransferLogic
destinationTeamId: number | null // resourceTransferLogic
isSearching: boolean
searchResults: SearchResponse | null
searchResultsLoading: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface resourceTransferRowLogicActions {
searchResources: (
resourceKind: string,
query: string
) => {
query: string
resourceKind: string
}
searchResourcesFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
searchResourcesSuccess: (
searchResults: SearchResponse,
payload?: {
query: string
resourceKind: string
}
) => {
searchResults: SearchResponse
payload?: {
query: string
resourceKind: string
}
}
setIsSearching: (isSearching: boolean) => {
isSearching: boolean
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface resourceTransferRowLogicMeta {
key: string
}
export type resourceTransferRowLogicType = MakeLogicType<
resourceTransferRowLogicValues,
resourceTransferRowLogicActions,
ResourceTransferRowLogicProps,
resourceTransferRowLogicMeta
>
export const resourceTransferRowLogic = kea<resourceTransferRowLogicType>([
path(['scenes', 'resource-transfer', 'resourceTransferRowLogic']),
props({} as ResourceTransferRowLogicProps),
key((props) => props.resourceKey),
connect((props: ResourceTransferRowLogicProps) => ({
values: [resourceTransferLogic(props.transferLogicProps), ['destinationTeamId', 'currentOrganization']],
})),
actions({
setIsSearching: (isSearching: boolean) => ({ isSearching }),
searchResources: (resourceKind: string, query: string) => ({ resourceKind, query }),
}),
reducers({
isSearching: [
false,
{
setIsSearching: (_, { isSearching }) => isSearching,
},
],
}),
loaders(({ values }) => ({
searchResults: [
null as SearchResponse | null,
{
searchResources: async ({ resourceKind, query }) => {
const { destinationTeamId, currentOrganization } = values
if (!destinationTeamId || !currentOrganization) {
throw new Error('Missing required fields for search')
}
// nosemgrep: prefer-codegen-api -- Legacy raw API call with a hand-written URL and an unchecked response type. No generated function covers this endpoint yet. Find out why the generated client skips it (no schema, no product tag, or excluded from the spec) and fix that first.
return await api.create<SearchResponse>(
`api/organizations/${currentOrganization.id}/resource_transfers/search/`,
{
team_id: destinationTeamId,
resource_kind: resourceKind,
q: query,
}
)
},
},
],
})),
])