<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Meera</title>
    <description>The latest articles on DEV Community by Meera (@meera).</description>
    <link>https://dev.to/meera</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F666062%2F7c109fe1-5bff-44d8-aa97-e7ac86b561f5.png</url>
      <title>DEV Community: Meera</title>
      <link>https://dev.to/meera</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/meera"/>
    <language>en</language>
    <item>
      <title>Build an Equipment Checkout App for the Admin Team at Your Company</title>
      <dc:creator>Meera</dc:creator>
      <pubDate>Fri, 31 Dec 2021 05:59:26 +0000</pubDate>
      <link>https://dev.to/appsmith/build-an-equipment-checkout-app-for-the-admin-team-at-your-company-1mhg</link>
      <guid>https://dev.to/appsmith/build-an-equipment-checkout-app-for-the-admin-team-at-your-company-1mhg</guid>
      <description>&lt;p&gt;On average, a mid-sized company uses 75 apps to run its businesses! As teams grow and scale, internal apps, primarily administrative and departmental tools, help in sustaining growth. When manual processes get automated, it leaves more time for organizations to focus on their core growth-related work. Low code tools are an excellent way for businesses to solve their dilemma in allocating engineering resources. Low code platforms can help developers build custom internal applications at a fraction of the time traditional development takes. In this blog, we will build a web application using two low-code tools: Appsmith and Supabase. &lt;/p&gt;

&lt;p&gt;Appsmith lets us drag-and-drop UI components into our application to develop the applications visually. It helps us connect the datasource to the UI components within a browser window. This speeds up the application building process. Supabase is a “Postgres database on the Cloud.” With Supabase, we only need to define table structure and SQL functions. Supabase takes care of generating REST APIs from the database schema. &lt;/p&gt;

&lt;p&gt;As part of this tutorial, we will build an equipment management application. Creating such an application from scratch is laborious and time-consuming. We will use Appsmith and Supabase to rapidly iterate design and development and get feedback from our users early on. Both tools will significantly cut down development time, allowing us to deliver this solution in far less time.&lt;/p&gt;

&lt;p&gt;Let us first understand the application and its uses in more detail. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Use-case&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Consider a video production company. This company has an inventory containing video cameras, lenses, and tripods. Employees borrow the equipment for photoshoots and then bring it back after the photo shoot is completed. The company needs to keep track of the equipment. They also need to make sure that people are accountable for the equipment they take. The company would need to know which employee has the equipment and when it will get returned at any given time.&lt;/p&gt;

&lt;p&gt;Although we are using a video production company as an example in this blog, this scenario applies to other industries, for example, sports clubs that lend equipment to players and software companies that provide computers to their employees for remote work. An inventory system is needed for any organization where employees borrow the equipment to take it to a job site or work remotely. &lt;/p&gt;

&lt;p&gt;We can implement this by using a simple spreadsheet or in paper form. But, spreadsheets or booklets are unmanageable once the equipment list or the number of employees grows. An equipment management system becomes a necessity.&lt;/p&gt;

