import { AlertDialog, AlertDialogBody, AlertDialogCloseButton, AlertDialogContent, AlertDialogFooter, AlertDialogOverlay, Button, Divider, Heading, HStack, Text, useToast, VStack } from '@chakra-ui/react' import * as React from 'react' import {JaenLogo} from '../../icons' export interface IncomingBuildAlertProps { onConfirm: () => Promise isOpen: boolean onClose: () => void totalChanges: number } // window.___webpackCompilationHash export const IncomingBuildAlert = ({ onConfirm, isOpen, onClose, totalChanges }: IncomingBuildAlertProps) => { const cancelRef = React.useRef() const [isLoading, setIsLoading] = React.useState(false) const toast = useToast() const handleConfirm = async () => { setIsLoading(true) const confirmed = await onConfirm() setIsLoading(false) if (confirmed) { toast({ title: 'Success', description: 'Your changes have been discarded. You are now in view mode.', status: 'success', duration: 5000, isClosable: true }) onClose() } else { toast({ title: 'Error', description: 'Something went wrong.', status: 'error', duration: 5000, isClosable: true }) } } return ( New version is now available There is a new version of the website available. You can either update to the latest version and discard your changes or you can continue working on your changes. Note: {totalChanges} changes have been made since the last published version. Warning: When not updating, publishing your changes might result in overwriting data of the latest version. ) } export default IncomingBuildAlert