Hello,
There are couple questions:
- So, I have data for macroConfig that comes from 3rd-party api.
const Config = () => {
const config = useConfig();
const [projects] = useState<MCProject[]>(async () => {
const token = await storage.getSecret(TOKEN_KEY);
const baseUrl = await storage.get(BASE_URL_KEY);
const response = await fetch(`${baseUrl}rest-api/projects`, {
headers: {
Authorization: `Bearer ${token}`
}
});
return await response.json();
});
const [documents, setDocuments] = useState<MCDocument[]>([]);
useEffect(() => {
if (!config.project) return;
(async () => {
const token = await storage.getSecret(TOKEN_KEY);
const baseUrl = await storage.get(BASE_URL_KEY);
const response = await fetch(`${baseUrl}rest-api/projects/${config.project}/documents`, {
headers: {
Authorization: `Bearer ${token}`
}
});
const dcs = await response.json();
setDocuments(dcs);
})();
}, [config.project])
return (
<MacroConfig>
<Select label="Project" name="project">
{projects.map((p) => (
<Option label={p.title} value={p.id} />
))}
</Select>
<Select label="Document" name="document">
{documents.map((d) => (
<Option label={d.title} value={d.documentID} />
))}
</Select>
</MacroConfig>
);
};
So, there are two selects, the second one depends on first one. Is it possible to implement here?
- Is it possible to open macro configuration on inserting macro tag into content?
Thanks a lot.