Whatsapp service updates

This commit is contained in:
Darren Clarke 2024-05-16 18:22:10 +02:00
parent e22a8e8d98
commit 3da103c010
16 changed files with 151 additions and 36 deletions

View file

@ -6,7 +6,8 @@ import { colors } from "../styles/theme";
type QRCodeProps = {
name: string;
label: string;
id: string;
token: string;
verified: boolean;
helperText?: string;
getValue?: (id: string) => Promise<string>;
refreshInterval?: number;
@ -15,7 +16,8 @@ type QRCodeProps = {
export const QRCode: FC<QRCodeProps> = ({
name,
label,
id,
token,
verified,
helperText,
getValue,
refreshInterval,
@ -24,19 +26,19 @@ export const QRCode: FC<QRCodeProps> = ({
const { white } = colors;
useEffect(() => {
if (getValue && refreshInterval) {
if (!verified && getValue && refreshInterval) {
const interval = setInterval(async () => {
const result = await getValue(id);
const result = await getValue(token);
setValue(result);
}, refreshInterval);
}, refreshInterval * 1000);
return () => clearInterval(interval);
}
}, [getValue, refreshInterval]);
return (
return !verified ? (
<Box sx={{ backgroundColor: white, m: 2 }}>
<QRCodeInternal value={value} />
<Box>{helperText}</Box>
</Box>
);
) : null;
};