Skip to content

Commit c5cda9f

Browse files
committed
merge payment fix and new request end point
1 parent 35b1988 commit c5cda9f

File tree

6 files changed

+52
-17
lines changed

6 files changed

+52
-17
lines changed

packages/tdb-dashboard/src/components/DiffView copy.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ export const DiffView = ({diffs, CRObject}) => {
103103
frames,
104104
woqlClient:client,
105105
} = WOQLClientObj()
106-
/*const {
107-
getChangeRequestByID,
108-
} = ChangeRequest()*/
106+
109107
const {id} = useParams()
110108

111109
// pagination constants

packages/tdb-dashboard/src/components/DiffView.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ export const DiffView = ({diffs, CRObject}) => {
103103
frames,
104104
woqlClient:client,
105105
} = WOQLClientObj()
106-
/*const {
107-
getChangeRequestByID,
108-
} = ChangeRequest()*/
106+
109107
const {id} = useParams()
110108

111109
// pagination constants

packages/tdb-dashboard/src/hooks/ChangeRequest.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,36 @@ export function ChangeRequest(){
6868
}
6969
}
7070

71+
72+
const getChangeRequestHead = async(id) =>{
73+
try{
74+
setLoading(true)
75+
// const payload = {id}
76+
const result = await woqlClient.sendCustomRequest("GET", `${getUrl()}/${id}/head`)
77+
return result
78+
}catch(err){
79+
const errMessage = formatErrorMessage(err)
80+
setError(errMessage)
81+
}finally{
82+
setLoading(false)
83+
}
84+
}
85+
86+
const rebaseChangeRequestBranch = async(id) =>{
87+
try{
88+
setLoading(true)
89+
// const payload = {id}
90+
const result = await woqlClient.sendCustomRequest("PUT", `${getUrl()}/${id}/rebase`,{})
91+
return result
92+
}catch(err){
93+
const errMessage = formatErrorMessage(err)
94+
setError(errMessage)
95+
}finally{
96+
setLoading(false)
97+
}
98+
}
99+
100+
71101
// TO BE REVIEW ?????
72102
const getChangeRequestByID = async(id) =>{
73103
try{
@@ -98,7 +128,9 @@ export function ChangeRequest(){
98128
createChangeRequest,
99129
getChangeRequestList,
100130
updateChangeRequestStatus,
101-
getChangeRequestByID
131+
getChangeRequestByID,
132+
getChangeRequestHead,
133+
rebaseChangeRequestBranch
102134
}
103135

104136
}

packages/tdb-dashboard/src/pages/PlansPage.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {WOQLClientObj} from '../init-woql-client'
88
import { Feedback } from "./Feedback";
99
import {MdEuroSymbol} from "react-icons/md"
1010
import { StripeManager } from "../payment/StripeManager";
11+
import {CancelSubscription} from "../payment/CancelSubscription";
1112
/*
1213
* the plan card, we use this component in home page
1314
*/
@@ -16,6 +17,7 @@ export const PlansPage = (props) => {
1617
const navigate = useNavigate()
1718
const [showFeedbackForm, setShowFeedbackForm] = useState(false)
1819
const [showModalPlan ,setShowModalPlan] = useState(false)
20+
const [showModalCancel ,setShowModalCancel] = useState(false)
1921
const {getPaymentMethod,paymentMethod} = StripeManager()
2022

2123
const tier = clientUser && clientUser.userInfo ? clientUser.userInfo.tier : "Community"
@@ -42,7 +44,7 @@ export const PlansPage = (props) => {
4244

4345
const communityActions = () =>{
4446
if(toBedisabled[tier]){
45-
alert("DownGrade")
47+
setShowModalCancel(true)
4648
}else{
4749
navigate("/")
4850
}
@@ -78,6 +80,7 @@ export const PlansPage = (props) => {
7880
return(<Layout showLeftSideBar={false}>
7981
{showModalPlan && <PaymentPage showModal={showModalPlan !== false ? true : false }
8082
setShowModal={setShowModalPlan} subscriptionObj={showModalPlan}/>}
83+
{showModalCancel && <CancelSubscription showModal={showModalCancel} setShowModal={setShowModalCancel} />}
8184
{showFeedbackForm && < Feedback boxType= {ENTERPRISE_PLAN} setShowFeedbackForm={setShowFeedbackForm}/>}
8285
<Container className="center-align col-md-10">
8386
<Row xs={1} md={4} className="g-4 py-2 w-100">

packages/tdb-dashboard/src/payment/CancelSubscription.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@ import React from "react"
22
import {WOQLClientObj} from '../init-woql-client'
33
import {Modal,Button,Stack, Card} from "react-bootstrap"
44
import {MdEuroSymbol} from "react-icons/md"
5+
import {StripeManager} from "./StripeManager"
56

6-
export const PaymentPage = ({showModal, setShowModal, tier}) => {
7+
export const CancelSubscription = ({showModal, setShowModal}) => {
78
const {woqlClient, } = WOQLClientObj()
89
if(!woqlClient) return ""
910

1011
const closeModal = () =>{
1112
setShowModal(false)
1213
}
1314

15+
const { succeeded,
16+
error,
17+
processing, deleteSubscrition} = StripeManager()
18+
19+
20+
1421
return <Modal size="lg" className="modal-dialog-right" show={showModal} onHide={closeModal}>
15-
<Modal.Header style={{background:subscriptionObj.color}}>
22+
<Modal.Header>
1623
<Stack direction="horizontal" gap={10} className="justify-content-center">
17-
<Modal.Title className="h4 fw-bold">Remove the {tier} Subscription</Modal.Title>
24+
<Modal.Title className="h4 fw-bold">Downgrade to Community</Modal.Title>
1825
</Stack>
1926
<Button variant="close" aria-label="Close" onClick={closeModal} />
2027
</Modal.Header>
@@ -25,13 +32,13 @@ export const PaymentPage = ({showModal, setShowModal, tier}) => {
2532
<Card.Text><MdEuroSymbol />0</Card.Text>
2633
</Stack>
2734
<div className="d-flex justify-content-end mt-2">
28-
<Button onClick={props.closeModal} disabled={processing} variant="light" >Cancel</Button>
29-
<Button type={"submit"} disabled={processing || !enableSubmit || !stripe} className="ml-3">
35+
<Button onClick={closeModal} disabled={processing} variant="light" >Cancel</Button>
36+
<Button type={"submit"} disabled={processing} className="ml-3" onClick={deleteSubscrition}>
3037
{processing ? "Processing…" : "Downgrade"}
3138
</Button>
3239
</div>
3340
<div className="d-flex justify-content-end mt-2">
34-
<span style={{fontSize: "15px", color: "#888" }}>* your account will be billed monthly until cancelled.
41+
<span style={{fontSize: "15px", color: "#888" }}>
3542
</span>
3643
</div>
3744
</Card>

packages/tdb-dashboard/src/payment/FormPayment.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export function FormPayment(props) {
3434
const city = useRef(null);
3535
const address = useRef(null);
3636

37-
3837
const stripe = useStripe();
3938
const elements = useElements();
4039

@@ -96,8 +95,6 @@ export function FormPayment(props) {
9695
;
9796
};
9897

99-
100-
10198
const renderSuccess = () => {
10299
function goToHome (){
103100
navigate("/")

0 commit comments

Comments
 (0)