<?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 Segun Alofun on Medium]]></title>
        <description><![CDATA[Stories by Segun Alofun on Medium]]></description>
        <link>https://medium.com/@segunalofun?source=rss-433a4762b0bc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KPGATHeZnO5sS_tXjYlCcw.jpeg</url>
            <title>Stories by Segun Alofun on Medium</title>
            <link>https://medium.com/@segunalofun?source=rss-433a4762b0bc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 03:52:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@segunalofun/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[Stutern Housemanship — DeliveryCog Documentation by Segun Alofun]]></title>
            <link>https://medium.com/@segunalofun/stutern-housemanship-deliverycog-documentation-by-segun-alofun-fb9797f18b8e?source=rss-433a4762b0bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb9797f18b8e</guid>
            <category><![CDATA[pre-commit]]></category>
            <category><![CDATA[husky]]></category>
            <category><![CDATA[stylelint]]></category>
            <category><![CDATA[lint-staged]]></category>
            <category><![CDATA[stutern]]></category>
            <dc:creator><![CDATA[Segun Alofun]]></dc:creator>
            <pubDate>Sat, 15 Oct 2022 08:55:09 GMT</pubDate>
            <atom:updated>2022-12-12T10:04:35.038Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stutern Housemanship — DeliveryCog Documentation by Segun Alofun</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*XxNQN1ajD6vvizQrTcg2Uw.png" /></figure><h4>Task 1</h4><p><strong>Implement Pre-commit and Pre-push ( Husky, Lint-Staged, StyleLint &amp; Pretty-Quick )</strong></p><p>“Pre-commit and Pre-push hooks are a set of automated commands or scripts that identifies both simple and complicated issues before code submission review. This is so that the code reviewer wouldn’t waste time styling or formatting the codes before making a commit or push.”</p><p>To start with, before you can implement a pre-commit hook into this project. It would be necessary to have the following requirements installed and configured:</p><ul><li><a href="https://reactjs.org/">React App</a></li><li><a href="https://prettier.io/">Prettier</a></li><li><a href="https://eslint.org/">ESlint</a></li><li>For this project, I will be using <a href="https://visualstudio.microsoft.com/">VScod</a>e. Use any IDE(<em>Integrated Development Environment</em>) of your choice.</li></ul><h4>Steps to implement</h4><p><strong>Step 1 — </strong><em>Setting up Pre-commit and Pre-push.</em></p><p>This is a pretty important step. This will ensure that before any developer in your team commits any code, the changes made by him are validated with EsLint, and the code is properly formatted.</p><p><strong>We will need to configure some packages</strong></p><ol><li>The First package we need is <strong>husky </strong>which will make adding these <strong>hooks </strong>very easy.</li><li>We also need a package called <strong>lint-staged</strong> that will let us check only the pages which are changed. So, only the staged files are checked and the rest of the code remains untouched.</li><li><strong>Pretty quick</strong> will check for any unformatted files and format them using <strong>Prettier</strong>.</li></ol><pre>npm install --save-dev husky lint-staged pretty-quick</pre><p>After <strong>installing </strong>these packages we need to add <strong>configuration </strong>for these in our <strong>package.json </strong>file</p><pre>”devDependencies”: {<br><strong> …</strong><br>},<br> “lint-staged”: {<br> “*.js”: “eslint”<br> },<br> “husky”: {<br> “hooks”: {<br> “pre-commit”: “npm run lint-fix lint-staged &amp;&amp; pretty-quick — staged”,<br> “pre-push”: “npm run test:all”<br> }<br> },<br> “test:all”: “set CI=true &amp;&amp; react-scripts test &amp;&amp; npm run lint”<br>}</pre><p><strong>Step 2 —<em> </em></strong><em>Adding StyleLint to Project</em></p><p><strong>(i) Use npm to install stylelint and its standard configuration:</strong></p><pre>npm install --save-dev stylelint stylelint-config-standard</pre><p><strong>(ii) Create a .stylelintrc configuration file in the root of your project:</strong></p><pre>{<br> “extends”: “stylelint-config-standard”,<br> “rules”: {<br> “indentation”: “tab”,<br> “number-leading-zero”: null,<br> “color-hex-case”: [“lower”, { “severity”: “warning” }]<br> }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TtM4k3_yYFG8vQyimg2_BQ.png" /><figcaption><em>A code snippet showing package.json dev dependencies</em></figcaption></figure><p>So, another thing would be if you are using prettier in your project, which in this case, yes. There is a need to turn off conflicting rules that are unnecessary and might affect prettier. See <a href="https://www.npmjs.com/package/stylelint-config-prettier">Prettier’s shared config</a> to do that.</p><p>That’s pretty much it!</p><p>The main objective of pre-commit and pre-push hooks is to have neater and quality codes across any application. I would leave you some resources where you can have a further understanding of the concept of pre-commit and pre-push hook</p><ul><li><a href="https://prettier.io/docs/en/precommit.html">Prettier</a></li><li><a href="https://www.npmjs.com/package/pre-push">Pre-push</a></li><li><a href="https://stylelint.io/user-guide/get-started/">StyleLint</a></li><li><a href="https://www.reactnative.guide/6-conventions-and-code-style/6.2-git-pre-hooks.html">Pre-hooks</a></li><li><a href="https://pre-commit.com/">Pre-commit</a></li><li><a href="https://prettier.io/docs/en/integrating-with-linters.html">Linters</a></li><li><a href="https://eslint.org/">ESlint</a></li><li><a href="https://prettier.io/">Prettier</a></li></ul><h4>Task 2A</h4><blockquote>Design a temporary layout for creating an account(SignUp Page Authentication)</blockquote><p>As a user, I want to be able to create an account using the following information</p><ul><li>first name</li><li>last name</li><li>email</li><li>mobile</li><li>password</li><li>confirm password</li></ul><h4>Step 1</h4><blockquote>Implement the UI Figma design</blockquote><p>Translated the Figma parameters into react and authenticated the create account form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*al_YMbEnsha5fSXWYUfc2w.png" /><figcaption>Create an account layout on react</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*DXu6KuRwfvUbKyC6I3ytIQ.png" /><figcaption>Create an account layout mobile view</figcaption></figure><p>See the<strong> </strong><a href="https://github.com/StuternHousemanship/DELIVERYCOG-Frontend-Project-Team1.1/blob/DYC-1_Onboarding_Features/src/pages/signUp.js"><strong>repo</strong></a><strong> </strong>for the code.</p><blockquote>Authentication</blockquote><p>So, after creating the input fields, you need to authenticate the form to accept data and format the input field. You make use of useState() to change the state of the input fields.</p><pre>import React, { useEffect, useState } from &quot;react&quot;;</pre><pre>const [showPassword, setShowPassword] = useState(false);</pre><pre>// const [value, setValue] = useState();</pre><pre>const [firstName, setFirstName] = useState(&quot;&quot;);</pre><pre>const [lastName, setLastName] = useState(&quot;&quot;);<br></pre><pre>/** handles show Password text */</pre><pre>const handleShowPassword = () =&gt; {</pre><pre>setShowPassword(!showPassword);</pre><pre>};</pre><pre>/** Validates Users Mobile Number */</pre><pre>const handleMobileNumber = () =&gt; {</pre><pre>//</pre><pre>};</pre><pre>const handleSignUp = (e) =&gt; {</pre><pre>e.preventDefault();</pre><pre>// setButtonIsLoading(true);</pre><pre>onboarding.SignUp(firstName, lastName).then((response) =&gt; {</pre><pre>if (response.status === 200) {</pre><pre>const accessToken = response.access_token;</pre><pre>const refreshToken = response.refresh_token;</pre><pre>Cookies.set(&quot;accessToken&quot;, accessToken);</pre><pre>localStorage.setItem(&quot;token&quot;, refreshToken);</pre><pre>}</pre><pre>});</pre><pre>};</pre><h4>Step 3</h4><blockquote>Routing</blockquote><p>Also, there’s a need to handle the routing so dependencies have been installed prior to this. in order to set up yours use this <a href="https://www.npmjs.com/package/react-router-dom">react-router-dom</a> to get started.</p><p>Next, is to create a router component that handles navigating between pages.</p><p>check the <a href="https://github.com/StuternHousemanship/DELIVERYCOG-Frontend-Project-Team1.1/blob/DYC-1_Onboarding_Features/src/routers.js"><strong>repo</strong></a> for code.</p><h4>Step 4</h4><blockquote>Url Routes</blockquote><p>A URL component was created to handle the authenticated routing and unauthenticated routing between pages.</p><pre>/** Authenticated URL Routes */</pre><pre>const AuthRoutes = {</pre><pre>dashboard: &quot;/dashboard&quot;,</pre><pre>};</pre><pre>/** Non Authenticated URL Routes */</pre><pre>const NonAuthRoutes = {</pre><pre>landingPage: &quot;/&quot;,</pre><pre>signUp: &quot;/sign-up&quot;,</pre><pre>logIn: &quot;/login&quot;,</pre><pre>signUpMobile: &quot;/sign-up-mobile&quot;,</pre><pre>};</pre><pre>export { AuthRoutes, NonAuthRoutes };</pre><h4>Task 2B</h4><blockquote>Integrate endpoint from BE to Log In temporary design</blockquote><h4>Step 1</h4><p>So, here a backend documentation was created to get the necessary endpoints to integrate. See the documentation<a href="https://deliverycog.beargaze.com/api/v1/docs/#/Authentication/post_api_v1_auth_login"><em> </em><strong><em>here</em></strong></a><strong>.</strong></p><h4>Step 2</h4><p>Next, we integrate these endpoints. An API folder is located in the src folder to handle the backend endpoints integration for all Authentication pages. Here a post request is sent to the login users</p><pre> /** Send a POST request to Login users */<br>  async Login(email, password) {<br>    const data = {<br>      email,<br>      password,<br>    };<br>    const stringifiedData = JSON.stringify(data);<br><br>    return deliverycogOnboarding.post(&quot;/login&quot;, stringifiedData);<br>  },<br>};</pre><p>A config file that handles the HTTP request is shown <a href="https://github.com/StuternHousemanship/DELIVERYCOG-Frontend-Project-Team1.1/blob/DYC-2_Dashboard_Features/src/config.js"><strong><em>here</em></strong></a><strong><em>. </em>Also, a function that handles the login for users can be seen in the code block below on the login.js<em> </em></strong><a href="https://github.com/StuternHousemanship/DELIVERYCOG-Frontend-Project-Team1.1/blob/DYC-2_Dashboard_Features/src/pages/logIn.js"><strong><em>page</em></strong></a></p><pre>  /** Handle Login to Onboardin Page */<br>  const handleLogin = async (e) =&gt; {<br>    e.preventDefault();<br>    navigate(AuthRoutes.onboardingPage);<br>    // setButtonIsLoading(true);<br>    // console.log(&quot;handleLogin Data&quot;, email, password);<br>    try {<br>      onboarding.Login(email, password).then((response) =&gt; {<br>        if (response.status === 200) {<br>          // console.log(&quot;handleLogin response&quot;, response);<br>          const accessToken = response.access_token;<br>          const refreshToken = response.refresh_token;<br>          Cookies.set(&quot;accessToken&quot;, accessToken);<br>          localStorage.setItem(&quot;token&quot;, refreshToken);<br>          // setButtonIsLoading(false);<br>          navigate(AuthRoutes.dashboard);<br>        }<br>      });<br>    } catch (error) {<br>      // console.error(&quot;handleLogin error&quot;, error);<br>        setTimeout(() =&gt; {<br>          setButtonIsLoading(false);<br>        }, 5000);<br>        navigate(NonAuthRoutes.logOutErrorLayout);<br>      }<br>    }<br>  };</pre><h4>Task 3 A</h4><blockquote>Design forgot password email template for BE to integrate</blockquote><h4>Step 1</h4><blockquote>Implement the UI Figma design for password reset</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_eGIcxSR81Y2UGkoTwa3mA.png" /></figure><h4>Step 2</h4><blockquote>Email Template</blockquote><p>Create a template folder that houses the forgot password design template outside the src folder and create an HTML file using the table, td, and tr, tags to write the codes and make use of in-line styling taking all dimensions into consideration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*sGprwDc3w1-8PMy7wcDTfw.png" /><figcaption>showing the resetPassword email code snip</figcaption></figure><p>See the code in the <a href="https://github.com/StuternHousemanship/DELIVERYCOG-Frontend-Project-Team1.1/blob/DYC-1_Onboarding_Features/email_templates/verify_email/resetPasswordEmail.html"><strong>repo</strong></a>.</p><h4>Task 3B</h4><blockquote>Design create account success and error templates</blockquote><h4>Step 1</h4><blockquote>Implement the UI Figma design</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tm6NwT3AI0d7jZ6SApW8rg.png" /><figcaption>create account success desktop layout</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*Zq1Wt1-csd7mlMP1P3J7tA.png" /><figcaption>create account success mobile layout</figcaption></figure><p>Check the <a href="https://github.com/StuternHousemanship/DELIVERYCOG-Frontend-Project-Team1.1/blob/DYC-1_Onboarding_Features/src/createAccountSuccessLayout.js"><strong>repo</strong></a> for code.</p><h4>Step 2</h4><blockquote>Implement the UI Figma design</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HmUyczsDrlzMo6t-OCzdAA.png" /><figcaption>create account error desktop layout</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*eDP9vicsHlgLvOMiBpca6w.png" /><figcaption>create account mobile layout</figcaption></figure><p>See the code<a href="https://github.com/StuternHousemanship/DELIVERYCOG-Frontend-Project-Team1.1/blob/DYC-1_Onboarding_Features/src/createAccountErrorLayout.js"> <strong><em>here</em></strong></a><strong>…</strong></p><h4>Task 4</h4><blockquote>Implement layout for adding a trip</blockquote><h4>Step 1</h4><p>Get the Figma layout</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AS5cgJpPOoHBZdWDcVvGFw.png" /><figcaption>Add A Trip Layout</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*21KOc10X97hGug0j4CGPTg.png" /><figcaption>Add A Trip Mobile Layout</figcaption></figure><p>See the code <a href="https://github.com/StuternHousemanship/DELIVERYCOG-Frontend-Project-Team1.1/blob/DYC-2_Dashboard_Features/src/pages/addTrip.js"><strong><em>here</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb9797f18b8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>