PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.14.5
GiveWP – Donation Plugin and Fundraising Platform v4.14.5
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 2.31.0 2.31.1 All 253 releases
give / src / Campaigns / resources / hooks / index.tsx
index.tsx
25 lines 915 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {useState} from 'react';
2 import {getCampaignOptionsWindowData, handleTooltipDismiss} from '@givewp/campaigns/utils';
3
4 type NoticeId = 'givewp_campaign_form_notice' | 'givewp_campaign_settings_notice' | 'givewp_campaign_listtable_notice';
5
6 const noticesMap = {
7 givewp_campaign_listtable_notice: 'showCampaignListTableNotice',
8 givewp_campaign_settings_notice: 'showCampaignSettingsNotice',
9 givewp_campaign_form_notice: 'showCampaignFormNotice',
10 };
11
12 export function useCampaignNoticeHook(id: NoticeId): [boolean, () => void] {
13 const campaignWindowData = getCampaignOptionsWindowData();
14 const [showTooltip, setShowTooltip] = useState<boolean>(campaignWindowData.admin[noticesMap[id]]);
15
16 return [
17 showTooltip,
18 () => {
19 setShowTooltip(false);
20 campaignWindowData.admin[noticesMap[id]] = false;
21 handleTooltipDismiss(id);
22 },
23 ];
24 }
25