<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Agbai Iroha on Medium]]></title>
        <description><![CDATA[Stories by Agbai Iroha on Medium]]></description>
        <link>https://medium.com/@akiroha27?source=rss-a31149c84746------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7SdCgn8pPRtXGAVykVuezg.jpeg</url>
            <title>Stories by Agbai Iroha on Medium</title>
            <link>https://medium.com/@akiroha27?source=rss-a31149c84746------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 22:38:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akiroha27/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Everything Is Possible]]></title>
            <link>https://akiroha27.medium.com/everything-is-possible-d24fde30b606?source=rss-a31149c84746------2</link>
            <guid isPermaLink="false">https://medium.com/p/d24fde30b606</guid>
            <category><![CDATA[mentorship]]></category>
            <category><![CDATA[community]]></category>
            <category><![CDATA[life-lessons]]></category>
            <dc:creator><![CDATA[Agbai Iroha]]></dc:creator>
            <pubDate>Sat, 08 Feb 2025 23:30:00 GMT</pubDate>
            <atom:updated>2025-02-08T23:30:00.138Z</atom:updated>
            <content:encoded><![CDATA[<p>I had the privilege of being invited as a guest speaker at the <a href="https://lenaharrisfoundation.com/">Lena Harris Foundation</a>, where I shared some key lessons and values that have shaped my journey. As I prepared for the presentation, I realized these insights could reach even more people through writing, so here we are.</p><h3>Background</h3><p>My name is Agbai Iroha. When I was four years old, my family of six migrated to America with just one suitcase. We lived in Jersey City for a few years before settling in Union, NJ, where I grew up. I played football at Union High School, which led me to earn a full scholarship to Monmouth University. There, I played defensive back and linebacker while majoring in software engineering. I’ve now been working as an engineer for seven years.</p><p>Throughout my life, I’ve been shaped by my parents, siblings, coaches, and mentors. I hope these lessons resonate with you as they have with me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0j7JZG8PWRapHx2XDSji0g.jpeg" /><figcaption>My family and I shortly after our arrival in 2000</figcaption></figure><h3>Be Coachable</h3><p>If there’s one thing football taught me that carried over into my career, it’s this: <strong>you don’t know everything.</strong> What you don’t know is greater than what you do. The turning point in life is when you humble yourself enough to learn.</p><p>Being coachable means being open to correction and applying it to improve. When someone takes the time to coach, correct, or even reprimand you, it’s usually because they believe in you. Don’t take it for granted.</p><h3>The Company You Keep</h3><p>My father always emphasized: <strong>“Show me your friends, and I will tell you who you are.”</strong></p><p>Surround yourself with people who align with your goals. As young adults, the people you spend the most time with shape your future. <em>Iron sharpens iron — stop hanging around dull people.</em> Seek out those who challenge you, hold you accountable, and push you to grow. Be that person in their lives as well.</p><h3>Be About It</h3><p>“Don’t talk about it, be about it.”</p><p>During my final collegiate year, I played linebacker under Coach Andrew Kirkland, and this was one of his key phrases. Another coach, Jeff Gallo, who recruited me to Monmouth, had a similar mantra: <strong>“Performance over perception.”</strong></p><p>Stop announcing what you’re going to do — just do it. Focus on results and execution. Your work will speak for itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GvL1YJvu1ZXZ1k-p" /><figcaption>Celebrating a big 4th-down stop against conference rivals, Charleston Southern University</figcaption></figure><h3>Catch the Black Sheep</h3><p>Growing up in an Igbo household, I heard many proverbs. One that stuck with me is <strong>“Catch the black sheep while the sun is up.”</strong> In other words, seize opportunities when they come, because second chances aren’t always guaranteed.</p><p>Stay ready so you don’t have to get ready. Preparation creates opportunities. Don’t be the person who looks back at life wondering, <em>“What if I had tried harder?”</em></p><h3>Give It Your All</h3><p>My father always said, <strong>“Anything worth doing is worth doing well.”</strong></p><p>If you’re going to spend your time on something, why not give it your best effort? Don’t waste your own time, nor the time of those who believe in you. If someone doubts you, use that as fuel. Prove them wrong. More importantly, prove yourself right.</p><h3>What Does Being an Adult Mean to You?</h3><p>I asked this question to the students, and they had great answers: responsibility, accountability, taking care of your family. I summed it up in one statement:</p><blockquote><strong><em>“Being an adult means doing what you have to do, even when you don’t feel like it.”</em></strong></blockquote><h3>Ask, Seek, Knock</h3><p>As mentioned earlier, you don’t know everything. When you’re stuck, seek guidance from those who have been in your shoes. One thing I learned early in my career: <strong>when asking for help, bring potential solutions with your problem.</strong></p><p>Never be afraid to say, <strong>“I don’t know.”</strong> Asking for help is a strength, not a weakness.</p><h3>No Man Is an Island</h3><p>My father still reminds my siblings and me of this truth. My mother pairs it with another:</p><p><strong>“A problem shared is a problem half solved.”</strong></p><p>Don’t bottle things up. Lean on your loved ones. You may feel like you’re burdening them, but trust me — they would rather hear from you than hear that something bad happened to you.</p><h3>Rest and Reset</h3><p>The grind is real, but so is burnout. If you don’t make time to rest, your body will make the time for you.</p><p>Have hobbies that help you unwind. For me, it’s playing a few games of Madden after work. Find what helps you recharge and make it a priority.</p><h3>Think Before You Act</h3><p>Control your emotions — don’t let them control you.</p><p>Getting angry is part of life, but don’t make impulsive decisions in the heat of the moment. Before I left for college, my father gave me this advice: <strong>“If you can control your tongue and your urges, you will go far in life.”</strong></p><p>When you feel the urge to react harshly, pause. Take a deep breath. Go for a walk. It could save your future.</p><h3>How Will You Respond?</h3><p>Hardship is guaranteed in life. What matters is how you respond to it.</p><p>My first high school coach, Brian Sheridan, used to tell us: <strong>“When things are going well, stay together. When things are going bad, stay together.”</strong></p><p>Tough times don’t give you an excuse to push people away. Everyone is going through something. Adversity isn’t an excuse to be unkind.</p><p><strong>Rest in peace, Coach Sheridan.</strong></p><h3>Matthew 19:26</h3><blockquote><strong><em>“Humanly speaking, it is impossible. But with God, everything is possible.”</em></strong></blockquote><p>This isn’t an easy list of do’s and don’ts. I still miss the mark sometimes, but I try not to be too hard on myself. I take things one day at a time, keeping my faith in God. With Him, everything is possible.</p><h3>Special Thanks</h3><p>Shout out to Joseph Johnson, a fellow Monmouth alum, whose family founded this incredible initiative. Thank you for this opportunity.</p><p>To the mentors I met at the event, including Monmouth alumni and a close family friend from church — you are making a real impact. May the energy you pour into these kids be returned to you in abundance.</p><p>To the <a href="https://lenaharrisfoundation.com/"><strong>Lena Harris Foundation</strong></a>, your work in shaping future leaders is invaluable. May God continue to sustain and grow your mission.</p><p>And to you — if you’ve made it this far, thank you for reading. <strong>God bless you.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d24fde30b606" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Good-bye to in-person voting]]></title>
            <link>https://akiroha27.medium.com/good-bye-to-in-person-voting-1fe3e78e9380?source=rss-a31149c84746------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fe3e78e9380</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[twilio]]></category>
            <category><![CDATA[supabase]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Agbai Iroha]]></dc:creator>
            <pubDate>Thu, 06 Jul 2023 04:33:38 GMT</pubDate>
            <atom:updated>2023-07-14T22:06:57.630Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey — if you’re new here, I’m Agbai Iroha and I’m from Nkporo (<a href="https://medium.com/@akiroha27/what-does-agbai-mean-44f31def4a5c">What’s my name</a>). Relevance? This article is all about Nkporo…mostly.</p><p>I belong to an organization called N.D.U.U.S.A., Nkporo Development Union, USA branch. Our goals include promoting unity here in America while preserving our cultural heritage, amongst other things. Every 4 years we have our election for various positions. The issue is that for years we’ve been holding these elections in person and they last hours on end. I volunteered to build an election system and that’s what the remainder of this article will be about.</p><h3>The Solution</h3><p>I came up with the idea of building an election system for the community. One that will allow members to vote from anywhere in the country, all they would need is to have internet access + are financially active.</p><h3>The Tech Stack</h3><ul><li><a href="https://nextjs.org/">NextJS</a></li><li><a href="https://supabase.com/">Supabase</a></li><li><a href="https://www.typescriptlang.org/">Typescript</a></li><li><a href="https://redux-toolkit.js.org/">Redux/Redux Toolkit</a></li><li><a href="https://tailwindcss.com/">TailwindCSS</a>/<a href="https://daisyui.com/">DaisyUI</a></li><li><a href="https://www.twilio.com/en-us?utm_source=google&amp;utm_medium=cpc&amp;utm_term=twilio&amp;utm_campaign=G_S_NAMER_Brand_ROW_RLSA&amp;cq_plac=&amp;cq_net=g&amp;cq_pos=&amp;cq_med=&amp;cq_plt=gp&amp;gad=1&amp;gclid=CjwKCAjwqZSlBhBwEiwAfoZUIO6jTy0ExV6bNUQ_JcS1DZSAJcAk2bGqbQtoR44ISm1VhmRFcP9G7xoCVGQQAvD_BwE">Twilio</a></li></ul><h3>Use Cases</h3><h4>User</h4><ol><li>A user will be able to confirm their identity via phone number and password combination</li><li>A user will be able to vote<br> — The polls must be open<br> — The user must be of good financial standing</li><li>A user will be able to view the results of the election<br> — Once polls close</li></ol><h4>Admin User (extends User)</h4><ol><li>An admin user will be able to manage members in the system.<br> — This includes; creating, deleting, updating, and texting members</li><li>An admin user will be able to manage the voting positions and options<br> — This includes; creating, deleting, and updating positions/options</li></ol><h4>System</h4><ol><li>The system will host user and election data</li><li>The system will generate passwords for users upon creation</li><li>The system will send out text messages to users</li></ol><h3>Entities</h3><h4>Election Year</h4><p>Represents an election year.</p><ul><li>The time that voting starts: Timestamp — the time that voting will be open</li><li>The time that voting ends: Timestamp — the time that voting will be closed</li></ul><h4>User</h4><p>Represents the members of the organization. Can be a regular member or an admin. All users will be authenticated using their phone number and assigned passwords. All users will be able to vote but only admin users can manage users in the system as well as voting options. All users should be able to see the voting results and breakdown.</p><ul><li>Name: String — the name of the user</li><li>Phone: String — the phone number of the user</li><li>Password: String — an auto-generated password that will be assigned to the user</li><li>Type: String — user type. (regular, admin)</li><li>Branch: String — the NDUUSA branch that a user belongs to (NJ, NY, MA, South)</li><li>Active: Boolean — whether or not the user is financially active and able to vote.</li><li>Voted: Boolean — whether or not the user has completed voting for the election</li></ul><h4>Voting Position</h4><p>Represents a position that needs to be voted for.</p><ul><li>Title: String — the title of the position</li><li>Election Year: Reference (election year) — The election year that this voting position is for</li></ul><h4>Voting Position Option</h4><p>Represents an option for a voting position</p><ul><li>Name: String — person’s name</li><li>Voting Position: Reference (voting position) — the voting position that the option belongs to</li></ul><h4>User Vote</h4><p>Represents a user’s vote</p><ul><li>User: Reference (user) — the user that the user vote belongs to</li><li>Voting Position: Reference (voting position) — the voting position that the user vote belongs to</li><li>Voting Position Option: Reference (voting position option) — the voting position option that the user selected</li><li>Election Year: Reference (election year) — The election year that this vote is for</li></ul><h3>Schema</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2UDR1DtyNqL3YcLV9PnnKg.png" /><figcaption>NDUUSA Election Database Schema</figcaption></figure><h3>Screenshots/GIFs</h3><h4>Login</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZxWtHv7s1szOHcw8WBzg6g.png" /><figcaption>Login screen</figcaption></figure><h4>User Management</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*PllHG7m8qFwh4KwBJpLyag.gif" /></figure><h4>Password Text Message</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*k3szQLyQ95olhYGgXpSmgA.png" /></figure><h4>Voting positions/options</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*nYtENP-cJnKqQt9MaizISA.gif" /></figure><h4>Casting votes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zdKigz-dz8DdGH3ZK11tIg.png" /><figcaption>Financially inactive user</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eh05uEiKGvozJnB8U8bMMA.png" /><figcaption>Active user — polls not open</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*YoLzbk66y_0yCfKtzI3xWg.gif" /><figcaption>Active user—voting</figcaption></figure><h4>Viewing results</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Q3Oem5cT8Xrhcb8poblo1g.gif" /><figcaption>Voting results</figcaption></figure><h3>Conclusion</h3><p>Well, that’s the end of the article. If you made it this far, you’re appreciated. There are still some things to sort out like hosting the site on Vercel or maybe adding a feature for handling tie-breakers. Either way, I’m happy with the progress I made in 2 weeks. What do you think? I’m open to answering any questions or just hearing some constructive criticism.</p><h3>Repo</h3><p><a href="https://github.com/Akiroha/nduusa_election_system">https://github.com/Akiroha/nduusa_election_system</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fe3e78e9380" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My week-long battle with a custom hook]]></title>
            <link>https://akiroha27.medium.com/my-week-long-battle-with-a-custom-hook-c5ed3e9668d7?source=rss-a31149c84746------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5ed3e9668d7</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[side-project]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Agbai Iroha]]></dc:creator>
            <pubDate>Mon, 24 Apr 2023 02:48:31 GMT</pubDate>
            <atom:updated>2023-04-24T02:48:31.053Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong><em>useDropdown</em></strong></h4><p>That’s the name of my custom hook that’s currently being reused in my application in <strong>18 components</strong> (and counting).</p><p>The thought behind it was rather simple. I started writing the code for my application, and after copying/pasting a few times, I realized that the use case for displaying a dropdown menu for my users to make a selection or take some action is going to be very common (<strong>18 components and counting</strong>) so I decided to make it a custom hook.</p><p>The useDropdown hook is comprised of:</p><ul><li>A reference to another custom hook that monitors the device’s width</li><li>A couple of local state variables</li><li>A couple of useEffect methods</li><li>The 3 methods that handle the logic; open, close, blur</li></ul><h4>Local state variables</h4><pre>const [mainClass, setMainClass] = useState(&#39;dropdown&#39;);<br>const [mousePos, setMousePos] = useState&lt;{ mouseX: number; mouseY: number }&gt;({<br>    mouseX: 0,<br>    mouseY: 0,<br>  });</pre><ul><li>In my application, I use <a href="https://tailwindcss.com/">Tailwind</a> and <a href="https://daisyui.com/">DaisyUI</a> for the bulk of the styling and some in-line styling on special occasions. The mainClass state variable starts off with the value of ‘dropdown’, this means whichever component has its className set to this will inherit DaisyUI’s dropdown functionality.</li><li>The mousePos state variable is used to track the position of the user’s mouse/finger as long as the component is rendered. Spoiler alert, this is how I solved the main issue I was facing.</li></ul><h4>useEffect methods</h4><pre>useEffect(() =&gt; {<br>  const handleMouseMove = (event: MouseEvent) =&gt; {<br>    setMousePos({ mouseX: event.clientX, mouseY: event.clientY });<br>  };<br><br>  window.addEventListener(&#39;mousemove&#39;, handleMouseMove);<br><br>  return () =&gt; {<br>    window.removeEventListener(&#39;mousemove&#39;, handleMouseMove);<br>  };<br>}, []);<br><br>useEffect(() =&gt; {<br>  let dropPositions: string[] = [];<br><br>  const mainBound = mainRef?.current?.getBoundingClientRect();<br>  if (mainBound) {<br>    const { x, y } = mainBound;<br>    if (windowWidth - x &lt; 500) dropPositions.push(&#39;dropdown-left&#39;);<br>    if (windowHeight - y &lt; 200) dropPositions.push(&#39;dropdown-top&#39;);<br>  }<br><br>  let val = `dropdown ${dropPositions.join(&#39; &#39;)}`;<br><br>  setMainClass(val.trim());<br>}, [mainRef, windowWidth, windowHeight]);</pre><ul><li>The first just adds and removes a mousemove event listener in order to keep the mousePos state variable up to date.</li><li>The second dictates the position of the dropdown menu. By default, DaisyUI will display the menu content at the bottom. This useEffect method makes the menu display to the left and/or top if necessary (based on the position of the mainRef component relative to the screen width and height).</li></ul><h4>Methods for the logic</h4><p>The <strong>open</strong> method just adds ‘dropdown-open’ to the mainClass state variable. This is how the dropdown menu is displayed.</p><pre>const open = () =&gt; {<br>    setMainClass((old) =&gt; {<br>      let val = old.includes(dropdownOpen) ? old : old + ` ${dropdownOpen}`;<br>      return val.trim();<br>    });<br>  };</pre><p>The <strong>close</strong> method removes ‘dropdown-open’ from the mainClass state variable and programmatically blurs the current activeElement (ensures that the dropdown menu closes).</p><pre>const close = () =&gt; {<br>  setMainClass((old) =&gt; {<br>    let val = old.replace(dropdownOpen, &#39;&#39;);<br>    return val;<br>  });<br><br>  try {<br>    (document.activeElement as HTMLElement).blur();<br>  } catch (error) {}<br>};</pre><p>The <strong>blur</strong> method checks the x and y positions of the user’s mouse/finger relative to the dropdownRef component. If the tap is outside of the dropdownRef component, we’ll call the close method.</p><pre>const blur = () =&gt; {<br>  const mainBound = dropdownRef?.current?.getBoundingClientRect();<br>  if (mainBound) {<br>    const { left, right, top, bottom } = mainBound;<br>    const { mouseX, mouseY } = mousePos;<br>    if (<br>      !(<br>        mouseX &gt;= left &amp;&amp;<br>        mouseX &lt;= right &amp;&amp;<br>        mouseY &gt;= top &amp;&amp;<br>        mouseY &lt;= bottom<br>      )<br>    ) {<br>      // Mouse is outside element.<br>      close();<br>    }<br>  }<br>};</pre><p>Now, I know what you’re thinking. “Agbai, this is stupid simple, why did it take you a week to figure it out???” Well for one, I have a job and life that takes precedence over this application that I’m building so some days I don’t get to work on it. So when I say a week, it was really like 10 hours broken up lol. But what really tripped me up was that there were places where I would call the dropdown.close() method on the main components onBlur and it would close the menu without taking the action that was clicked. Figuring this out took more time than I’m proud to share but I came up with the blur method to solve this.</p><h3><strong>Use cases</strong></h3><h4>With onBlur</h4><p>This is the most common use case where we have an element that needs to display a dropdown menu but if the user clicks out of the menu, the menu needs to be closed.</p><pre>const mainRef = useRef&lt;HTMLDivElement&gt;(null);<br>const dropdownRef = useRef&lt;HTMLUListElement&gt;(null);<br>const dropdown = useDropdown(mainRef, dropdownRef);<br><br>const handleOptionClick = (value: string) =&gt; {<br>  dropdown.close();<br>  handleSoleRecordAction(mixerEvent, value);<br>};<br><br>&lt;div className={dropdown.mainClass} ref={mainRef}&gt;<br>  &lt;label<br>    tabIndex={0}<br>    className=&quot;cursor-pointer text-white dark:text-black&quot;<br>    onClick={() =&gt; dropdown.open()}<br>    onBlur={() =&gt; dropdown.blur()}<br>  &gt;<br>    &lt;svg<br>      xmlns=&quot;http://www.w3.org/2000/svg&quot;<br>      viewBox=&quot;0 0 20 20&quot;<br>      fill=&quot;currentColor&quot;<br>      className=&quot;w-5 h-5&quot;<br>    &gt;<br>      &lt;path d=&quot;M10 3a1.5 1.5 0 110 3 1.5 1.5 0 010-3zM10 8.5a1.5 1.5 0 110 3 1.5 1.5 0 010-3zM11.5 15.5a1.5 1.5 0 10-3 0 1.5 1.5 0 003 0z&quot; /&gt;<br>    &lt;/svg&gt;<br>  &lt;/label&gt;<br>  &lt;ul<br>    tabIndex={0}<br>    className=&quot;dropdown-content menu p-1 bg-white shadow rounded-box w-auto&quot;<br>    ref={dropdownRef}<br>  &gt;<br>    {dropdownOptions.map((option) =&gt; {<br>      return (<br>        &lt;li<br>          key={option.value}<br>          className=&quot;text-black text-2xs md:text-base lg:text-lg&quot;<br>        &gt;<br>          &lt;a onClick={() =&gt; handleOptionClick(option.value)}&gt;<br>            {option.label}<br>          &lt;/a&gt;<br>        &lt;/li&gt;<br>      );<br>    })}<br>  &lt;/ul&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*kE5k5u4eZTD0HfWOwumSLw.gif" /></figure><h4>Without onBlur (button to close)</h4><p>This is the rare use case that exposed the flaw in my old useDropdown and prompted me to do the refactor. There are times when we want the dropdown menu to persist regardless of where the user has clicked. The only way that we want the menu to close is if the user deliberately clicks a button to close the menu.</p><pre>const mainRef = useRef&lt;HTMLDivElement&gt;(null);<br>const dropdownRef = useRef&lt;HTMLDivElement&gt;(null);<br>const dropdown = useDropdown(mainRef, dropdownRef);<br><br>const handleUpdate = () =&gt; {<br>  dropdown.close();<br>};<br><br>&lt;div className={dropdown.mainClass} ref={mainRef}&gt;<br>  &lt;label<br>    tabIndex={0}<br>    className=&quot;bg-primary text-white rounded-md px-1 font-bold flex h-full cursor-pointer&quot;<br>    onClick={() =&gt; dropdown.open()}<br>  &gt;<br>    &lt;div className=&quot;flex items-center text-xs lg:text-base&quot;&gt;<br>      &lt;div&gt;Filter&lt;/div&gt;<br>      &lt;svg<br>        xmlns=&quot;http://www.w3.org/2000/svg&quot;<br>        viewBox=&quot;0 0 20 20&quot;<br>        fill=&quot;currentColor&quot;<br>        className=&quot;w-5 h-5&quot;<br>      &gt;<br>        &lt;path<br>          fillRule=&quot;evenodd&quot;<br>          d=&quot;M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z&quot;<br>          clipRule=&quot;evenodd&quot;<br>        /&gt;<br>      &lt;/svg&gt;<br>    &lt;/div&gt;<br>  &lt;/label&gt;<br>  &lt;div<br>    tabIndex={0}<br>    className=&quot;dropdown-content menu p-1 shadow bg-white rounded-lg w-64 mt-0 lg:mt-2 flex flex-col&quot;<br>    ref={dropdownRef}<br>  &gt;<br>    &lt;div className=&quot;flex flex-col p-1&quot;&gt;<br>      {radioOptions.map((option) =&gt; (<br>        &lt;div key={option.value} className=&quot;form-control&quot;&gt;<br>          &lt;label className=&quot;label cursor-pointer&quot;&gt;<br>            &lt;span className=&quot;label-text font-bold text-black text-sm&quot;&gt;<br>              {option.label}<br>            &lt;/span&gt;<br>            &lt;input<br>              type=&quot;radio&quot;<br>              className=&quot;radio radio-primary radio-xs&quot;<br>              checked={focus === option.value}<br>              onChange={() =&gt; setFocus(option.value)}<br>            /&gt;<br>          &lt;/label&gt;<br>        &lt;/div&gt;<br>      ))}<br>    &lt;/div&gt;<br>    &lt;div className=&quot;flex-auto flex flex-col border-t-2 gap-1 p-1 w-64&quot;&gt;<br>      &lt;div className=&quot;font-bold text-primary&quot;&gt;Filter by member&lt;/div&gt;<br>      &lt;input<br>        className=&quot;text-black outline-none text-sm border-black border-2 rounded-lg p-1&quot;<br>        placeholder=&quot;Search team&quot;<br>        value={search}<br>        onChange={(e) =&gt; setSearch(e.target.value)}<br>      /&gt;<br>      {selected.length !== 0 &amp;&amp; (<br>        &lt;div className=&quot;flex justify-between items-center&quot;&gt;<br>          &lt;label&gt;<br>            &lt;button<br>              className=&quot;btn btn-xs btn-ghost&quot;<br>              onClick={() =&gt;<br>                setSelected(dummyTeamMembers.map((member) =&gt; member.id!))<br>              }<br>            &gt;<br>              select all<br>            &lt;/button&gt;<br>          &lt;/label&gt;<br>          &lt;label&gt;<br>            &lt;button<br>              className=&quot;btn btn-xs btn-ghost&quot;<br>              onClick={() =&gt; setSelected([])}<br>            &gt;<br>              unselect all<br>            &lt;/button&gt;<br>          &lt;/label&gt;<br>        &lt;/div&gt;<br>      )}<br>      &lt;div className=&quot;flex flex-col gap-1 h-auto max-h-64 overflow-y-auto&quot;&gt;<br>        {dummyTeamMembers.map((member) =&gt; (<br>          &lt;div key={member.id}&gt;<br>            &lt;label className=&quot;label cursor-pointer&quot;&gt;<br>              &lt;span className=&quot;label-text font-bold text-black text-sm text-ellipsis overflow-hidden&quot;&gt;<br>                {member.user}<br>              &lt;/span&gt;<br>              &lt;input<br>                type=&quot;checkbox&quot;<br>                className=&quot;checkbox checkbox-primary checkbox-xs&quot;<br>                checked={selected.includes(member.id!)}<br>                onChange={(event) =&gt; handleSelect(event, member.id!)}<br>              /&gt;<br>            &lt;/label&gt;<br>          &lt;/div&gt;<br>        ))}<br>      &lt;/div&gt;<br>      &lt;div className=&quot;flex justify-between items-center&quot;&gt;<br>        &lt;button onClick={() =&gt; dropdown.close()}&gt;cancel&lt;/button&gt;<br>        &lt;button onClick={() =&gt; handleUpdate()}&gt;update&lt;/button&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*1KRLtcFSjMKSR5s1V_pvVg.gif" /></figure><h3>Before and After</h3><p>Here is the comparison of the useDropdown hook before and after the refactor.</p><h4>Before</h4><pre>import { useState } from &#39;react&#39;;<br><br>const useDropdown = (initClass: string) =&gt; {<br>  const [clicked, setClicked] = useState(false);<br>  const hiddenClass = initClass + &#39; hidden&#39;;<br>  const [contentClass, setContentClass] = useState(hiddenClass);<br><br>  const toggleContentClass = () =&gt; {<br>    setClicked((oldClicked) =&gt; {<br>      if (oldClicked) {<br>        setContentClass(hiddenClass);<br>      } else {<br>        setContentClass(initClass);<br>      }<br>      return !oldClicked;<br>    });<br>  };<br><br>  const handleReset = () =&gt; {<br>    setClicked(false);<br>    setContentClass(hiddenClass);<br>  };<br><br>  return { contentClass, clicked, toggleContentClass, setClicked, handleReset };<br>};<br><br>export default useDropdown;</pre><h4>After</h4><pre>import { RefObject, useEffect, useState } from &#39;react&#39;;<br>import useWindowDimensions from &#39;./useWindowDimensions&#39;;<br><br>const dropdownOpen = &#39;dropdown-open&#39;;<br><br>const useDropdown = (<br>  mainRef: RefObject&lt;HTMLDivElement&gt;,<br>  dropdownRef: RefObject&lt;HTMLDivElement | HTMLUListElement&gt;<br>) =&gt; {<br>  const [mainClass, setMainClass] = useState(&#39;dropdown&#39;);<br>  const { windowWidth, windowHeight } = useWindowDimensions();<br>  const [mousePos, setMousePos] = useState&lt;{ mouseX: number; mouseY: number }&gt;({<br>    mouseX: 0,<br>    mouseY: 0,<br>  });<br><br>  useEffect(() =&gt; {<br>    const handleMouseMove = (event: MouseEvent) =&gt; {<br>      setMousePos({ mouseX: event.clientX, mouseY: event.clientY });<br>    };<br><br>    window.addEventListener(&#39;mousemove&#39;, handleMouseMove);<br><br>    return () =&gt; {<br>      window.removeEventListener(&#39;mousemove&#39;, handleMouseMove);<br>    };<br>  }, []);<br><br>  useEffect(() =&gt; {<br>    let dropPositions: string[] = [];<br><br>    const mainBound = mainRef?.current?.getBoundingClientRect();<br>    if (mainBound) {<br>      const { x, y } = mainBound;<br>      if (windowWidth - x &lt; 600) dropPositions.push(&#39;dropdown-left&#39;);<br>      if (windowHeight - y &lt; 200) dropPositions.push(&#39;dropdown-top&#39;);<br>    }<br><br>    let val = `dropdown ${dropPositions.join(&#39; &#39;)}`;<br><br>    setMainClass(val.trim());<br>  }, [mainRef, windowWidth, windowHeight]);<br><br>  const open = () =&gt; {<br>    setMainClass((old) =&gt; {<br>      let val = old.includes(dropdownOpen) ? old : old + ` ${dropdownOpen}`;<br>      return val.trim();<br>    });<br>  };<br><br>  const close = () =&gt; {<br>    setMainClass((old) =&gt; {<br>      let val = old.replace(dropdownOpen, &#39;&#39;);<br>      return val;<br>    });<br><br>    try {<br>      (document.activeElement as HTMLElement).blur();<br>    } catch (error) {}<br>  };<br><br>  const blur = () =&gt; {<br>    const mainBound = dropdownRef?.current?.getBoundingClientRect();<br>    if (mainBound) {<br>      const { left, right, top, bottom } = mainBound;<br>      const { mouseX, mouseY } = mousePos;<br>      if (<br>        !(<br>          mouseX &gt;= left &amp;&amp;<br>          mouseX &lt;= right &amp;&amp;<br>          mouseY &gt;= top &amp;&amp;<br>          mouseY &lt;= bottom<br>        )<br>      ) {<br>        // Mouse is outside element.<br>        close();<br>      }<br>    }<br>  };<br><br>  return {<br>    mainClass,<br>    open,<br>    close,<br>    blur,<br>  };<br>};<br><br>export default useDropdown;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5ed3e9668d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hackathon idea turned Salesforce unlocked package]]></title>
            <link>https://akiroha27.medium.com/hackathon-idea-turned-salesforce-unlocked-package-71f3f67c98b8?source=rss-a31149c84746------2</link>
            <guid isPermaLink="false">https://medium.com/p/71f3f67c98b8</guid>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[unlocked-packages]]></category>
            <category><![CDATA[salesforce-security]]></category>
            <category><![CDATA[salesforce-apex]]></category>
            <category><![CDATA[lightning-web-component]]></category>
            <dc:creator><![CDATA[Agbai Iroha]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 00:40:24 GMT</pubDate>
            <atom:updated>2022-10-04T00:40:24.551Z</atom:updated>
            <content:encoded><![CDATA[<p>“Sitetracker packaged application that provides insight into an org’s users’ object and field level security.”</p><p>Back in December of 2021, <a href="https://www.sitetracker.com/">Sitetracker</a> hosted a virtual and internal hackathon which allowed us to build our own team and work on anything our hearts desired. I got to team up with some dope engineers that I don’t usually work with and we decided to tackle Salesforce permissions **shivers**. Anyone that works in Salesforce daily can confirm that while permissions can be used to make an org very secure, they can also be confusing/a burden when debugging. Long story short, we built a very MVP version of a component which made navigating permissions less cumbersome. We walked away with the “Technical Marvel” award. Some months down the line, I freed up a bit and decided to make the component an unlocked package that can be installed and used in any Salesforce instance where permissions can be a nuisance *cough* all of them *cough*. My favorite part about it is that I use it every single day when building customizations or just debugging my clients’ Salesforce instances. Below are the features of the unlocked package.</p><h3>Search By User</h3><p>This feature allows you to search for active users in your org. Once a user is selected, their profile and permission sets are displayed. Additionally, a table is rendered that breaks down object permissions. This table can be filtered to search for a certain object. Each row has an action section that allows you to see which profile and permission set(s) are giving the user read, edit, create, delete, modify all, and/or view all access. Alternatively, you can click the button in the action menu that allows you to view field access. Clicking the “eye” action button gives you a similar breakdown of why a user has read/edit access to each field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xV91d0TW3bhmMsIWUOjnAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*eFet3KxDTEYRmJON8Cf4QA.png" /></figure><h3>Export Fields</h3><p>This button generates and downloads an excel spreadsheet that has a breakdown of all of the fields in your Salesforce instance. The columns are Object, Field Label, API Name, and Data Type.</p><h3>Compare *newest*</h3><p>This button opens up a modal that allows you to choose one of three types of entities to compare: Users, Permission Sets, or Profiles. Once selected, search for and select two different entities to compare. Once compared, you have the ability to filter by object name. For each row, you can click the “plus” button and view the permission disparity (if any) at both the object and field level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*1QHgzINXo61lBjLK9nQpJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XCDSVy_kuXrl6696Lmj98A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IpQPzsUG9cEIRV_8NT-RWA.png" /></figure><h3>See for yourself</h3><p>Want to try the unlocked package? It’s free to install in your org and doesn’t introduce any new objects. Steps to install</p><ol><li>Open up your org and add this link after your org URL /packaging/installPackage.apexp?p0=04t6T000001IG4WQAW</li><li>Leave “Install for Admins Only” selected</li><li>Expand Advanced Options</li><li>Select “Compile only the Apex in the package”</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71f3f67c98b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What does Agbai mean?]]></title>
            <link>https://akiroha27.medium.com/what-does-agbai-mean-44f31def4a5c?source=rss-a31149c84746------2</link>
            <guid isPermaLink="false">https://medium.com/p/44f31def4a5c</guid>
            <category><![CDATA[nigeria]]></category>
            <category><![CDATA[names]]></category>
            <category><![CDATA[igbo]]></category>
            <dc:creator><![CDATA[Agbai Iroha]]></dc:creator>
            <pubDate>Tue, 21 Jun 2022 15:55:18 GMT</pubDate>
            <atom:updated>2022-06-21T16:56:07.431Z</atom:updated>
            <content:encoded><![CDATA[<p>My great friend Chinomso Nwachuku (founder of <a href="https://talknaija.org/">TalkNaija</a>) has been encouraging me to write more + he’s the latest one to ask me this question so I thought I’d share it here.</p><p>My full name is Agbai Kalu Uka Iroha. Kalu is my father’s name. Uka was the name of my late grandfather. As you can imagine, the names are infinite (Oduenyi, Okoroikpo, etc.). This is the naming convention of my people.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*I8fFI9LJnxLjK8xkPcyuXw.jpeg" /></figure><p>Agbai is a very old name in my village (Nkporo Okwe Ancient Kingdom). I was named after my dad’s best friend (Agbai Ude Ndukwe). But to answer the question, it’s a shortened version of the phrase: <strong>Agbainwogu</strong>. In those days, prepubescent death was the norm, so the phrase pretty much means don’t count on that child because they might not make it. To the point, someone boldly asked my parents why they would name their child such?? My parents already had 3 strong children before me. That, coupled with their faith in God, caused them to disregard the traditional negative connotation to the name. They simply named me Agbai to honor their long time friend and knew that they <strong>COULD</strong> count on me making it. To God’s glory I did and still am 💪🏾.</p><p>Interested in the history of my people? Visit the links below:</p><ul><li><a href="https://en.wikipedia.org/wiki/Nkporo">https://en.wikipedia.org/wiki/Nkporo</a></li><li><a href="https://nduusa.org/about-us/objectives/">https://nduusa.org/about-us/objectives/</a></li><li><a href="https://www.sunnewsonline.com/i-want-nigerians-in-diaspora-not-to-forget-home-eze-ogbuagu-of-nkporo/">https://www.sunnewsonline.com/i-want-nigerians-in-diaspora-not-to-forget-home-eze-ogbuagu-of-nkporo/</a></li><li><a href="https://www.wikiwand.com/en/Nkporo">https://www.wikiwand.com/en/Nkporo</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44f31def4a5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Overcoming Apex’s 12 MB Heap Size Limit]]></title>
            <link>https://akiroha27.medium.com/overcoming-apexs-12-mb-heap-size-limit-249c2f4c2bb6?source=rss-a31149c84746------2</link>
            <guid isPermaLink="false">https://medium.com/p/249c2f4c2bb6</guid>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[sharepoint]]></category>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[http-request]]></category>
            <dc:creator><![CDATA[Agbai Iroha]]></dc:creator>
            <pubDate>Sun, 24 Jan 2021 04:45:33 GMT</pubDate>
            <atom:updated>2021-01-24T04:45:33.711Z</atom:updated>
            <content:encoded><![CDATA[<p>Right before the holiday break, I was presented with a new enhancement request. My client uses Salesforce for their day-to-day operations, but they also use Sharepoint to “share” files to external investors who don’t have access to their Salesforce org. This results in them manually uploading files to Salesforce and then repeating the same task in Sharepoint…for over 2k sites! That’s a lot of clicks as you can imagine, so they asked if I could automate this. I was able to deliver this new functionality a couple of weeks upon returning from the holiday break but there was a catch…</p><h3>Failing gracefully.</h3><p>Something that I really focused on was error reporting in the event that the integration failed. If it failed, I wanted it to do so gracefully and I wanted the right people to be notified. Upon failure, I dynamically send an email to a list of addresses described in a <a href="https://help.salesforce.com/articleView?id=sf.custommetadatatypes_about.htm&amp;type=5">Custom Metadata</a> Record in Salesforce. A few days live in production, myself and some other admins received an integration error email 😷 :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*LxRW38eF1-SoEoSPSRAepg.png" /></figure><p>All of my test runs in the sandbox were with files way smaller than 12 MB (happy path 😆 ), but it turns out large PDF files are usually what my client needs to send over. In my design and testing, I did not take <a href="https://developer.salesforce.com/docs/atlas.en-us.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_platform_apexgov.htm">Apex Governor Limits</a> into account. So Salesforce has a total heap size asynchronous limit of 12 MB, how can I solve this??</p><h3>Email Service Hack</h3><p>I was stumped at first, I spent hours on google trying to find a workaround for making an HTTP callout with such big files but to no avail. But then I read the fine print at the governor limits article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*twA4vRYTrBX1E8_nGMGPNw.png" /></figure><p>Ah ha! Email services have a larger heap size (3x)…but how do I take advantage of that? I’m pretty familiar with <a href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_inbound_what_is.htm">Email Services</a> in Salesforce and have done some pretty dope things with them in the past, but that’s a story for another Medium article. I had to figure out a way to leverage this increased heap size limit, but it also had to be programmatic in the sense that the user just triggers the update and they don’t have to take an extra step like emailing the file. In my head, it made sense, but saying it out loud to my manager, even I thought I sounded crazy. The idea was crazy…crazy enough that it might actually work. Here was the updated logic</p><ul><li>Update triggered on the attachment</li><li>Future callout code is called</li><li>Handle locating/creation of necessary folders and subfolders in Sharepoint via <a href="https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/sharepoint-net-server-csom-jsom-and-rest-api-index">Rest API</a></li><li>Finally push file to Sharepoint — this is where the enhancement occurred and will be broken down further</li></ul><h3>File Push to Sharepoint</h3><p>I had to add some conditional logic for when the file will be uploaded to Sharepoint and it really came down to 3 possible scenarios. Code snippet below</p><ol><li>We’re in a future instance &amp;&amp; file size is less than or equal to 12 MB — safe to push to Sharepoint</li><li>We’re in an email service instance &amp;&amp; file size is less than or equal to 36 MB — safe to push to Sharepoint</li><li>We’re in an email service instance &amp;&amp; file size is greater than 36 MB — send error email to necessary admin users that this file must be manually uploaded</li></ol><pre>if ((!fromEmail &amp;&amp; cv.ContentSize &lt; 12000000) || (fromEmail &amp;&amp; cv.ContentSize &lt; 36000000)) {</pre><pre>// store version data</pre><pre>Blob cvData = cv.VersionData;</pre><pre>String request =</pre><pre>&#39;callout:Sharepoint/_api/Web/GetFolderByServerRelativeUrl(\&#39;Shared Documents/&#39; +</pre><pre>folder +</pre><pre>&#39;/&#39; +</pre><pre>foldername +</pre><pre>&#39;/&#39; +</pre><pre>category +</pre><pre>&#39;\&#39;)/Files/add(url=\&#39;&#39; +</pre><pre>attachmentName +</pre><pre>&#39;\&#39;,overwrite=true)&#39;;</pre><pre>request = request.trim().replace(&#39; &#39;, &#39;%20&#39;);</pre><pre>// add request string to return list</pre><pre>returnList.add(request);</pre><pre>HttpRequest req = new HttpRequest();</pre><pre>req.setEndpoint(request);</pre><pre>req.setMethod(&#39;POST&#39;);</pre><pre>req.setHeader(&#39;Content-Length&#39;, String.valueOf(EncodingUtil.base64Encode(cvData).length()));</pre><pre>req.setBodyAsBlob(cvData);</pre><pre>Http http = new Http();</pre><pre>HTTPResponse res = http.send(req);</pre><pre>// add response body to request list</pre><pre>returnList.add(res.getBody());</pre><pre>if (fromEmail) {</pre><pre>auditRecord.Request__c = returnList[0];</pre><pre>auditRecord.Response__c = returnList[1];</pre><pre>update auditRecord;</pre><pre>}</pre><pre>if (res.getStatusCode() &gt; 299) {</pre><pre>throw new CalloutException(res.getBody());</pre><pre>}</pre><pre>}</pre><pre>// if method isn&#39;t being called from email service and content size is greater than 12 MB send email</pre><pre>if (!fromEmail &amp;&amp; cv.ContentSize &gt; 12000000) {</pre><pre>insert auditRecord;</pre><pre>sendEmail(attachmentId + &#39;;&#39; + auditRecord.Id, Json.serialize(auditRecord), true);</pre><pre>}</pre><pre>// if method is being called from email service and content size is greater than 36 MB throw error</pre><pre>if (fromEmail &amp;&amp; cv.ContentSize &gt; 36000000) {</pre><pre>auditRecord.Failed__c = true;</pre><pre>auditRecord.Integration_Exception__c = true;</pre><pre>auditRecord.Integration_Exception_Message__c = &#39;You must manually upload a file bigger than 36 MB.&#39;;</pre><pre>insert auditRecord;</pre><pre>// create subject and send error email</pre><pre>String subject = &#39;There was an issue sending &#39; + attachment.Name + &#39; to Sharepoint&#39;;</pre><pre>sendEmail(subject, Json.serialize(auditRecord), false);</pre><pre>}</pre><h3>Lessons Learned</h3><ol><li>Take ALL constraints into account when designing</li><li>That it’s possible to programmatically trigger email services + how to do so</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=249c2f4c2bb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>