0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-31 22:51:25 -05:00

refactor: rename existing connectors

This commit is contained in:
wangsijie 2022-11-29 14:53:29 +08:00
parent 356aeabb54
commit 3b52af56e0
No known key found for this signature in database
GPG key ID: 1EA50084233D66BE

View file

@ -24,20 +24,21 @@ type Props = {
};
const CreateForm = ({ onClose, isOpen: isFormOpen, type }: Props) => {
const { data: connectors, error: connectorsError } = useSWR<ConnectorResponse[], RequestError>(
'/api/connectors'
);
const { data: existingConnectors, error: connectorsError } = useSWR<
ConnectorResponse[],
RequestError
>('/api/connectors');
const { data: factories, error: factoriesError } = useSWR<
ConnectorFactoryResponse[],
RequestError
>('/api/connector-factories');
const isLoading = !factories && !connectors && !connectorsError && !factoriesError;
const isLoading = !factories && !existingConnectors && !connectorsError && !factoriesError;
const [activeGroupId, setActiveGroupId] = useState<string>();
const [activeFactoryId, setActiveFactoryId] = useState<string>();
const [isGetStartedModalOpen, setIsGetStartedModalOpen] = useState(false);
const groups = useMemo(() => {
if (!factories || !connectors) {
if (!factories || !existingConnectors) {
return [];
}
@ -49,10 +50,10 @@ const CreateForm = ({ onClose, isOpen: isFormOpen, type }: Props) => {
...group,
connectors: group.connectors.map((connector) => ({
...connector,
added: connectors.some(({ connectorId }) => connector.id === connectorId),
added: existingConnectors.some(({ connectorId }) => connector.id === connectorId),
})),
}));
}, [factories, type, connectors]);
}, [factories, type, existingConnectors]);
const activeGroup = useMemo(
() => groups.find(({ id }) => id === activeGroupId),