Skip to content

Commit beeac7f

Browse files
committed
fix: separate context and provider to make eslint happy
1 parent c47050b commit beeac7f

File tree

7 files changed

+88
-20
lines changed

7 files changed

+88
-20
lines changed

src/components/ui/helpCenter/HelpCenter.tsx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import React, { useState } from 'react';
4-
import { X, Info, PlayCircle, BookOpen, History } from 'lucide-react';
4+
import { X, Info, PlayCircle, BookOpen, History, Link as LinkIcon } from 'lucide-react';
55
import { Button } from '@/components/ui/button';
66
import helpContent from '@/data/helpContent.json';
77

@@ -73,7 +73,7 @@ const HelpCenter: React.FC<HelpCenterProps> = ({
7373
</div>
7474

7575
{/* Tabs - grid for mobile, flex for desktop */}
76-
<div className='grid grid-cols-4 sm:flex border-b'>
76+
<div className='grid grid-cols-5 sm:flex border-b'>
7777
<button
7878
className={`px-2 sm:px-4 py-2 font-medium text-xs sm:text-sm flex flex-col sm:flex-row items-center justify-center ${
7979
activeTab === 'welcome'
@@ -107,6 +107,17 @@ const HelpCenter: React.FC<HelpCenterProps> = ({
107107
<BookOpen className='w-4 h-4 sm:mr-1 mb-1 sm:mb-0' />
108108
<span>Features</span>
109109
</button>
110+
<button
111+
className={`px-2 sm:px-4 py-2 font-medium text-xs sm:text-sm flex flex-col sm:flex-row items-center justify-center ${
112+
activeTab === 'resources'
113+
? 'text-brand-blue border-b-2 border-brand-blue'
114+
: 'text-gray-500 hover:text-gray-700'
115+
}`}
116+
onClick={() => handleTabChange('resources')}
117+
>
118+
<LinkIcon className='w-4 h-4 sm:mr-1 mb-1 sm:mb-0' />
119+
<span>Resources</span>
120+
</button>
110121
<button
111122
className={`px-2 sm:px-4 py-2 font-medium text-xs sm:text-sm flex flex-col sm:flex-row items-center justify-center ${
112123
activeTab === 'versions'
@@ -219,8 +230,29 @@ const HelpCenter: React.FC<HelpCenterProps> = ({
219230
{activeTab === 'resources' && (
220231
<div>
221232
<h3 className='text-lg font-medium text-gray-800 mb-3'>
222-
Resources
233+
Helpful Resources
223234
</h3>
235+
236+
<div className='space-y-4'>
237+
{helpContent.resources.map((resource, index) => (
238+
<div key={index} className='bg-gray-50 p-4 rounded-lg hover:bg-gray-100 transition-colors'>
239+
<a
240+
href={resource.link}
241+
target='_blank'
242+
rel='noopener noreferrer'
243+
className='block'
244+
>
245+
<h4 className='font-medium text-brand-blue mb-1 flex items-center'>
246+
<LinkIcon className='w-4 h-4 mr-2' />
247+
{resource.title}
248+
</h4>
249+
<p className='text-gray-700 text-sm'>
250+
{resource.description}
251+
</p>
252+
</a>
253+
</div>
254+
))}
255+
</div>
224256
</div>
225257
)}
226258

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use client';
2+
3+
import { createContext } from 'react';
4+
5+
export interface HelpContextType {
6+
showHelpCenter: (tab?: string) => void;
7+
}
8+
9+
export const HelpContext = createContext<HelpContextType | undefined>(undefined);

src/components/ui/helpCenter/HelpProvider.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
'use client';
22

3-
import React, { createContext, useContext, useState, useEffect } from 'react';
3+
import React, { useState, useEffect } from 'react';
4+
import { HelpContext } from './HelpContext';
45
import WelcomePanel from './WelcomePanel';
56
import HelpButton from './HelpButton';
67
import HelpCenter from './HelpCenter';
78

8-
interface HelpContextType {
9-
showHelpCenter: (tab?: string) => void;
10-
}
11-
12-
const HelpContext = createContext<HelpContextType | undefined>(undefined);
13-
14-
export const useHelp = () => {
15-
const context = useContext(HelpContext);
16-
if (!context) {
17-
throw new Error('useHelp must be used within a HelpProvider');
18-
}
19-
return context;
20-
};
21-
229
interface HelpProviderProps {
2310
children: React.ReactNode;
2411
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './useHelp';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use client';
2+
3+
import { useContext } from 'react';
4+
import { HelpContext } from '../HelpContext';
5+
6+
export const useHelp = () => {
7+
const context = useContext(HelpContext);
8+
if (!context) {
9+
throw new Error('useHelp must be used within a HelpProvider');
10+
}
11+
return context;
12+
};
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export { default as HelpProvider, useHelp } from './HelpProvider';
1+
export { default as HelpProvider } from './HelpProvider';
2+
export { useHelp } from './hooks';
23
export { default as HelpButton } from './HelpButton';
34
export { default as HelpCenter } from './HelpCenter';
45
export { default as WelcomePanel } from './WelcomePanel';

src/data/helpContent.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,33 @@
8181
}
8282
],
8383

84-
"resources": [{}],
84+
"resources": [
85+
{
86+
"title": "Communication Guide",
87+
"description": "Comprehensive guide on effective workplace communication strategies.",
88+
"link": "https://example.com/communication-guide"
89+
},
90+
{
91+
"title": "Manager Conversation Toolkit",
92+
"description": "Tools and templates for having productive conversations with your manager.",
93+
"link": "https://example.com/manager-conversation-toolkit"
94+
},
95+
{
96+
"title": "Workplace Accommodations FAQ",
97+
"description": "Frequently asked questions about requesting and implementing workplace accommodations.",
98+
"link": "https://example.com/workplace-accommodations-faq"
99+
},
100+
{
101+
"title": "Career Development Resources",
102+
"description": "Resources to help plan and discuss your career development with your manager.",
103+
"link": "https://example.com/career-development"
104+
},
105+
{
106+
"title": "Wellbeing Support",
107+
"description": "Information and resources for maintaining wellbeing in the workplace.",
108+
"link": "https://example.com/wellbeing-support"
109+
}
110+
],
85111
"versions": [
86112
{
87113
"version": "1.0.0",

0 commit comments

Comments
 (0)