React Multiple Select – Metronic Theme and React Hooks

This article introduces the React Multiple Select using React Hooks.

I have vendors in various cities who are providing service to their customers. The situation is I need to assign societies to vendors as per their preference. A vendor may provide service to multiple societies in an area.

For this, I used Metronic theme and React hooks – useEffect.

There is a list of vendors and now I want to assign societies to a particular vendor.

To do so I redirected to details of the vendor.

First, select a city, then an area and then I want a filtered list of societies from that area of the city.

 

React Multiple Select - Metronic Theme and React Hooks

Step 1 :
Fetched a list of cities using async-await with useEffect hook.

/* Get list of all Cities */

const apiUrl = API_ENDPOINT + “city_list/”;

useEffect(() => {

const fetchData = async () => {

const result = await axios(apiUrl).then(response => response.data)

.then((data) => {

setData(data.data);

let count = Object.keys(data.data).length;

setcount(count);

})

};

fetchData();

}, []);

/* End Get list of all Cities */

 

Step 2 :

Fetched a list of areas from the selected city using async-await with useEffect as —>

/* Get area list by City */

const apiUrlArea = API_ENDPOINT + “area_list/”;

useEffect(() => {

let postAreaData=”;

if(formdata.city_id && formdata.city_id !==”){

postAreaData = {city_id:formdata.city_id}

const fetchData = async () => {

const result = await axios.post(apiUrlArea,postAreaData).then(response => response.data)

.then((data) => {

setareadata(data.data);

})

};

fetchData();

}

},[formdata.city_id]);

/* End Get area list by City */

 

Here formdata contains details of the vendor to edit.

 

This code will get executed as we change City and we are able to get a list of all areas from the selected city.

 

Step 3 :

Now I have a city and area , I can get a list of all societies in that area.

/* Get Societies by City & Area */

const apiUrlGetSociety = API_ENDPOINT + “society_list”;

useEffect(() => {

let postCityAreaData = {

area_id:formdata.area_id,

city_id:formdata.city_id,

}

const temp_slist = [];

if(formdata.area_id && formdata.area_id!== ” && formdata.city_id && formdata.city_id!== ” ){

const fetchData = async () => {

const result = await axios.post(apiUrlGetSociety,postCityAreaData).then(response => response.data)

.then((data) => {

data.data.forEach(element => {

const obj_temp = {‘id’:element.id, ‘name’:element.name};

temp_slist.push(obj_temp);

});

 

setAllSocieties(temp_slist);

setShowLoading(false);

console.log(“allSocieties”);

console.log(temp_slist);

 

})

};

fetchData();

 

}

},[formdata.area_id,formdata.city_id]);

/* End Get Societies of Area */

 

Here I get a list of societies as an array of object – {id,name}

 

let  allSocieties = [ {“id”: 6,”name”: “Abhiruchi”}, {“id”: 2,”name”: “Sahara Society”}, {“id”: 3,”name”: “Satyam Society”},]

Now we have a filtered list of societies with respect to the area from the city.

Step 4 :

To show listing on form I used form-components from Metronics.

