-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat]: Add support for Key value pair in AccessType #575
base: master
Are you sure you want to change the base?
Changes from 2 commits
4007274
7e14598
0ab370b
f6efb17
74a738e
0aa41e1
856d126
24ef0c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import React, { useState, useEffect } from "react"; | ||
import { object, func } from "prop-types"; | ||
import get from "lodash/get"; | ||
|
||
import "./group-and-plans.m.css"; | ||
|
||
export const GroupsAndPlansModal = ({ member, setActiveTab, setSelectedPlan, getSubscription }) => { | ||
const [subscriptionsData, setSubscriptionsData] = useState([]); | ||
const [selectedSubscriptions, setSelectedSubscriptions] = useState({}); | ||
const [selectedOption, setSelectedOption] = useState(null); | ||
|
||
useEffect(() => { | ||
getSubscription().then((res) => setSubscriptionsData(res)); | ||
}, []); | ||
|
||
useEffect(() => { | ||
const defaultSelectedOptions = {}; | ||
subscriptionsData.forEach((group, id) => { | ||
subscriptionsData.forEach((group) => { | ||
const firstPlan = get(group, ["subscription_plans", "0"]); | ||
defaultSelectedOptions[group.name] = firstPlan; | ||
}); | ||
|
@@ -26,6 +26,11 @@ export const GroupsAndPlansModal = ({ member, setActiveTab, setSelectedPlan, get | |
member ? setActiveTab("checkout") : setActiveTab("login"); | ||
}; | ||
|
||
const handleOptionClick = (groupName, plan) => { | ||
setSelectedOption(plan); | ||
setSelectedSubscriptions({ ...selectedSubscriptions, [groupName]: plan }); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div styleName="title">Choose A Plan</div> | ||
|
@@ -35,29 +40,54 @@ export const GroupsAndPlansModal = ({ member, setActiveTab, setSelectedPlan, get | |
</p> | ||
<div styleName="groups"> | ||
{subscriptionsData.map((group, id) => { | ||
const renderRichText = (richText) => { | ||
return <div dangerouslySetInnerHTML={{ __html: richText }} />; | ||
}; | ||
return ( | ||
<div key={id} styleName="group-card"> | ||
<div styleName="group-name">{group.name}</div> | ||
<div styleName="plan-name"> | ||
<select | ||
styleName="select-option" | ||
onChange={(e) => | ||
setSelectedSubscriptions({ ...selectedSubscriptions, [group.name]: JSON.parse(e.target.value) }) | ||
} | ||
> | ||
{group.subscription_plans.map((plan, id) => { | ||
return ( | ||
// eslint-disable-next-line react/jsx-key | ||
<option key={id} value={JSON.stringify(plan)}> | ||
{`${plan.duration_length} ${ | ||
plan.duration_length === 1 | ||
<div> | ||
<div | ||
styleName="selected-option" | ||
onClick={() => handleOptionClick(group.name, selectedSubscriptions[group.name])} | ||
> | ||
{selectedSubscriptions[group.name]?.duration_length} | ||
{selectedSubscriptions[group.name]?.duration_length === 1 | ||
? selectedSubscriptions[group.name]?.duration_unit.substring( | ||
0, | ||
selectedSubscriptions[group.name]?.duration_unit.length - 1 | ||
) | ||
: selectedSubscriptions[group.name]?.duration_unit} | ||
| ||
{selectedSubscriptions[group.name]?.price_cents / 100} | ||
{selectedSubscriptions[group.name]?.price_currency} | ||
</div> | ||
<div className="options"> | ||
{group.subscription_plans.map((plan, index) => ( | ||
<> | ||
<div | ||
key={index} | ||
styleName={`option ${selectedOption === plan ? "option-select" : ""}`} | ||
onClick={() => handleOptionClick(group.name, plan)} | ||
> | ||
{1 + index}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its a design change for showing like this 1) |
||
{plan.duration_length} | ||
{plan.duration_length === 1 | ||
? plan.duration_unit.substring(0, plan.duration_unit.length - 1) | ||
: plan.duration_unit | ||
} ${plan.price_cents / 100} ${plan.price_currency}`} | ||
</option> | ||
); | ||
})} | ||
</select> | ||
: plan.duration_unit} | ||
| ||
{plan.price_cents / 100} | ||
{plan.price_currency} | ||
{plan.custom_attributes && | ||
plan.custom_attributes.map((attribute, index) => ( | ||
<div key={index}>{attribute.value && renderRichText(attribute.value)}</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. index shouldnt be a key There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
))} | ||
</div> | ||
</> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
<div styleName="plan-description">{group.description}</div> | ||
<button styleName="subscribe-btn" onClick={() => handlePlanSelection(group.name)}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
asset_host: http://localhost:8080 | ||
sketches_host: https://malibu-advanced-web.qtstage.io | ||
sketches_host: https://malibu-advanced-web.quintype.io | ||
host_to_api_host: | ||
help.lvh.me: https://user-documentation.quintype.io | ||
host_to_automatic_api_host: | ||
|
@@ -22,8 +22,8 @@ publisher: | |
redirect_Url: "<Domain>/api/auth/v1/oauth/token" | ||
callback_Url: "Callback Url" | ||
accesstypeConfig: | ||
key: "Aw4ujaqhpn8aVMT7yzQawSyZ" | ||
accessTypeBkIntegrationId: 455 | ||
key: "yTKoDn8R1d4AY651ZPvGDUq4" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. switch back to stg creds, do not commit prod keys or domains There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for QA testing. On staging, subscription page doesn't work. It only works on prod. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use BK!, do not commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay |
||
accessTypeBkIntegrationId: 2270 | ||
timezone: "Asia/Baku" | ||
auto_sso: | ||
is_enable: false | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the same set of statements are repeated to access properties, fundamentals like variables are to be used!
Please consider programming practices over copy paste..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done