File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import CodeInput from '@/components/CodeInput';
44import Button from '@/components/Button' ;
55import { useState } from 'react' ;
66import { useCodeApply } from '@/api/code/useCodeApply' ;
7+ import { useGeoValidation } from '@/hooks/useGeoValidation' ;
78
89type CodePopupProps = {
910 isOpen : boolean ;
@@ -19,8 +20,16 @@ const CodePopup: React.FC<CodePopupProps> = ({
1920 const [ code , setCode ] = useState < string [ ] > ( Array ( 6 ) . fill ( '' ) ) ;
2021 const [ errorMessage , setErrorMessage ] = useState ( '' ) ;
2122 const applyCode = useCodeApply ( ) ;
23+ const geolocation = useGeoValidation ( ) ;
2224
2325 function handleCodeSubmit ( code : string ) {
26+ if ( ! geolocation . isOk ) {
27+ setErrorMessage (
28+ `Ne možete unijeti kod izvan dozvoljene lokacije. ${ geolocation ?. error ?? '' } ` ,
29+ ) ;
30+ return ;
31+ }
32+
2433 applyCode . mutate ( code , {
2534 onSuccess : ( submittedCode ) => {
2635 closePopup ( ) ;
You can’t perform that action at this time.
0 commit comments