Skip to content

Commit e54983d

Browse files
author
Fabiana Fonseca
committed
testing window type
1 parent 54f0d02 commit e54983d

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

react/components/CustomButton.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import React, { Component } from 'react'
22

33
import Table from './Table'
4-
54
import { OrderFormItem } from '../typings/orderForm'
65

7-
class CustomButton extends Component<CustomButtonProps, CustomButtonState> {
8-
/**
9-
* This component is responsible for rendering the custom button itself. For instance,
10-
* we use it to render a table that contains the name of the items that are in the
11-
* order form.
12-
*/
13-
constructor(props: any) {
14-
super(props)
15-
}
16-
render() {
6+
/**
7+
* This component is responsible for rendering the custom button itself. For instance,
8+
* we use it to render a table that contains the name of the items that are in the
9+
* order form.
10+
*/
11+
class CustomButton extends Component<CustomButtonProps, {}> {
12+
public render() {
1713
const { items } = this.props
1814

1915
return items ? (
@@ -31,6 +27,6 @@ interface CustomButtonProps {
3127
items: OrderFormItem[]
3228
}
3329

34-
interface CustomButtonState {}
30+
// interface CustomButtonState {}
3531

3632
export default CustomButton

react/index.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import React, { Component } from 'react'
33
import CustomButton from './components/CustomButton'
44
import { OrderForm } from './typings/orderForm'
55

6-
class CheckoutButtonExample extends Component<
7-
CheckoutButtonExampleProps,
6+
class CheckoutButtonExample extends React.Component<
7+
{},
88
CheckoutButtonExampleState
99
> {
1010
/**
@@ -20,19 +20,22 @@ class CheckoutButtonExample extends Component<
2020
}
2121
}
2222

23-
listenOrderFormUpdated = () => {
23+
public listenOrderFormUpdated() {
2424
$(window).on('orderFormUpdated.vtex', (_: any, orderForm: OrderForm) =>
2525
this.setState({ orderForm })
2626
)
2727
}
2828

29-
render() {
29+
public render() {
3030
this.listenOrderFormUpdated()
31+
32+
console.log(window.vtex.i18n.getLocale())
33+
3134
return <CustomButton {...this.state.orderForm!} />
3235
}
3336
}
3437

35-
interface CheckoutButtonExampleProps {}
38+
// interface CheckoutButtonExampleProps {}
3639

3740
interface CheckoutButtonExampleState {
3841
orderForm: OrderForm | null

react/typings/orderForm.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
declare global {
2+
type Window = any
3+
}
4+
15
export interface OrderFormContext {
26
orderForm: OrderForm
37
loading: boolean

0 commit comments

Comments
 (0)