From 0a66be14b90acb942c333c4604bca4cd5cfc05c4 Mon Sep 17 00:00:00 2001 From: L-Pircy Date: Sat, 1 Jun 2024 16:30:57 +0530 Subject: [PATCH] alert code --- app/_components/_rhs/BetterIDEa.tsx | 3 +++ app/_components/_rhs/MessagesDD.tsx | 36 +++++++++++++++++++++++++++- app/_store/store.ts | 9 +++++++ public/alert.png | Bin 0 -> 1251 bytes 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 public/alert.png diff --git a/app/_components/_rhs/BetterIDEa.tsx b/app/_components/_rhs/BetterIDEa.tsx index 0344dce..653f867 100644 --- a/app/_components/_rhs/BetterIDEa.tsx +++ b/app/_components/_rhs/BetterIDEa.tsx @@ -1,6 +1,7 @@ "use client"; import React, { useEffect, useState } from "react"; import { + useAlertStore, useCodeStore, useMessagesArrayStore, usePidStore, @@ -13,6 +14,7 @@ const BetterIDEa = () => { const curCode = useCodeStore((state) => state.curCode); const setMessArr = useMessagesArrayStore((state) => state.setMessArr); const setCurPid = usePidStore((state) => state.setCurPid); + const setAlert = useAlertStore((state) => state.setAlert); const [newMes, setNewMes] = useState(""); useEffect(() => { @@ -61,6 +63,7 @@ const BetterIDEa = () => { console.log("message new", "test\n", m); // setNewMes(m); if (m[0].Output.print) { + setAlert(true); alert("You have new Message!"); } }} diff --git a/app/_components/_rhs/MessagesDD.tsx b/app/_components/_rhs/MessagesDD.tsx index 09646e3..b8573fd 100644 --- a/app/_components/_rhs/MessagesDD.tsx +++ b/app/_components/_rhs/MessagesDD.tsx @@ -3,12 +3,37 @@ import React, { useState, useEffect } from "react"; import { brandLightText } from "../../_utils/colors"; import { getInbox } from "@betteridea/codecell"; import Image from "next/image"; -import { useMessagesArrayStore, usePidStore } from "../../_store/store"; +import { + useAlertStore, + useMessagesArrayStore, + usePidStore, +} from "../../_store/store"; const MessagesDD = () => { const [mesToggle, setMesToggle] = useState(false); + const [notif, setNotif] = useState(false); const messArr = useMessagesArrayStore((state) => state.messArr); const curPid = usePidStore((state) => state.curPid); + const alert = useAlertStore((state) => state.alert); + const setAlert = useAlertStore((state) => state.setAlert); + + useEffect(() => { + getInbox("1", true); + }, []); + + useEffect(() => { + console.log("alert effecvt triggere", alert); + if (!mesToggle && alert) { + getInbox("1", true); + setNotif(true); + } + }, [alert]); + + useEffect(() => { + if (mesToggle) { + setAlert(false); + } + }, [mesToggle]); const stripAnsiCodes = (str: string) => { return str?.replace( @@ -55,6 +80,15 @@ const MessagesDD = () => { className={`${mesToggle ? "rotate-180" : "rotate-0"}`} /> )} + {notif && ( + dd + )} {curPid && ( void; } +interface AlertState { + alert: boolean; + setAlert: (newAlert: boolean) => void; +} + export const useTutorialStore = create()((set) => ({ curTutorial: "GET Request", // increasePopulation: () => set((state) => ({ bears: state.bears + 1 })), @@ -39,3 +44,7 @@ export const usePidStore = create()((set) => ({ curPid: "", setCurPid: (newPid) => set({ curPid: newPid }), })); +export const useAlertStore = create()((set) => ({ + alert: false, + setAlert: (newAlert) => set({ alert: newAlert }), +})); diff --git a/public/alert.png b/public/alert.png new file mode 100644 index 0000000000000000000000000000000000000000..4ae639488215ff6aedf85ed79e45339037ccfe18 GIT binary patch literal 1251 zcmV<91RVQ`P)TBc5!9m|jYjzwJP3*)YU07~3#hA3 zSM@H5Cmhb8hgEjo>)mWfIPTHUs1ZY=1_TikBg+CY3+z<2S@0xE)QqX_dc!0$JI+k^ z%rqM+c}efSo_eodeY~n)wK3Odh0^rda81PUlq1;V7(Q`~bB^(%Ww~_1EWziFgBK^}OREMhzmtS&;b|GcFLd|n|IdDjA63-5UY+o2%qT0XPgEAiEbTV zcJ+ILuw)8Cjsd;%cVuEV#vT5i$Qoj!D!yVFXJt6TEm?S#Yvmgp!ErS)Z2Pk0J87yQ zf&`D6jARL-D>pXm%FM4CY*Jp;wpx+o%}0o=i}pj1TFqSNBWc9p^X(S?GJOfRWnHu% zf(TiL*OcF9rWHwum9$zi(q0n4K?zb>7#&IK8-l-E?$dJkv^vsPc`Vp3L4+*hL5-@- z0mKr#t7f&+6kQO4U3$;$Zkp8cv{qqwviKSa6YH@IA2v-o!g-mLDz4~)Oc6eyeCL`M zWw;=ddFEC95+qt2TdSt^Tl1nR(oviJxqMU61(}#Ht@1d*iWcO;)nZyR)zZ3UO=~4N z`^PHf);zM@iz8#mj;Ui6!x@rkd z+BkeTx7{wcW(@27nv#`Uf_rmeET`ekEJeiuB^;WZsVpIuVaz+Wm{Wzu@5;X!ssTXn znd5nNU**P5yTzE?6W+1=+IyG&L|yHQ+6#=?%U2BI2TAUvX@^r&%ClSCiFVMZGb+$! zO|Q#R_(&BeVOuZ&8S*SmBNxLn={tDP;{-nKhzNqAd;uYg3MwvuvX%f{eZnEBxB!Ea z01icfRwRJ3V6jrQImVCD4`^_y;iH-*$M}nsr^!2nTb8XSu93O==|8<+JUGRr9gqM3 N002ovPDHLkV1oFXP?P`w literal 0 HcmV?d00001