&lt;p&gt;In this blog, we will learn the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use Appsmith to build web pages and use Supabase as a data store.&lt;/li&gt;
&lt;li&gt;Connect Supabase with Appsmith using REST APIs. This approach eliminates the need to use master database credentials in Appsmith.&lt;/li&gt;
&lt;li&gt;Use Appsmith’s UI widgets to display data.&lt;/li&gt;
&lt;li&gt;Build Forms in Appsmith.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can see the finished application&lt;a href="https://app.appsmith.com/applications/616674d2ea18372f05106464/pages/616674d2ea18372f05106466" rel="noopener noreferrer"&gt; here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We will switch back and forth between Supabase and Appsmith to complete this project. Keep Supabase and Appsmith open on different browser tabs to follow this tutorial. We have a lot to cover, so let’s get started! &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Appsmith and Supabase: Setting Up a Project&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Get Started on Appsmith&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Create a new account on&lt;a href="https://www.appsmith.com/" rel="noopener noreferrer"&gt; Appsmith&lt;/a&gt; (it’s free!), if you are an existing user, log in to your Appsmith account.&lt;/li&gt;
&lt;li&gt;In Appsmith, create a new application. You will see a new Appsmith app with an empty canvas and a sidebar with two directories: Datasources, Widgets, and JS Objects [This is a new feature, read more about it in&lt;a href="https://www.appsmith.com/blog/our-new-js-snippets-feature-helps-you-write-javascript-in-the-appsmith-platform" rel="noopener noreferrer"&gt; this blog&lt;/a&gt;].&lt;/li&gt;
&lt;li&gt;Visit&lt;a href="https://supabase.io/" rel="noopener noreferrer"&gt; Supabase.io&lt;/a&gt; and create an account in another browser tab if you don’t already have one.&lt;/li&gt;
&lt;li&gt;Start a new project in Supabase and create a new organization name, project name, database password, and the region near your user’s location.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Define Database Table&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;The first step is to use Supabase to create database tables. Here are the steps needed to create tables.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the left-hand sidebar to visit Table Editor and create a table by clicking + New table. &lt;/li&gt;
&lt;li&gt;Create a Table ‘equipment’ and add varchar field’ name’ and varchar field ‘image’.&lt;/li&gt;
&lt;li&gt;You can populate the database with sample data. Use ‘Import Data from SpreadSheet’ and this CSV file to follow this tutorial.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create another table and name it the ‘employee’ table. This table contains three fields - id, name. &lt;/p&gt;

&lt;p&gt;Add another table and name it the ‘checkout’ table. This table stores checkout transactions; it contains which employee checked out which equipment.&lt;/p&gt;

&lt;p&gt;This table will have the following fields: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;id, &lt;/li&gt;
&lt;li&gt;created_at, &lt;/li&gt;
&lt;li&gt;equipment_id &lt;/li&gt;
&lt;li&gt;employee_id, &lt;/li&gt;
&lt;li&gt;due_by, &lt;/li&gt;
&lt;li&gt;returned_on and notes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: [Fields’ equipment_id’ and ‘employee_id’ are foreign keys into table ‘equipment’ and ‘employee’, respectively.]&lt;/p&gt;

&lt;p&gt;We will be using this&lt;a href="https://drive.google.com/drive/folders/14TIMP4URsdMH_ONpT7pQkxlV-gt5kBSq" rel="noopener noreferrer"&gt; dataset&lt;/a&gt;. &lt;/p&gt;



&lt;h4&gt;
  
  
  &lt;strong&gt;Connect Appsmith and Supabase&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Go to the Appsmith window. [ See accompanied gif]&lt;/li&gt;
&lt;li&gt;Click on Datasource, create a new datasource and find a new “Curl Import”.&lt;/li&gt;
&lt;li&gt;Goto Supabase dashboard left sidebar, open menu ‘API’ and click on Table ‘Equipment’ and find corresponding Bash API and select a key as ‘anon key’.
&lt;/li&gt;
&lt;li&gt;Copy this text into your clipboard.&lt;/li&gt;
&lt;li&gt;And Paste the text into the Appsmith Curl text box.&lt;/li&gt;
&lt;li&gt;Click ‘Import’.&lt;/li&gt;
&lt;li&gt;Let us rename this API as ‘get_equipment’.&lt;/li&gt;
&lt;li&gt;Save this as a DataSource - name it as ‘StoreRoom_DB’. From now on, we only need to modify the relative URL path (the part with /rest/v1/table_name?query_param) to read other tables, views and invoke functions. Now that is cool! 😎&lt;/li&gt;
&lt;li&gt;Run the API get_equipment and see that we get a successful result.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;You can also use SQL from Supabase and write them as queries.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faskus.how%2Fwp-content%2Fuploads%2F2021%2F12%2Fget_equipment.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faskus.how%2Fwp-content%2Fuploads%2F2021%2F12%2Fget_equipment.gif" alt="get_equipment"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;
  
  
  &lt;strong&gt;Appsmith: Display Table Containing Equipment&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;If you successfully followed the previous step, you will see that the API has successfully returned data. Now, we will display the equipment data in a table.&lt;/li&gt;
