🚀 Add new /templates utility + add support for web components

This commit is contained in:
pheralb
2025-02-26 16:59:52 +00:00
parent 63d2416274
commit dc22285088
14 changed files with 290 additions and 91 deletions
+23
View File
@@ -0,0 +1,23 @@
interface ReactComponentParams {
code: string;
name: string;
typescript: boolean;
}
export const getReactCode = async (
params: ReactComponentParams
): Promise<{ data?: string; error?: string }> => {
try {
const getCode = await fetch('/api/svgs/svgr', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
});
const data = await getCode.json();
return data;
} catch (error) {
return { error: `⚠️ getReactCode: An error has ocurred - ${error}` };
}
};