Skip to content

Commit

Permalink
chore: fix dapp
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman035 committed Jul 7, 2024
1 parent 02de4ca commit f3718c2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
8 changes: 4 additions & 4 deletions packages/examples/dnode-dapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/examples/dnode-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@headlessui/react": "^2.1.1",
"@heroicons/react": "^2.1.4",
"@pushprotocol/dnode": "^0.0.4",
"@pushprotocol/dnode": "^0.0.5",
"@rainbow-me/rainbowkit": "^2.1.3",
"@tailwindcss/forms": "^0.5.7",
"@tanstack/react-query": "^5.28.4",
Expand Down
31 changes: 21 additions & 10 deletions packages/examples/dnode-dapp/src/components/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ const SendNotification: React.FC = () => {
const [recipient, setRecipient] = useState<string[]>(['*']); // State for recipients
const [allowNotification, setAllowNotification] = useState<boolean>(false);
const [errorMessage, setErrorMessage] = useState<string>(''); // State for error message
const [sending, setSending] = useState<boolean>(false);

const { isConnected } = useAccount();
const walletClient = useWalletClient();

useEffect(() => {
const checkNotificationPermission = async () => {
if (isConnected && walletClient.data) {
if (isConnected && walletClient.data && channel === '') {
try {
const channelInfo = await getChannelInfo(walletClient.data);
if (channelInfo !== null) {
Expand Down Expand Up @@ -76,19 +77,29 @@ const SendNotification: React.FC = () => {
notificationType,
recipient
);
const res = await sendNotification(
title,
body,
recipient,
walletClient.data
);
console.log(res);

setAllowNotification(false);
setSending(true);
try {
const res = await sendNotification(
title,
body,
recipient,
walletClient.data
);
setAllowNotification(false);
console.log(res);
} catch (error) {
console.error(error);
}
// Reset form fields if needed
setTitle('');
setBody('');
setChannel('');
setNotificationType('broadcast');
setRecipient(['*']);
setSending(false);
setAllowNotification(true);
};

return (
Expand Down Expand Up @@ -181,7 +192,7 @@ const SendNotification: React.FC = () => {
>
<option value="broadcast">Broadcast</option>
<option value="targeted">Targeted</option>
<option value="subset">Subset</option>
{/* <option value="subset">Subset</option> */}
</select>
</div>

Expand Down Expand Up @@ -222,7 +233,7 @@ const SendNotification: React.FC = () => {
: 'bg-gray-300 text-gray-600 cursor-not-allowed'
}`}
>
Send
{sending ? 'Sending...' : 'Send'}
</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/dnode-dapp/src/utils/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PushAPI } from '@pushprotocol/dnode';
import { ENV } from '@pushprotocol/dnode/src/lib/constants';

// TODO: Change to dev or stage
const env = ENV.LOCAL;
const env = ENV.DEV;

export const sendNotification = async (
title: string,
Expand Down

0 comments on commit f3718c2

Please sign in to comment.