&lt;li&gt;On the right-hand side menu under Pages, you will find the ‘Widgets’ option. &lt;/li&gt;
&lt;li&gt;Select a Table Widget and drag it to canvas.&lt;/li&gt;
&lt;li&gt;Open its property pane by clicking on the cog icon on the top-right next to its name. Now to bind the data, use the moustache syntax {{ }} and enter the query name: {{ get_equipment.data }}. This will populate all the data from the query onto the table. The table widget has built-in search, pagination, and filters - without us coding a single line!&lt;/li&gt;
&lt;li&gt;Column ‘image’ field is displayed as a text URL instead of an image. Update the column type for the image field to ‘image’. Now, you should see the image.&lt;/li&gt;
&lt;li&gt;Now, let us add a Button for Checkout. Adding a column to the table widget.&lt;/li&gt;
&lt;li&gt;Change the Column Type to ‘Button’ and change the label to ‘Checkout’.&lt;/li&gt;
&lt;li&gt;We will code the checkout logic bit later.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faskus.how%2Fwp-content%2Fuploads%2F2021%2F12%2Fequipment_list.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faskus.how%2Fwp-content%2Fuploads%2F2021%2F12%2Fequipment_list.gif" alt="equipment"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;
  
  
  &lt;strong&gt;Appsmith: Read Employee Table&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Follow these steps to read the employee table:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Duplicate the get_equipment API - and rename it to ‘get_employee’.&lt;/li&gt;
&lt;li&gt;Change the relative endpoint to /rest/v1/employee?select=*&lt;/li&gt;
&lt;li&gt;Run to make sure you can read all employees.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;Appsmith: Build Equipment Checkout Form&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;We can now build the Checkout form. &lt;/p&gt;

&lt;p&gt;When the user clicks on the checkout button, we will open a modal containing a form. The form will allow users to select an employee and the date when equipment will be returned. &lt;/p&gt;

&lt;p&gt;Here is how we can do it!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drag a Modal widget into the canvas.&lt;/li&gt;
&lt;li&gt;Add a DatePicker to pick the date to return the equipment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We want to set the default return date to a week from today’s date. We can calculate the default return date by adding 7 to today’s date. We can use external libraries such as moment.js inside our Appsmith application, which we will use in our application.&lt;/p&gt;

&lt;p&gt;Replace default date with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{moment().add(7, 'd')}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can read about using external libraries in the Appsmith application&lt;a href="https://docs.appsmith.com/core-concepts/writing-code/ext-libraries" rel="noopener noreferrer"&gt; here&lt;/a&gt;. Now, we need to Select an Employee who will check out the Equipment. For selecting an employee - drag a ‘select' Widget. &lt;/p&gt;

&lt;p&gt;Inside the options, we like to populate the list with employee names. We can derive the full name of an employee by concatenating last_name and first_name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{{
get_employee.data.map(
   (emp)=&amp;gt;{return {'label':emp.name, "value": emp.id }})
}}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faskus.how%2Fwp-content%2Fuploads%2F2021%2F12%2Fcheckout_modal.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faskus.how%2Fwp-content%2Fuploads%2F2021%2F12%2Fcheckout_modal.gif" title="check out modal form" alt="Checkout Form"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Appsmith Code Checkout Form Submit Button&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;When user checks out, duplicate the get_equipment API - and rename it to ‘post_checkout’.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change the relative endpoint to /rest/v1/checkout&lt;/li&gt;
&lt;li&gt;And this code inside the body
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "employee_id":{{SelectEmployee.selectedOptionValue}},

    "equipment_id": {{TableEquipment.selectedRow.id}},

    "due_by": {{DatePickerDueBy.selectedDate}}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code essentially says: Construct a JSON with employee_id = Employee Id of the selected drop-down box, equipment_id = Current Row of Equipment Table, and Due_by = Value from the date picker. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connect this API when the user presses the ‘Confirm’ button.&lt;/li&gt;
