@@ -2,44 +2,64 @@ import React, { useState, useEffect, useRef } from 'react';
22import AssistantModal from './AssistantModal' ; // Import the AssistantModal component for the chatbot.
33import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ; // Import the FontAwesomeIcon component.
44import { faChevronDown } from '@fortawesome/free-solid-svg-icons' ; // Import the icon.
5- import ContactSupportLink from "./ContactSupportLink" ; // Import the Enterprise support link.
65import { useDoc } from '@docusaurus/plugin-content-docs/client' ;
6+ import { useLocation } from "@docusaurus/router" ; // Import for location detection.
77
8- const DropdownMenu : React . FC = ( ) => {
8+ const SupportDropdownMenu : React . FC = ( ) => {
99 const [ isOpen , setIsOpen ] = useState ( false ) ; // For dropdown visibility
1010 const [ isModalOpen , setIsModalOpen ] = useState ( false ) ; // For modal visibility
11+ const [ storedUrl , setStoredUrl ] = useState < string | null > ( null ) ; // For storing the URL
1112 const dropdownRef = useRef < HTMLDivElement > ( null ) ;
13+ const location = useLocation ( ) ;
1214
1315 // Get document metadata from Docusaurus.
1416 const { metadata } = useDoc ( ) ;
1517 const docTitle = metadata ?. title || "Issue with documentation page" ; // Use document title or fallback.
1618
1719 // Detect the language based on the URL path.
18- const isJapanese = typeof window !== "undefined" && window . location . pathname . startsWith ( "/ja-jp" ) ;
20+ const isJapanese = location . pathname . startsWith ( "/ja-jp" ) ;
21+
22+ useEffect ( ( ) => {
23+ // Store the current URL in localStorage when the component first mounts.
24+ const currentUrl = `https://scalardb.scalar-labs.com${ location . pathname } ` ;
25+ localStorage . setItem ( "currentUrl" , currentUrl ) ;
26+
27+ // Retrieve stored URL (if available).
28+ const savedUrl = localStorage . getItem ( "currentUrl" ) ;
29+ if ( savedUrl ) {
30+ setStoredUrl ( savedUrl ) ;
31+ }
32+ } , [ location ] ) ;
1933
2034 const toggleDropdown = ( ) => {
2135 setIsOpen ( ( prev ) => ! prev ) ;
2236 } ;
2337
2438 const openModal = ( event : React . MouseEvent ) => {
25- event . preventDefault ( ) ; // Prevent the default anchor behavior (page navigation) .
26- setIsModalOpen ( true ) ; // Open the modal when the link is clicked.
27- setIsOpen ( false ) ; // Optionally close the dropdown when modal opens.
39+ event . preventDefault ( ) ; // Prevent default anchor behavior.
40+ setIsModalOpen ( true ) ;
41+ setIsOpen ( false ) ;
2842 } ;
2943
3044 const closeModal = ( ) => {
3145 setIsModalOpen ( false ) ;
3246 } ;
3347
48+ const handleSupportClick = ( ) => {
49+ // Get the stored URL or fall back to the current URL.
50+ const finalUrl = storedUrl || `https://scalardb.scalar-labs.com${ location . pathname } ` ;
51+ const reportUrl = `https://support.scalar-labs.com/hc/ja/requests/new?ticket_form_id=8641483507983&tf_11847415366927=${ encodeURIComponent ( finalUrl ) } ` ;
52+
53+ // Open the support link in a new tab.
54+ window . open ( reportUrl , "_blank" ) ;
55+ } ;
56+
3457 // Generate GitHub issue URL dynamically.
3558 const repoUrl = "https://github.com/scalar-labs/docs-scalardb/issues/new" ;
36-
37- // Define issue title dynamically based on language.
3859 const issueTitle = encodeURIComponent (
3960 isJapanese ? `フィードバック: \`${ docTitle } \` ページ` : `Feedback: \`${ docTitle } \` page`
4061 ) ;
4162
42- // Define issue body dynamically based on language.
4363 const issueBody = encodeURIComponent (
4464 isJapanese
4565 ? `**ドキュメントページの URL:** ${ window . location . href . replace ( / # .* $ / , '' ) }
@@ -60,7 +80,7 @@ const DropdownMenu: React.FC = () => {
6080
6181該当する場合は、スクリーンショットを添付してください。
6282`
63- : `**Documentation page URL:** ${ window . location . href . replace ( / # .* $ / , '' ) }
83+ : `**Documentation page URL:** ${ window . location . href . replace ( / # .* $ / , '' ) }
6484
6585## Expected behavior
6686
@@ -78,12 +98,11 @@ If the issue is reproducible, please list the steps to reproduce it.
7898
7999If applicable, add screenshots to help explain your problem.
80100`
81- ) ;
101+ ) ;
82102
83- // Construct the GitHub issue URL.
84103 const githubIssueUrl = `${ repoUrl } ?title=${ issueTitle } &body=${ issueBody } &labels=documentation` ;
85104
86- // Close the dropdown when clicking outside of the content container .
105+ // Close dropdown when clicking outside of it .
87106 useEffect ( ( ) => {
88107 function handleClickOutside ( event : MouseEvent ) {
89108 if ( dropdownRef . current && ! dropdownRef . current . contains ( event . target as Node ) ) {
@@ -108,7 +127,12 @@ If applicable, add screenshots to help explain your problem.
108127
109128 { isOpen && (
110129 < div className = "supportDropdownContent" >
111- < ContactSupportLink />
130+ < div >
131+ < a href = "#" onClick = { handleSupportClick } rel = "noopener noreferrer" >
132+ < b > { isJapanese ? "テクニカルサポートに問い合わせ" : "Contact technical support" } </ b > < br />
133+ { isJapanese ? "エンタープライズのお客様向け" : "For Enterprise customers" }
134+ </ a >
135+ </ div >
112136 < hr />
113137 < a href = "https://stackoverflow.com/questions/tagged/scalardb" target = "_blank" >
114138 < b > { isJapanese ? "Stack Overflow をチェック" : "Check Stack Overflow" } </ b > < br />
@@ -127,10 +151,9 @@ If applicable, add screenshots to help explain your problem.
127151 </ div >
128152 ) }
129153
130- { /* Pass isModalOpen to AssistantModal to control visibility. */ }
131154 { isModalOpen && < AssistantModal isOpen = { isModalOpen } onClose = { closeModal } /> }
132155 </ div >
133156 ) ;
134157} ;
135158
136- export default DropdownMenu ;
159+ export default SupportDropdownMenu ;
0 commit comments