Signal API updates
This commit is contained in:
parent
83653ef23b
commit
c729a46a0c
25 changed files with 501 additions and 279 deletions
|
|
@ -82,7 +82,7 @@ export const Detail: FC<DetailProps> = ({ service, row }) => {
|
|||
<QRCode
|
||||
name={field.name}
|
||||
label={field.label}
|
||||
getValue={field.getValue}
|
||||
getValue={field.getQRCode}
|
||||
refreshInterval={field.refreshInterval}
|
||||
token={token}
|
||||
verified={row.verified as boolean}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ type QRCodeProps = {
|
|||
token: string;
|
||||
verified: boolean;
|
||||
helperText?: string;
|
||||
getValue?: (id: string) => Promise<string>;
|
||||
getValue?: (id: string) => Promise<Record<string, string>>;
|
||||
refreshInterval?: number;
|
||||
};
|
||||
|
||||
|
|
@ -23,13 +23,16 @@ export const QRCode: FC<QRCodeProps> = ({
|
|||
refreshInterval,
|
||||
}) => {
|
||||
const [value, setValue] = useState("");
|
||||
const [kind, setKind] = useState("data");
|
||||
const { white } = colors;
|
||||
|
||||
useEffect(() => {
|
||||
if (!verified && getValue && refreshInterval) {
|
||||
const interval = setInterval(async () => {
|
||||
const result = await getValue(token);
|
||||
setValue(result);
|
||||
const { qr, kind } = await getValue(token);
|
||||
console.log({ kind });
|
||||
setValue(qr);
|
||||
setKind(kind);
|
||||
}, refreshInterval * 1000);
|
||||
return () => clearInterval(interval);
|
||||
}
|
||||
|
|
@ -37,7 +40,11 @@ export const QRCode: FC<QRCodeProps> = ({
|
|||
|
||||
return !verified ? (
|
||||
<Box sx={{ backgroundColor: white, m: 2 }}>
|
||||
<QRCodeInternal value={value} />
|
||||
{kind === "data" ? (
|
||||
<QRCodeInternal value={value} />
|
||||
) : (
|
||||
<img src={value} alt={name} />
|
||||
)}
|
||||
<Box>{helperText}</Box>
|
||||
</Box>
|
||||
) : null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue