| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
import { getGlobalCurrencySymbol } from '../utils/currency'; |
| 3 |
|
| 4 |
/** |
| 5 |
* Settings tab — full-width campaign settings view. |
| 6 |
* |
| 7 |
* Two collapsible sections matching the PRD: |
| 8 |
* 7.1 General Settings |
| 9 |
* 7.2 Donation Options |
| 10 |
*/ |
| 11 |
export default function SettingsTab( { meta, dispatch } ) { |
| 12 |
const update = ( patch ) => dispatch( { type: 'UPDATE_META', payload: patch } ); |
| 13 |
const currencySymbol = getGlobalCurrencySymbol(); |
| 14 |
|
| 15 |
return ( |
| 16 |
<div className="bp-settings-tab"> |
| 17 |
|
| 18 |
{/* 7.1 General Settings */} |
| 19 |
<div className="bp-settings-section"> |
| 20 |
<div className="bp-settings-section__header"> |
| 21 |
<h3>{ __( 'General Settings', 'better-payment' ) }</h3> |
| 22 |
</div> |
| 23 |
<div className="bp-settings-section__body"> |
| 24 |
|
| 25 |
<div className="bp-settings-row"> |
| 26 |
<div className="bp-settings-col bp-settings-col--full"> |
| 27 |
<label>{ __( 'Campaign Goal Amount', 'better-payment' ) }</label> |
| 28 |
<div className="bp-settings-prefix-input"> |
| 29 |
<span className="bp-settings-prefix">{ currencySymbol }</span> |
| 30 |
<input |
| 31 |
type="number" min="0" step="1" |
| 32 |
value={ meta.bpc_goal_amount } |
| 33 |
onChange={ ( e ) => update( { bpc_goal_amount: e.target.value } ) } |
| 34 |
placeholder="0" |
| 35 |
/> |
| 36 |
</div> |
| 37 |
</div> |
| 38 |
</div> |
| 39 |
|
| 40 |
<div className="bp-settings-row"> |
| 41 |
<div className="bp-settings-col bp-settings-col--full"> |
| 42 |
<label>{ __( 'Ending Date', 'better-payment' ) }</label> |
| 43 |
<input |
| 44 |
type="date" |
| 45 |
value={ meta.bpc_end_date } |
| 46 |
onChange={ ( e ) => update( { bpc_end_date: e.target.value } ) } |
| 47 |
onClick={ ( e ) => e.target.showPicker?.() } |
| 48 |
/> |
| 49 |
</div> |
| 50 |
</div> |
| 51 |
|
| 52 |
<div className="bp-settings-row"> |
| 53 |
<div className="bp-settings-col bp-settings-col--full"> |
| 54 |
<label>{ __( 'Custom CSS Class', 'better-payment' ) }</label> |
| 55 |
<input |
| 56 |
type="text" |
| 57 |
value={ meta.bpc_css_class || '' } |
| 58 |
onChange={ ( e ) => update( { bpc_css_class: e.target.value } ) } |
| 59 |
placeholder="my-campaign-class" |
| 60 |
/> |
| 61 |
</div> |
| 62 |
</div> |
| 63 |
|
| 64 |
</div> |
| 65 |
</div> |
| 66 |
|
| 67 |
{/* 7.2 Donation Options */} |
| 68 |
<div className="bp-settings-section"> |
| 69 |
<div className="bp-settings-section__header"> |
| 70 |
<h3>{ __( 'Donation Options', 'better-payment' ) }</h3> |
| 71 |
</div> |
| 72 |
<div className="bp-settings-section__body"> |
| 73 |
|
| 74 |
<div className="bp-settings-row"> |
| 75 |
<div className="bp-settings-col bp-settings-col--full"> |
| 76 |
<label>{ __( 'Minimum Donation Amount', 'better-payment' ) }</label> |
| 77 |
<div className="bp-settings-prefix-input"> |
| 78 |
<span className="bp-settings-prefix">{ currencySymbol }</span> |
| 79 |
<input |
| 80 |
type="number" min="0" step="1" |
| 81 |
value={ meta.bpc_minimum_amount || '' } |
| 82 |
onChange={ ( e ) => update( { bpc_minimum_amount: e.target.value } ) } |
| 83 |
placeholder="0" |
| 84 |
/> |
| 85 |
</div> |
| 86 |
<p className="bp-settings-hint bp-settings-hint--italic"> |
| 87 |
{ __( 'Leave empty to allow no restrictions on how small the donation can be.', 'better-payment' ) } |
| 88 |
</p> |
| 89 |
</div> |
| 90 |
</div> |
| 91 |
|
| 92 |
</div> |
| 93 |
</div> |
| 94 |
|
| 95 |
</div> |
| 96 |
); |
| 97 |
} |
| 98 |
|