&lt;li&gt;Run to make sure you can successfully read the checkouts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faskus.how%2Fwp-content%2Fuploads%2F2021%2F12%2Fpost_checkout.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Faskus.how%2Fwp-content%2Fuploads%2F2021%2F12%2Fpost_checkout.gif" title="image_tooltip" alt="Post_CheckOut_API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;\&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;View Outstanding Equipment Checkouts&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We must provide a way to view a list of outstanding equipment checkouts. Let us create a new page.  &lt;/p&gt;

&lt;p&gt;First, let us build an API to read the checkout table. The process is similar to reading equipment or employee tables. &lt;/p&gt;

&lt;p&gt;The only twist is that our checkout table is normalized. That means we have chosen to store ids for equipment and employees' tables instead of duplicating the record. In our UI, we don’t want to show ids.&lt;/p&gt;

&lt;p&gt;For people familiar with REST APIs, that means multiple REST API calls to retrieve complete information. To avoid multiple REST API, we would need to use GraphQL. However, we don’t have to use GraphQL.There are simpler alternatives available. &lt;/p&gt;

&lt;p&gt;Supabase’s REST API is based on PostgREST. PostgREST can detect foreign relationships and automatically returns embedded data. All we need to do is include the names of tables with fields. In our example, we like to retrieve all fields from the checkout table with corresponding records from employee and equipment tables.&lt;/p&gt;

&lt;p&gt;Follow these steps to read the checkout data table:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Duplicate the get_equipment API - and rename it to ‘get_checkout’.&lt;/li&gt;
&lt;li&gt;Change the relative endpoint to&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;/rest/v1/checkout?select=&lt;em&gt;,employee(&lt;/em&gt;),equipment(*)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run to make sure you can successfully read the checkouts. It would be best if you got nested JSON.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This will return values in JSON&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
   "employee": {
      "id": 1,
      "first_name": "Smita",
      "last_name": "Mehra",
        },

    "equipment": {
      "id": 1,
      "name": "Dell Laptop",
      "image": "url..."
    }
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Drag a Table widget onto the canvas.&lt;/li&gt;
&lt;li&gt;Use ‘get_checkout’ as a data source for the table widget.&lt;/li&gt;
&lt;li&gt;Because employee and equipment are nested fields, we need to adjust column values for ‘employee’ and ‘equipment’&lt;/li&gt;
&lt;li&gt;Update the computed value for employee to {{_.get(currentRow.employee, 'name')}}&lt;/li&gt;
&lt;li&gt;Update the computed value for equipment to {{_.get(currentRow.equipment, 'name')}}  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9mtastwx5b6xoq5t3st.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9mtastwx5b6xoq5t3st.png" alt="TableWidgetColumn"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
And you are done! We hope this was a great starting point for you to build the application. You can expand it further to include more features and make it as complex as you’d like. &lt;/p&gt;

&lt;p&gt;If you’re feeling stuck, feel free to reach out to me! Email me at &lt;a href="mailto:meera.datey@gmail.com"&gt;meera.datey@gmail.com&lt;/a&gt;. This article was written as part of the Appsmith Writers Program. If you wish to participate, send an email to &lt;a href="mailto:writersprogram@appsmith.com"&gt;writersprogram@appsmith.com&lt;/a&gt; expressing your interest. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/in/meeradatey/" rel="noopener noreferrer"&gt;Meera Datey&lt;/a&gt; is a freelance web developer based in the San Francisco Bay Area. She specializes in helping small businesses design software solutions that deliver immediate value. This article was sent in as part of the Appsmith Writers Program.&lt;/p&gt;

</description>
      <category>lowcode</category>
      <category>appsmith</category>
      <category>supabase</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