( https://keenthemes.com/metronic/preview/react/demo2/google-material/inputs/selects )

 

The Select component can handle multiple selections. It’s enabled with multiple property.

<FormControl className='form-control'>

<Select

multiple

name = “societies”

id = “societies”

value = { selectedSocieties }

onChange = { handleChange_multiple }

input = { <Input id=”select-multiple-chip” /> }

renderValue = { selected => (

<div className = {classes.chips}>

{ selected.map( s => {

const chipname = allSocieties.find(soc => soc.id === s);

return (chipname

?   <Chip

key={s}

label={chipname.name}

className={classes.chip}

data-aaa={JSON.stringify(allSocieties)}

/>

: ”)

})}

</div>

)}

MenuProps={MenuProps}

>

{ allSocieties.map((itemsociety) => (

<MenuItem

key={itemsociety.id}

value={itemsociety}

>

<Checkbox checked={selectedSocieties.includes(itemsociety.id) } />

<ListItemText primary={itemsociety.name} />

</MenuItem>

))}

</Select>

</FormControl>

 

In the above select component, we have passed selectedSocieties to value attribute.
selectedSocieties is an array of ids of societies which are already assigned to vendor.
I can get list of assigned societies to vendor as –>

 

useEffect(() => {

setShowLoading(true)

setformdata(props.data)

if(props.data.vendorSociety && props.data.vendorSociety !== ” && props.data.vendorSociety !== ‘undefined’ ){

props.data.vendorSociety.forEach(el => {

const obj = {‘id’:el.id, ‘name’:el.name};

temp_selected_slist.push(el.id);

})

setSelectedSocieties(temp_selected_slist);

 

}

}, [props.data]);

react multiple selection

After selecting one/more societies, handleChange_multiple event bind selected societies data to selectedSocieties . See the following code:

 

const handleChange_multiple = event =>{

 

let newitems = event.target.value.filter(t => typeof t !== ‘number’);

let changed = newitems[0].id;

let cleanthis = event.target.value.filter(t => typeof t === ‘number’);

newitems.forEach(i => cleanthis.push(i.id));

const newSelectedItems = selectedSocieties.includes(changed)

? selectedSocieties.filter(v => v !== changed)

: […selectedSocieties, changed];

setSelectedSocieties(newSelectedItems);

 

}

 

In the example given in Metronic , handleChange event deals with an array of the name only. In above we are dealing with an array of objects.
In the above code, in handleChange_multiple event, we get newly selected items as an object – newitems {id,name}. Then extract id from it and saved to changed. 

Now I can check with changed whether it exist in  selectedSocieties.

 

const newSelectedItems = selectedSocieties.includes(changed)

? selectedSocieties.filter(v => v !== changed)

: […selectedSocieties, changed];

setSelectedSocieties(newSelectedItems);

 

In above article , we learned how to use multiple select in combination with array of objects and obtain required results.

 

 

Laravel: A New Era in PHP Framework 2019

If you are in the business of building web applications for your clients or businesses you might have flirted with the idea of using several different types of PHP frameworks. CodeIgniter, CakePHP, Yii, and Phalcon are some of the most popular PHP Frameworks but there is one that goes above and beyond these tools and one that is our favorite here at CodePlateau and that is the Laravel PHP Framework. But what makes the Laravel PHP framework better and different from all the others? Let’s take a closer look.

Why Laravel Is The Best PHP Framework For 2019

1) Object Oriented Libraries

One of the reasons Laravel is as popular as it is (more than 1 million sites use Laravel, and it currently has more than 51,192 stars on GitHub) that it has Object Oriented libraries and plenty of pre-installed ones. Surprisingly none of these libraries are part of any other major PHP frameworks. It’s easy implementation and advanced features has made it a success across the world and you have access to tools like password reset, CSRF protection, encryption as well as authentication.

2) Authentication Techniques

As discussed above Laravel provides several object-oriented libraries of which authentication is a major item. It provides a very simple and straightforward method of implementing authentication techniques across platforms. Even the control access to resources as well as the manner in which authorization logic is organized is very simply configured which makes Laravel one of the easiest frameworks to adopt.

3) Security

One of the biggest concerns businesses has, especially those that work directly with customers, is the threat of data security. Even companies like Facebook have come under the scanner for leaking their user’s data. Laravel takes a unique look at security and provides a really clever response. Security is covered within the framework itself. Instead of saving passwords in the plain text they use salted and hashed passwords. It avoids injection attacks by avoiding user injection of <script> tags. Overall it’s one of the safest PHP frameworks to work within 2019.

4) Artisan

Apart from the business reasons many companies choose to work with Laravel, there are plenty of development reasons that developers have chosen Laravel as the best PHP framework in 2019. Laravel provides an in-built command line tool called Artisan, which allows programmers to avoid tedious, repetitive tasks and rather focus on the tougher parts of the build.

5) Database Migrations

Change is the only constant, in life and in programming. Sometimes 1000’s of lines of code will need to be updated due to a feature change, or you’ll have found a better way to manage the database, the reasons could be anything. Database migrations with Laravel is extremely easy. As long as your changes are carefully managed in migrations and seeds you can migrate changes into any other development machine you might have. If you’re looking to make your developers life easier you should definitely consider Laravel as your PHP development framework in 2019.

6) Tutorials

