import React,{ useEffect, useState,useContext } from 'react';
import { Link } from 'gatsby';
import { LanguageContext } from '../../context/LanguageContext';
import api from '../../common/api';
const Pricing = () => {
const { currentLanguage } = useContext(LanguageContext);
const [plansData, setPlansData] = useState({ plans: [], text_traductions: {} });
useEffect(() => {
const fetchData = async () => {
try {
const response = await api.get('plan','plans.json');
setPlansData(response);
} catch (error) {
console.error(error);
}
};
fetchData();
}, []);
const { plans, text_traductions } = plansData;
if (!plansData || plansData.length === 0) {
return
Loading...
;
}
return (
{text_traductions.title && text_traductions.title[currentLanguage]} {text_traductions.title2 && text_traductions.title2[currentLanguage]}
{text_traductions.subtitle1 && text_traductions.subtitle1[currentLanguage]}
{text_traductions.subtitle2 && text_traductions.subtitle2[currentLanguage]}
{text_traductions.contact && text_traductions.contact[currentLanguage]} {text_traductions.us_now && text_traductions.us_now[currentLanguage]}
{text_traductions.our_services_button && text_traductions.our_services_button[currentLanguage]}
{
plans.map((plan, i) => (
{ plan.title } { plan.recommended && {text_traductions.recommend && text_traductions.recommend[currentLanguage]} }
{ plan.description }
{ plan.price }
{text_traductions.per_month && text_traductions.per_month[currentLanguage]}
{
plan.features.map((feature, i) => (
-
{ feature }
))
}
{text_traductions.get_started_now && text_traductions.get_started_now[currentLanguage]}
))
}
)
}
export default Pricing