11"use client" ;
22
3- import React from "react" ;
3+ import React , { useEffect } from "react" ;
44import { faCheckCircle , faCopy , faQuestionCircle } from "@fortawesome/free-solid-svg-icons" ;
55import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
66import { useState } from "react" ;
77import { useSnackbar } from "@context/SnackbarContext" ;
8- import "./copy.css" ;
8+ import { Modal } from "@components/modal/modal" ;
9+ import { useRouter , useSearchParams } from "next/navigation" ;
910
1011export interface CopyViewProps
1112{
12- title : string ;
13+ name : string ;
1314 description ?: string ;
1415 value : string ;
1516}
1617
17- export const CopyView = ( { title , description, value } : CopyViewProps ) => {
18+ export const CopyView = ( { name , description, value } : CopyViewProps ) => {
1819
1920 const [ copied , setCopied ] = useState ( false ) ;
2021 const [ hover , setHover ] = useState ( false ) ;
@@ -27,7 +28,7 @@ export const CopyView = ({ title, description, value }: CopyViewProps) => {
2728 < div className = "relative my-auto" >
2829 < div className = "flex mb-2 " >
2930 < label className = "text-lg sm:text-xl my-auto opacity-50 text-white grow align-bottom mb-1" >
30- { title }
31+ { name }
3132 </ label >
3233 { description && (
3334 < FontAwesomeIcon icon = { faQuestionCircle } className = "w-5 h-5 mb-1 opacity-25 hover:opacity-100 align-self-end justify-self-end text-white justify-right"
@@ -73,4 +74,39 @@ export const CopyView = ({ title, description, value }: CopyViewProps) => {
7374 </ div >
7475 </ >
7576 ) ;
76- } ;
77+ } ;
78+
79+ export default function CopyPage ( ) {
80+
81+ const searchParams = useSearchParams ( ) ;
82+ const router = useRouter ( ) ;
83+ const title = searchParams . get ( "title" ) ;
84+ const name = searchParams . get ( "name" ) ;
85+ const description = searchParams . get ( "description" ) ;
86+ const value = searchParams . get ( "value" ) ;
87+
88+ if ( ! title || ! name || ! value ) {
89+ let message = `Copy modal dialog is missing one or more required paramters.\n` ;
90+ message += `\ntitle: ${ title } \nname: ${ name } \ndescription: ${ description } \nvalue: ${ value } ` ;
91+ console . error ( message ) ;
92+ router . push ( '/' ) ;
93+
94+ return ;
95+ }
96+
97+ useEffect ( ( ) => {
98+
99+ router . replace ( '/copy' , { } ) ;
100+
101+ } , [ ] ) ;
102+
103+ return (
104+ < >
105+ < Modal title = { title } >
106+ < div className = " w-full h-[70%]" >
107+ < CopyView name = { name } description = { description || '' } value = { value } />
108+ </ div >
109+ </ Modal >
110+ </ >
111+ ) ;
112+ }
0 commit comments