Assuming you’re new to Laravel & haven’t had the chance to explore it as much as your peers, you don’t need to worry. There are plenty of tutorials available on YouTube, however, Laravel offers its own tutorial service (which no other platform does), Laracast, which provides excellent, high-quality, insightful, videos that give you everything you’d like to know in one place. While the tutorials are not entirely free you do have plenty of free videos available on Laracast which should help you more than cover the basics. It’s only the advanced tutorials that you need to pay for.

Conclusion
Your developers will surely thank you for picking the Laravel PHP framework and if the decision was left upto them, that’s what they would pick 9/10 times. At CodePlateau we have a team of highly skilled programmers who are experts in Laravel and Web Application development. If you ever have any requirements for web design and web development, do get in touch.

Checklist for a Mobile Friendly Website

Smartphones have been integrated into our world and how! You can’t turn a corner today and see someone’s head glued to their screen. While the question of where does this lead us as a society is for greater minds, we’re looking at the checklist you need to keep ready to be able to implement a mobile-friendly website. In today’s blog, we’re going to be covering just that topic. Hopefully the end of it, you’ll know exactly what you need in order to have a fully functional mobile-friendly website.

Mobile Friendly Website Checklist

1) Implement Mobile Friendly Design
There are at least 3 ways in which you can serve your customers with a responsive web template. However, out of these 1 is highly recommended by Google and is relatively easy to implement as well. This is by using a responsive design template. The HTML code, the URL shared to the customer is the same in the responsive design template. The other two options that are not ideal, but good to know are, by dynamic serving where you URL shared is the same across the different devices, but the HTML served on each device is slightly altered for the screen. The third option is to use a completely separate URL, one for mobile viewers and the other for web browsing.

2) Structured Data
Using structured data will definitely help Google understand the content on your website. The same applies to your mobile website as well. The pages on your mobile website should have the same structured data that is on your website. Google does mobile first indexing. Keep that in mind.

3) No Flash
Adobe Flash is quite an outdated tool. Some of your favorite games had been built using Flash but in more recent times flash has encumbered websites and makes them slow. More importantly, Chrome automatically disables flash on most sites due to security and speed issues. So it should be pretty obvious to anyone building your mobile website that they should not be using any Flash on your mobile-friendly website. Use JavaScript, CSS or similar other modern properties instead.

4) Font, Buttons, Design Is Important
Another important aspect of ensuring that your website is responsive and mobile friendly is the design architecture of the website itself. Being responsive enough is not enough it should have to be aesthetically pleasing as well. Pay special attention to the fonts. Mobile screens have been steadily growing bigger over the years, but they are still no comparison to screens of your websites and desktops. Fonts that are easily readable on larger screens are not so when using your website on mobile screens. It’s not the same with mobile phones. Buttons themselves can have an impact on your customer experience which can again have an impact on your website SEO.

5) Performance Matters
Apart from the fonts, buttons, design the performance of your mobile responsive website is also of the utmost importance. You have to focus on optimizing your mobile website to give your customers the kind of experience that they have come to expect from your website. There are several ways in which you can optimize your mobile website such as

– Improve your images
– Boost performance by improving the server response time
– Reduce the file size of your uploads by using tools like GZip
– Optimize your CSS

6) Focus On Your Customers
Maybe you won’t be able to display everything your website has to offer on your mobile website. That can be irrelevant. Your mobile website can be the platform that gives customers exactly what they need when they need it. Mobile users are normally looking for information on the go and they need accurate information quickly. If you are able to serve it to them through your mobile website then your customers will be dependent on you. Optimize the content for your users and you’ll almost have the battle won.

Conclusion
Having a mobile website can be easy but ensuring that you develop a mobile-friendly website that looks good, delivers on the design, content, and experiential aspects to the customers is not a piece of cake. You can do so by hiring the best web design and development company. If you’re looking to hire a professional web design company get in touch with us today.

Things To Consider When Building An E-Commerce Website

