diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-06-21 11:01:35 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-06-21 11:01:35 +0700 |
| commit | 220190db66bcc1c6db78180c593f21e9cf8f363c (patch) | |
| tree | 1517faa9636a6b3b2cc8d468a57b1fe476c229d7 /src-migrate/hooks | |
| parent | 208b234320b6c42491a4e87a1c3db3abab9c1715 (diff) | |
| parent | 1cf754b4d8da1aa28700ffc3dad67081f6daf9a5 (diff) | |
Merge branch 'promotion-program' into feature/all-promotion
Diffstat (limited to 'src-migrate/hooks')
| -rw-r--r-- | src-migrate/hooks/useUtmSource.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src-migrate/hooks/useUtmSource.ts b/src-migrate/hooks/useUtmSource.ts new file mode 100644 index 00000000..a72fae36 --- /dev/null +++ b/src-migrate/hooks/useUtmSource.ts @@ -0,0 +1,20 @@ +import { useRouter } from 'next/router'; +import { useEffect, useState } from 'react'; +import { UTM_SOURCE } from '~/constants/utm-source'; + +const useUtmSource = () => { + const router = useRouter(); + const [source, setSource] = useState<string>(); + + useEffect(() => { + console.log(router.pathname); + + if (router.pathname) { + setSource(UTM_SOURCE[router.pathname as keyof typeof UTM_SOURCE]); + } + }, [router.pathname]); + + return source; +}; + +export default useUtmSource; |
