-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #586 from Rushikesh-Sonawane99/release-1.1.0
Issue #PS-000 chore: Updated dynamic values for hidden fields with deviceInfo of user and added support icon
- Loading branch information
Showing
4 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,78 @@ import { Box } from '@mui/material'; | |
import Typography from '@mui/material/Typography'; | ||
import { useTranslation } from 'next-i18next'; | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; | ||
import { useEffect, useState } from 'react'; | ||
import { jotFormId } from '../../app.config'; | ||
|
||
type QueryParams = { | ||
fullName: string; | ||
userName: string; | ||
userid: string; | ||
email: string; | ||
deviceInfo?: string; | ||
}; | ||
|
||
const SupportRequest = () => { | ||
const { t } = useTranslation(); | ||
const queryParams = { | ||
fullName: 'JohnDoe', | ||
username: 'JohnD', | ||
userid: 'JohnDoe123', | ||
email: '[email protected]', | ||
}; | ||
const [queryParams, setQueryParams] = useState<QueryParams>({ | ||
fullName: '', | ||
userName: '', | ||
userid: '', | ||
email: '', | ||
}); | ||
|
||
useEffect(() => { | ||
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') { | ||
const name = localStorage.getItem('userName') || ''; | ||
const loginUserName = localStorage.getItem('userIdName') || ''; | ||
const userId = localStorage.getItem('userId') || ''; | ||
const email = localStorage.getItem('userEmail') || ''; | ||
|
||
const { userAgent, language, platform, cookieEnabled, onLine, hardwareConcurrency } = navigator; | ||
const screenResolution = `${window.screen.width}x${window.screen.height}`; | ||
const viewportSize = `${window.innerWidth}x${window.innerHeight}`; | ||
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; | ||
const screenOrientation = screen.orientation?.type || 'Unknown'; | ||
const referrer = document.referrer || 'Direct Access'; | ||
|
||
// Detect device type | ||
const deviceType = /Mobile|Android|iPhone|iPad/i.test(userAgent) ? 'Mobile' : /Tablet/i.test(userAgent) ? 'Tablet' : 'Desktop'; | ||
|
||
// Extract browser name and version | ||
const browserMatch = userAgent.match(/(firefox|msie|trident|chrome|safari|edge|opr|edg(?=\/))\/?\s*(\d+)/i) || []; | ||
const browser = browserMatch[1] || 'Unknown'; | ||
const browserVersion = browserMatch[2] || 'Unknown'; | ||
|
||
// Access deviceMemory safely | ||
const deviceMemory = (navigator as any).deviceMemory || 'Unknown'; | ||
|
||
// Format the device-related data into a string | ||
const deviceInfo = ` | ||
Browser: ${browser} ${browserVersion} | ||
OS: ${platform} | ||
Screen Resolution: ${screenResolution} | ||
Language: ${language} | ||
Cookies Enabled: ${cookieEnabled} | ||
Online Status: ${onLine ? 'Online' : 'Offline'} | ||
Device Type: ${deviceType} | ||
Hardware Concurrency: ${hardwareConcurrency || 'Unknown'} | ||
Device Memory: ${deviceMemory} | ||
Time Zone: ${timeZone} | ||
Screen Orientation: ${screenOrientation} | ||
Viewport Size: ${viewportSize} | ||
Referrer: ${referrer} | ||
`.trim(); | ||
|
||
setQueryParams({ | ||
fullName: name, | ||
userName: loginUserName, | ||
userid: userId, | ||
email, | ||
deviceInfo, | ||
}); | ||
} | ||
}, []); | ||
|
||
|
||
return ( | ||
<> | ||
|
@@ -25,12 +88,12 @@ const SupportRequest = () => { | |
{t('COMMON.SUBMIT_YOUR_REQUEST_FOR_ISSUES')} | ||
</Typography> | ||
</Box> | ||
<JotFormEmbed formId="250065095006449" queryParams={queryParams} /> | ||
<JotFormEmbed formId={jotFormId} queryParams={queryParams} /> | ||
</> | ||
); | ||
}; | ||
|
||
export async function getStaticProps({ locale }: any) { | ||
export async function getStaticProps({ locale }: { locale: string }) { | ||
return { | ||
props: { | ||
...(await serverSideTranslations(locale, ['common'])), | ||
|