PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 1.0.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v1.0.0
2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.10.0 All 48 releases
thinkrank / src / admin / components / essential-seo / schema / forms / SchemaFAQForm.js

SchemaFAQForm.js in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 1.0.0, at src/admin/components/essential-seo/schema/forms/SchemaFAQForm.js

188 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Schema FAQ Form Component
3 *
4 * Extracted from SchemaGeneration.js - handles FAQ schema form fields
5 *
6 * @package ThinkRank
7 * @since 1.0.0
8 */
9
10 import { __ } from '@wordpress/i18n';
11 import {
12 Card,
13 CardBody,
14 CardHeader,
15 TextControl,
16 TextareaControl
17 } from '@wordpress/components';
18
19 /**
20 * Schema FAQ Form Component
21 */
22 const SchemaFAQForm = ({
23 settings,
24 onSettingChange,
25 isLoading
26 }) => {
27 const faqQuestions = settings.faq_questions || [];
28
29 const addFAQQuestion = () => {
30 const newQuestions = [...faqQuestions, { question: '', answer: '' }];
31 onSettingChange('faq_questions', newQuestions);
32 };
33
34 const updateFAQQuestion = (index, field, value) => {
35 const newQuestions = [...faqQuestions];
36 newQuestions[index][field] = value;
37 onSettingChange('faq_questions', newQuestions);
38 };
39
40 const removeFAQQuestion = (index) => {
41 const newQuestions = faqQuestions.filter((_, i) => i !== index);
42 onSettingChange('faq_questions', newQuestions);
43 };
44
45 return (
46 <Card size="small">
47 <CardHeader>
48 <h4>{__('FAQ Page Configuration', 'thinkrank')}</h4>
49 </CardHeader>
50 <CardBody>
51 <div style={{ marginBottom: '16px' }}>
52 <p className="components-base-control__help">
53 {__('Configure your FAQ page details and add frequently asked questions with their answers. Each question will be structured for rich snippets in search results.', 'thinkrank')}
54 </p>
55 </div>
56
57 {/* FAQ Page Details */}
58 <div style={{ marginBottom: '24px', padding: '16px', backgroundColor: '#f8f9fa', borderRadius: '4px', border: '1px solid #dee2e6' }}>
59 <h5 style={{ margin: '0 0 12px 0', fontSize: '14px', fontWeight: '600' }}>
60 {__('FAQ Page Information', 'thinkrank')}
61 </h5>
62 <div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
63 <TextControl
64 label={__('Page Title', 'thinkrank')}
65 value={settings.faq_page_name || ''}
66 onChange={(value) => onSettingChange('faq_page_name', value)}
67 help={__('Title of your FAQ page (recommended)', 'thinkrank')}
68 placeholder={__('e.g., Frequently Asked Questions', 'thinkrank')}
69 disabled={!settings.enabled}
70 __next40pxDefaultSize={true}
71 __nextHasNoMarginBottom={true}
72 />
73 <TextareaControl
74 label={__('Page Description', 'thinkrank')}
75 value={settings.faq_page_description || ''}
76 onChange={(value) => onSettingChange('faq_page_description', value)}
77 help={__('Brief description of your FAQ page (recommended)', 'thinkrank')}
78 placeholder={__('e.g., Find answers to commonly asked questions about our products and services.', 'thinkrank')}
79 disabled={!settings.enabled}
80 rows={2}
81 __nextHasNoMarginBottom={true}
82 />
83 <TextControl
84 label={__('Page URL', 'thinkrank')}
85 type="url"
86 value={settings.faq_page_url || ''}
87 onChange={(value) => onSettingChange('faq_page_url', value)}
88 help={__('URL of your FAQ page (optional)', 'thinkrank')}
89 placeholder={__('e.g., https://yoursite.com/faq', 'thinkrank')}
90 disabled={!settings.enabled}
91 __next40pxDefaultSize={true}
92 __nextHasNoMarginBottom={true}
93 />
94 </div>
95 </div>
96
97 {faqQuestions.length > 0 && (
98 <div style={{ marginBottom: '16px' }}>
99 {faqQuestions.map((faq, index) => (
100 <div key={index} style={{
101 padding: '16px',
102 border: '1px solid #ddd',
103 borderRadius: '4px',
104 marginBottom: '12px',
105 backgroundColor: '#f9f9f9'
106 }}>
107 <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '12px' }}>
108 <h5 style={{ margin: 0, fontSize: '14px' }}>
109 {__('Question', 'thinkrank')} {index + 1}
110 </h5>
111 <button
112 type="button"
113 onClick={() => removeFAQQuestion(index)}
114 style={{
115 background: '#dc3545',
116 color: 'white',
117 border: 'none',
118 borderRadius: '3px',
119 padding: '4px 8px',
120 fontSize: '12px',
121 cursor: 'pointer'
122 }}
123 disabled={!settings.enabled}
124 >
125 {__('Remove', 'thinkrank')}
126 </button>
127 </div>
128 <TextControl
129 label={__('Question', 'thinkrank')}
130 value={faq.question || ''}
131 onChange={(value) => updateFAQQuestion(index, 'question', value)}
132 placeholder={__('Enter the frequently asked question...', 'thinkrank')}
133 disabled={!settings.enabled}
134 __next40pxDefaultSize={true}
135 __nextHasNoMarginBottom={true}
136 style={{ marginBottom: '12px' }}
137 />
138 <TextareaControl
139 label={__('Answer', 'thinkrank')}
140 value={faq.answer || ''}
141 onChange={(value) => updateFAQQuestion(index, 'answer', value)}
142 placeholder={__('Enter the detailed answer...', 'thinkrank')}
143 disabled={!settings.enabled}
144 rows={3}
145 __nextHasNoMarginBottom={true}
146 />
147 </div>
148 ))}
149 </div>
150 )}
151
152 <button
153 type="button"
154 onClick={addFAQQuestion}
155 style={{
156 background: '#007cba',
157 color: 'white',
158 border: 'none',
159 borderRadius: '3px',
160 padding: '8px 16px',
161 fontSize: '13px',
162 cursor: 'pointer'
163 }}
164 disabled={!settings.enabled}
165 >
166 {__('+ Add FAQ Question', 'thinkrank')}
167 </button>
168
169 {faqQuestions.length === 0 && (
170 <div style={{
171 padding: '16px',
172 backgroundColor: '#fff3cd',
173 border: '1px solid #ffeaa7',
174 borderRadius: '4px',
175 marginTop: '12px'
176 }}>
177 <p style={{ margin: 0, color: '#856404' }}>
178 {__('No FAQ questions added yet. Click "Add FAQ Question" to get started.', 'thinkrank')}
179 </p>
180 </div>
181 )}
182 </CardBody>
183 </Card>
184 );
185 };
186
187 export default SchemaFAQForm;
188