forked from vtex/react-address-book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
109 lines (101 loc) · 4.14 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="language" content="pt-BR">
<meta name="country" content="BRA">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css">
</head>
<body>
<!--[if lte IE 8]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div id="content" class="container">
</div>
<script src="//io.vtex.com.br/front-libs/jquery/1.8.3/jquery.js"></script>
<!--[if lte IE 9]>
<script src="//io.vtex.com.br/front-libs/es5-shim/4.1.1/es5-shim.min.js"></script>
<script src="//io.vtex.com.br/front-libs/es5-shim/4.1.1/es5-sham.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<![endif]-->
<script src="//io.vtex.com.br/front-libs/react/0.13.2/react.min.js"></script>
<script src="//io.vtex.com.br/front-libs/underscore/1.8.3/underscore-min.js"></script>
<script src="//io.vtex.com.br/front-libs/intl/0.1.4/Intl.min.js"></script>
<script src="//io.vtex.com.br/front-libs/intl/0.1.4/locale-data/jsonp/pt.js"></script>
<script src="//io.vtex.com.br/front-libs/intl/0.1.4/locale-data/jsonp/es.js"></script>
<script src="//io.vtex.com.br/front-libs/intl/0.1.4/locale-data/jsonp/en.js"></script>
<script src="//io.vtex.com.br/front-libs/react-intl/1.2.0/react-intl.min.js"></script>
<script src="//io.vtex.com.br/front-libs/formsy-react/0.12.5/formsy-react.min.js"></script>
<script src="../dist/react-address-book.js"></script>
<script>
var country = $("meta[name='country']").attr("content"); // BRA
var language = $("meta[name='language']").attr("content"); // pt-BR
var locales = language.split('-')[0]; // pt-BR -> pt
// Mock address list
var addressListCountries = {
BRA: [
{
"addressType": "residential",
"receiverName": "Joakim",
"addressId": "-1429301413320",
"postalCode": "22260000",
"city": "Rio de Janeiro",
"state": "RJ",
"country": "BRA",
"street": "Rua São Clemente",
"number": "100",
"neighborhood": "Botafogo",
"complement": "num 1000",
"reference": null,
"geoCoordinates": [],
"selected": true
},
{
"addressType": "residential",
"receiverName": "Martin",
"addressId": "-1429301413321",
"postalCode": "22240000",
"city": "Rio de Janeiro",
"state": "RJ",
"country": "BRA",
"street": "Rua Voluntários da Pátria",
"number": "411",
"neighborhood": "Botafogo",
"complement": "casa 2",
"reference": null,
"geoCoordinates": []
}
]
};
var addressList = addressListCountries[country];
var onSelect = function(address) {
console.log('address selected!', address);
// TODO simulate API latency
// TODO check for errors and re-render with error message
};
var onValidSubmit = function(address) {
console.log('address submit!', address);
// TODO simulate API latency
// TODO check for errors and re-render with error message
};
// git clone git@github.com:vtex/i18n; npm i; grunt
// in production, localhost -> io.vtex.com.br and add version after i18n
$.get("//io.vtex.com.br/i18n/0.1.18/address/" + locales + ".json").done(function(messages) {
var options = {
addressList: addressList,
onSelect: onSelect,
onValidSubmit: onValidSubmit,
messages: messages,
locales: locales,
country: country
};
var content = document.getElementById('content');
React.render(React.createElement(AddressBook, options), content);
});
</script>
</body>
</html>