PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Admin / fields / Status / index.tsx

index.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Admin/fields/Status/index.tsx

41 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from "@wordpress/i18n";
2 import cx from "classnames";
3 import { AdminSectionField } from "@givewp/components/AdminDetailsPage/AdminSection";
4 import Notice from "@givewp/admin/components/Notices";
5 import { useFormContext, useFormState } from "react-hook-form";
6 import styles from "./styles.module.scss";
7
8 /**
9 * @since 4.10.0
10 */
11 export default function Status({statusOptions}: {statusOptions: Record<string, string>}) {
12 const {register, watch} = useFormContext();
13 const {errors} = useFormState();
14 const {isDirty, dirtyFields} = useFormState();
15 const isStatusDirty = isDirty && dirtyFields?.status;
16 const status = watch('status');
17
18 return (
19 <AdminSectionField error={errors.status?.message as string}>
20 <label htmlFor="status">{__('Status', 'give')}</label>
21 <div className={cx(styles.statusSelect, styles[`statusSelect--${status}`])}>
22 <select id="status" className={styles.statusSelectInput} {...register('status')}>
23 {statusOptions && (
24 Object.entries(statusOptions).map(([value, label]) => (
25 <option key={value} value={value}>
26 {label as string}
27 </option>
28 ))
29 )}
30 </select>
31 </div>
32
33 {isStatusDirty && (
34 <Notice type="info" className={styles.notice}>
35 {__('This will not change the status at the gateway.', 'give')}
36 </Notice>
37 )}
38 </AdminSectionField>
39 );
40 }
41