2024-08-12 22:49:00 +02:00
|
|
|
import { useEffect, useState } from 'react';
|
2024-08-12 19:10:11 +02:00
|
|
|
|
|
|
|
import { getSchemaByName } from "@stirling-pdf/shared-operations/src/workflow/operatorAccessor";
|
|
|
|
|
|
|
|
import styles from './OperatorCard.module.css';
|
2024-08-12 21:05:52 +02:00
|
|
|
import { MaterialSymbol, MaterialSymbolProps } from 'react-material-symbols';
|
|
|
|
|
2024-08-12 19:10:11 +02:00
|
|
|
interface OperatorCardProps {
|
|
|
|
/** The text to display inside the button */
|
|
|
|
operatorInternalName: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function OperatorCard({ operatorInternalName }: OperatorCardProps) {
|
|
|
|
const [schema, setSchema] = useState<any>(undefined); // TODO: Type as joi type
|
2024-08-12 21:05:52 +02:00
|
|
|
const [materialSymbolName, setMaterialSymbolName] = useState<MaterialSymbolProps["icon"]>("error");
|
2024-08-12 19:10:11 +02:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
getSchemaByName(operatorInternalName).then(schema => {
|
|
|
|
if(schema) {
|
|
|
|
setSchema(schema.schema);
|
2024-08-12 21:05:52 +02:00
|
|
|
setMaterialSymbolName(schema.materialSymbolName || "error");
|
2024-08-12 19:10:11 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}, [operatorInternalName]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<a key={operatorInternalName} href={"/operators/" + operatorInternalName}>
|
|
|
|
<div className={styles.operator_card}>
|
2024-08-12 21:05:52 +02:00
|
|
|
<h3><MaterialSymbol icon={materialSymbolName} size={30} fill grade={-25} color='black'></MaterialSymbol> { schema?.describe().flags.label }</h3>
|
2024-08-12 19:10:11 +02:00
|
|
|
{ schema?.describe().flags.description }
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
);
|
|
|
|
}
|