From relying on mega online e-commerce websites like Amazon and E-Bay many companies are now focusing on building their own e-commerce sites to directly try and tap their customers. In the last couple of years, we’ve seen a significant rise in the number of websites that are selling products online and with good reason. If you have some products you’d like to sell, it’s better to focus on developing an e-commerce website from scratch. You’ll have more control over the products you sell, the customers you are targeting and you have greater control over the pricing of the products. But if you’ve decided to build a website or are thinking about getting a professional e-commerce website development team, here is a checklist that you should be aware of.

Guidelines for E-Commerce Website Development

1. Understand the customer and product
Don’t build a website simply because you want to have an online presence without the customer base of the product that will sell online. There are plenty of products that have a higher propensity to sell offline than through online sales to ensure that you’ve made the right choice in going ahead for an e-commerce website development. If you need additional advice you can always get in touch with the best website development company in your area.

2. Choosing the right platform
Once you’ve decided to come online the next question becomes which platform to use and there is plenty of e-commerce website platform to choose from. You can either go with Hybris, Magento, WooCommerce, Shopify or even consider building your website from scratch using HTML, Java, and CSS. What you need to keep in mind, especially if you have a sizeable user base is to make sure you have
– A functioning customer relationship management tool to handle all their requirements
– A payment gateway integration to make paying for your products simpler
– Strong backend which can support your frontend activities
– Mobile responsiveness for all pages

3. Website Hosting Provider
Once you’ve decided which platform you want to choose the next choice to be made is the hosting provider you will go with. Now you may think that all host provide the same services, but in our multiple years of experience in website development and web design, we’ve seen that some services, although priced identically, have vastly different service levels. If you need more details on hosting providers for your website please feel free to get in touch with us.

Here are some things to keep in mind while selecting your hosting provider
– Speed is of the essence. Google rewards sites that provide data to the customers faster with a better ranking
– Choose a hosting provider that will make sure your site is available to the customer at all times. There should be zero or very marginal downtimes
– Since you will be dealing a lot with sensitive customer data, privacy and security or a concern. Make sure you choose a hosting provider that keeps your site protected at all times
– In case there is any issue you want to make sure that your hosting provider is there to support you at all times. Choose a host that has good service staff to support you.
– You might be starting off small but you should be able to build your website as you go so scalability in terms of server size, space, and reliability are always important

4. Choosing what you want your customer to see
Another important aspect of an e-commerce website development project is to make sure you know exactly what pages you’ll be showing to your customers. How easy the website is to navigate? Are the images too cluttered? These may not seem like important factors when building an e-commerce website but they are all very relevant not only to your customer but to Google as well.

Conclusion
If you use e-commerce platforms like WooCommerce and Shopify you might be able to develop an e-commerce website yourself, but without the help of professional reliable web development and design company, your website won’t have the much-needed fascination to the public. If you want someone to professionally build your e-commerce website, get in touch with us today.

Web Development Trends to Follow In 2019

We’ve already stressed enough how important a website can be for your business. Meeting your business goals, reaching out to potential new customers and all the other benefits that come with a well-developed website. Web development companies always have to stay updated with the latest web development trends that take precedent each year. Today we’ll be looking at the top web development trends for 2019.

Continue reading

All You Need To Know About AMP (Accelerated Mobile Pages)

Since we’re living in a world of short attention spans your consumers are looking for the fastest smoothest web browsing experience. With the advent of the smartphone more and more of the users browsing experience has moved to smartphones. Google recognized this and in 2015 made speed a ranking factor and again in December 2015 hinted at making mobile website loading speeds a ranking factor too. Web developers in Pune and around the world began experimenting with mobile-friendly versions of their website but it wasn’t good enough.
Kissmetrics data shows that pages that take longer than 3 seconds to load are more likely to be abandoned by up to 40% of the users. To battle, this problem Accelerated Mobile pages were introduced, and it was found that websites that were AMP-optimized showed a significant improvement in their rankings. In this blog, we’ll look at what AMP Pages are and how you can use CodePlateau’s world-renowned web development services to take advantage of them on your own website.

What Are Accelerated Mobile Pages?
It began when Google and Twitter joined forces to bring about a faster online experience to their users. It is an open source experience that helps design your web pages to make them faster and provide a better user experience. It’s a plugin that can help reduce your web page to the absolute essential basics to make it load quicker.

