@@ -58,11 +58,44 @@ function TabPanel(props) {
5858
5959const ContractsPage = ( ) => {
6060 const [ tabValue , setTabValue ] = useState ( 0 ) ;
61+ const [ myContracts , setMyContracts ] = useState ( [ ] ) ;
62+ const [ recentActivity , setRecentActivity ] = useState ( [ ] ) ;
6163
6264 const handleTabChange = ( event , newValue ) => {
6365 setTabValue ( newValue ) ;
6466 } ;
6567
68+ const handleUseTemplate = ( template ) => {
69+ // Create a new contract from template
70+ const newContract = {
71+ id : Date . now ( ) ,
72+ title : template . title ,
73+ type : template . type ,
74+ status : 'Draft' ,
75+ createdAt : new Date ( ) . toISOString ( ) ,
76+ template : template
77+ } ;
78+
79+ // Add to My Contracts
80+ setMyContracts ( prev => [ newContract , ...prev ] ) ;
81+
82+ // Add to Recent Activity
83+ const activity = {
84+ id : Date . now ( ) ,
85+ type : 'Contract Created' ,
86+ description : `Created "${ template . title } " from template` ,
87+ timestamp : new Date ( ) . toISOString ( ) ,
88+ contractId : newContract . id
89+ } ;
90+ setRecentActivity ( prev => [ activity , ...prev ] ) ;
91+
92+ // Switch to My Contracts tab to show the new contract
93+ setTabValue ( 1 ) ;
94+
95+ // Show success message (you could add a toast notification here)
96+ alert ( `Contract "${ template . title } " created successfully! Check "My Contracts" tab.` ) ;
97+ } ;
98+
6699 const contractTemplates = [
67100 {
68101 id : 1 ,
@@ -257,9 +290,13 @@ const ContractsPage = () => {
257290 startIcon = { < AddIcon /> }
258291 sx = { {
259292 backgroundColor : 'white' ,
260- color : designTokens . colors . primary [ 600 ] ,
293+ color : '#0D47A1' , // Dark blue for better contrast
294+ fontWeight : 700 ,
295+ boxShadow : '0 4px 12px rgba(0, 0, 0, 0.15)' ,
261296 '&:hover' : {
262297 backgroundColor : 'rgba(255, 255, 255, 0.9)' ,
298+ boxShadow : '0 6px 20px rgba(0, 0, 0, 0.2)' ,
299+ transform : 'translateY(-2px)' ,
263300 } ,
264301 } }
265302 >
@@ -438,6 +475,16 @@ const ContractsPage = () => {
438475 variant = "primary"
439476 size = "small"
440477 startIcon = { < AddIcon /> }
478+ onClick = { ( ) => handleUseTemplate ( template ) }
479+ sx = { {
480+ backgroundColor : '#1565C0' ,
481+ color : 'white' ,
482+ fontWeight : 600 ,
483+ '&:hover' : {
484+ backgroundColor : '#0D47A1' ,
485+ transform : 'translateY(-1px)' ,
486+ } ,
487+ } }
441488 >
442489 Use Template
443490 </ Button >
@@ -479,7 +526,17 @@ const ContractsPage = () => {
479526 </ Box >
480527
481528 < List >
482- { userContracts . map ( ( contract , index ) => (
529+ { myContracts . length === 0 ? (
530+ < Box sx = { { textAlign : 'center' , py : 4 } } >
531+ < Typography variant = "h6" color = "text.secondary" gutterBottom >
532+ No contracts yet
533+ </ Typography >
534+ < Typography variant = "body2" color = "text.secondary" >
535+ Use a template to create your first contract
536+ </ Typography >
537+ </ Box >
538+ ) : (
539+ myContracts . map ( ( contract , index ) => (
483540 < React . Fragment key = { contract . id } >
484541 < ListItem
485542 sx = { {
@@ -496,7 +553,7 @@ const ContractsPage = () => {
496553 < ListItemText
497554 primary = {
498555 < Typography variant = "h6" sx = { { fontWeight : designTokens . typography . fontWeight . semibold } } >
499- { contract . name }
556+ { contract . title }
500557 </ Typography >
501558 }
502559 secondary = {
@@ -537,9 +594,10 @@ const ContractsPage = () => {
537594 </ IconButton >
538595 </ Box >
539596 </ ListItem >
540- { index < userContracts . length - 1 && < Divider /> }
597+ { index < myContracts . length - 1 && < Divider /> }
541598 </ React . Fragment >
542- ) ) }
599+ ) )
600+ ) }
543601 </ List >
544602 </ motion . div >
545603 </ TabPanel >
@@ -557,15 +615,55 @@ const ContractsPage = () => {
557615 >
558616 Recent Activity
559617 </ Typography >
560- < Box sx = { { textAlign : 'center' , py : designTokens . spacing [ 8 ] } } >
561- < DescriptionIcon sx = { { fontSize : 64 , color : designTokens . colors . neutral [ 300 ] , mb : designTokens . spacing [ 4 ] } } />
562- < Typography variant = "h6" color = "text.secondary" sx = { { mb : designTokens . spacing [ 2 ] } } >
563- No recent activity
564- </ Typography >
565- < Typography variant = "body2" color = "text.secondary" >
566- Your contract activity will appear here
567- </ Typography >
568- </ Box >
618+ { recentActivity . length === 0 ? (
619+ < Box sx = { { textAlign : 'center' , py : designTokens . spacing [ 8 ] } } >
620+ < DescriptionIcon sx = { { fontSize : 64 , color : designTokens . colors . neutral [ 300 ] , mb : designTokens . spacing [ 4 ] } } />
621+ < Typography variant = "h6" color = "text.secondary" sx = { { mb : designTokens . spacing [ 2 ] } } >
622+ No recent activity
623+ </ Typography >
624+ < Typography variant = "body2" color = "text.secondary" >
625+ Your contract activity will appear here
626+ </ Typography >
627+ </ Box >
628+ ) : (
629+ < List >
630+ { recentActivity . map ( ( activity , index ) => (
631+ < React . Fragment key = { activity . id } >
632+ < ListItem
633+ sx = { {
634+ p : designTokens . spacing [ 3 ] ,
635+ borderRadius : designTokens . borderRadius . md ,
636+ '&:hover' : {
637+ backgroundColor : designTokens . colors . neutral [ 50 ] ,
638+ } ,
639+ } }
640+ >
641+ < ListItemIcon >
642+ < AddIcon sx = { { color : designTokens . colors . success [ 500 ] } } />
643+ </ ListItemIcon >
644+ < ListItemText
645+ primary = {
646+ < Typography variant = "h6" sx = { { fontWeight : designTokens . typography . fontWeight . semibold } } >
647+ { activity . type }
648+ </ Typography >
649+ }
650+ secondary = {
651+ < Box >
652+ < Typography variant = "body2" color = "text.secondary" >
653+ { activity . description }
654+ </ Typography >
655+ < Typography variant = "caption" color = "text.secondary" >
656+ { new Date ( activity . timestamp ) . toLocaleString ( ) }
657+ </ Typography >
658+ </ Box >
659+ }
660+ />
661+ </ ListItem >
662+ { index < recentActivity . length - 1 && < Divider /> }
663+ </ React . Fragment >
664+ ) ) }
665+ </ List >
666+ ) }
569667 </ motion . div >
570668 </ TabPanel >
571669 </ Card >
0 commit comments