diff --git a/src/components/Tenanat/LogoUpload.jsx b/src/components/Tenanat/LogoUpload.jsx index 7c30d80f..aa6fbc12 100644 --- a/src/components/Tenanat/LogoUpload.jsx +++ b/src/components/Tenanat/LogoUpload.jsx @@ -63,12 +63,12 @@ export const LogoUpload = ({ preview, setPreview, fileName, setFileName }) => { )} {preview && ( -
+
Preview
{fileName} diff --git a/src/components/Tenanat/SegmentedControl.jsx b/src/components/Tenanat/SegmentedControl.jsx new file mode 100644 index 00000000..4d936c3a --- /dev/null +++ b/src/components/Tenanat/SegmentedControl.jsx @@ -0,0 +1,43 @@ +import React, { useEffect, useState } from 'react'; + +const SegmentedControl = ({setFrequency}) => { + const [selected, setSelected] = useState(3); +useEffect(()=>{ + setFrequency(selected) +},[selected]) + return ( +
+ + + + + +
+ ); +}; + +export default SegmentedControl; diff --git a/src/components/Tenanat/SubScription.jsx b/src/components/Tenanat/SubScription.jsx index 50bf5ad8..9d6ed387 100644 --- a/src/components/Tenanat/SubScription.jsx +++ b/src/components/Tenanat/SubScription.jsx @@ -1,15 +1,83 @@ -import React from 'react' -import { useSubscriptionPlan } from '../../hooks/useTenant' +import React, { useState } from "react"; +import { useSubscriptionPlan } from "../../hooks/useTenant"; +import SegmentedControl from "./SegmentedControl"; const SubScription = () => { - const {data,isError,isPending} = useSubscriptionPlan() - console.log(data) + const [Frequency, setFrequency] = useState(3); + const[selectedPlanId,setSelectedPlanId] = useState() + const { data, isError, isLoading } = useSubscriptionPlan(Frequency); + console.log(Frequency); return ( -
+
+ -

Scription

+ {!isLoading && !isError && data.length > 0 && ( + <> +
+ {data.map((plan) => ( +
+
setSelectedPlanId(plan.id)} + style={{ cursor: "pointer" }} + > +
+
+ +
+
+ {plan.planName} +
+

{plan.description}

+
+
+ +

+ {plan.currency?.symbol} + {plan.price} + {/* + /{selectedBilling.label.toLowerCase()} + */} +

+ +
    +
  • + + Max Users: {plan.maxUser} +
  • +
  • + + Storage: {plan.maxStorage} MB +
  • +
  • + + Trial Days: {plan.trialDays} +
  • +
+ +
+
+
+ ))} +
+ + )}
- ) -} + ); +}; -export default SubScription \ No newline at end of file +export default SubScription; diff --git a/src/hooks/useTenant.js b/src/hooks/useTenant.js index 04f43465..9d4aa15c 100644 --- a/src/hooks/useTenant.js +++ b/src/hooks/useTenant.js @@ -1,6 +1,7 @@ -import { useQuery } from "@tanstack/react-query"; +import { useMutation, useQuery } from "@tanstack/react-query"; import { TenantRepository } from "../repositories/TenantRepository"; import { MarketRepository } from "../repositories/MarketRepository"; +import showToast from "../services/toastService"; export const useTenants = ( pageSize, @@ -33,12 +34,32 @@ export const useIndustries=()=>{ }) } -export const useSubscriptionPlan=()=>{ +export const useSubscriptionPlan=(freq)=>{ return useQuery({ - queryKey:['SubscriptionPlan'], + queryKey:['SubscriptionPlan',freq], queryFn:async()=>{ - const res = await TenantRepository.getSubscriptionPlan(); + const res = await TenantRepository.getSubscriptionPlan(freq); return res.data; } }) +} + +// ------------Mutation--------------------- + +export const usecreateTenant = (onSuccessCallback)=>{ + return useMutation({ + mutationFn:async(tenantPayload)=>{ + const res = await TenantRepository.createTenant(tenantPayload); + return res.data; + }, + onSuccess:(data,variables)=>{ + showToast("Tenant Created SuccessFully","success") + + if(onSuccessCallback) onSuccessCallback() + }, + onError:(error)=>{ + showToast(error.response.message || error.message || `Something went wrong`,"error") + } + + }) } \ No newline at end of file diff --git a/src/repositories/TenantRepository.jsx b/src/repositories/TenantRepository.jsx index 60abb9d2..6f868116 100644 --- a/src/repositories/TenantRepository.jsx +++ b/src/repositories/TenantRepository.jsx @@ -7,6 +7,8 @@ export const TenantRepository = { return api.get(`/api/Tenant/list?pageSize=${pageSize}&pageNumber=${pageNumber}&filter=${payloadJsonString}&searchString=${searchString}`) }, - getSubscriptionPlan:()=>api.get(`/api/Tenant/list/subscription-plan`) + getSubscriptionPlan:(freq)=>api.get(`/api/Tenant/list/subscription-plan?frequency=${freq}`), + + createTenant:(data)=>api.post('/api/Tenant/create',data) }