How To Optimize Your Web pages For AMP?

  • This is what most of your readers are here to find out. The solution, simple, download the AMP plugin from right within the WordPress plugins search or from the Github downloads. You will need to change a bit of code however and that’s where the excellent team of web developers from CodePlateau in Pune come in handy.
  • What we also suggest is that you create two different versions of your content pages. One can simply be a mobile-friendly version where you can have all your features and customizations while the AMP pages will be bare bones but provide a better online experience to the user. You don’t have to be worried about Google considering the pages as duplicate as they take into account the AMP version as long as your page has been validated online.
  • Use AMP URL’s to distinguish between the two.

So How Does The AMP Plugin Work?

Like we’ve mentioned before the AMP plugin strips your webpage to the absolute basic code required by smartphones to run smoothly. There are three parts to the AMP structure:
1) AMP HTML
2) AMP JS
3) AMP CDN

AMP pages don’t load regular Javascript, there is an AMP Javascript subset that you need to use. There are several other factors that you need to consider before using the AMP plugin on your page –

– Before you can roll out your AMP pages they need to be validated
– It is best to avoid custom fonts on your AMP pages as this may delay load time as these fonts have to be specially loaded every time
– You have to specify height and width for every image you share on your page if you want them to load correctly
– Videos need specially approved extensions to run on your AMP pages

You also need to be aware of the fact that AMP pages are built for quickness and readability. You might not even be able to enable the social sharing icons on your AMP pages as these are built using Javascript. CodePlateau’s web development team in Pune have found a workaround for this issue, get in touch with us for additional details.

5 Benefits Of Using AMP Pages For Your Website
While there are numerous benefits of using AMP pages for your website, we’ll be looking at the top 5. These are the factors that can really help enhance your site’s ranking and help you convert more sales.

1) Quicker Loading Speeds – The whole purpose of building AMP pages is to get an edge over your competition when it comes to the speed with which the content on your pages load. Users love a faster browsing experience as can be ascertained by the KissMetrics numbers.

Here are some more statistics to help convince you that you need AMP pages for your website

  • Every second your page delays in loading you are losing 9.4% of your pageviews
  • Conversion rate drops by 3.5% with every second added to your page load time
  • Bounce rate can go up by 8.3% for pages that take more than 3 seconds to load

In commercial terms, depending on your monthly traffic this could amount to a serious loss of site visitors, sales and more

2) Highlighted Results In Search – When it comes to SEO every advantage you can find is worth the time you spend getting it. Websites that rely heavily on their content for marketing were thrilled when AMP pages were introduced as it provided them with a green lightning symbol to display them as AMP pages. They also showed up higher in the search results. AMP pages have a higher click-through rate than their non-AMP counterparts.

3) Higher Listing In Search – Since speed is now one of the ranking factors on Google pages that load quicker tend to have a higher listing in search. This is especially true for AMP pages as not only do they have faster loading times as compared to non-AMP pages, they also have a better click-through rate. While Google may not necessarily be focusing on earning money using AMP pages it has helped them generate more revenue. A better user experience has led to more users pushing to use Google as their default browser. More clicks mean more money for Google.

4) Better Ad Support – Speaking of Google making money using AMP pages it has also helped content creators streamline the Ad’s on their sites. Since only custom AMP approved HTML works along with streamlined CSS code and almost no Javascript there are fewer distractions on your web page. Users can focus on the content and there is plenty of space for Ads. While you don’t want to clutter your pages with Ad’s less clutter makes it more convenient for people to click on Ad’s when they’re truly interested in them. AMP pages make the Ad’s stand out more effectively than the rest of the content on the page.

5) Simpler User Tracking – It’s not just that AMP pages provide the user with a better experience they also provide the content creator with more data to work with. Using Tag manager on their AMP pages provides Google webmasters with more information about their users. All the metrics you can find on Google Analytics are provided separately for AMP pages.

Conclusion
India is still in a very nascent stage when it comes to adopting AMP pages. If you want to get a head start on your competition you should start working on converting your pages to AMP as soon as possible. While setting up AMP pages on your website might seem easy there is some web development knowledge that you would need. Who better to help you out with your problem than Pune’s best Web Development company CodePlateau. If you’d like to get started on your project or need more information on the subject, we’d love to hear from you. Get in touch today!