Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b98b21a
re-working the hotel example flow
nicktaras Jan 19, 2021
20016dc
added json flow
nicktaras Jan 19, 2021
90842ea
added logic to further new flow.
nicktaras Jan 19, 2021
b1d85d7
end to end demo ui updated
nicktaras Jan 20, 2021
0674340
code tidy with annotations
nicktaras Jan 20, 2021
b9e6cf1
added most upto date third-party-example. along with the v2 vesion.
nicktaras Jan 20, 2021
2336cab
added heroku endpoint in place of the hotel data
nicktaras Jan 21, 2021
bdbceb7
using demo iframe for now
nicktaras Jan 21, 2021
dd5810f
connected application to new tokenscript.js using heroku data
nicktaras Jan 21, 2021
6372100
added annotations
nicktaras Jan 21, 2021
45c9e1d
updated discount calc
nicktaras Jan 21, 2021
330bd1d
removed lib files. Now working from the heroku lib
nicktaras Jan 21, 2021
4edc40e
updated ui to work with filters. Tidied code naming of components
nicktaras Jan 26, 2021
9f28327
added filter logic to discount tickets defined by webster
nicktaras Jan 28, 2021
aa0a0cf
code tidy
nicktaras Jan 28, 2021
4f316e0
ui adjustments
nicktaras Jan 31, 2021
2ff9db3
added logic for date picker to select date
nicktaras Jan 31, 2021
3ffcb28
updated thirdparty-example
nicktaras Feb 5, 2021
a0dac20
merged the react-thrid-party-examples into a single example
nicktaras Feb 6, 2021
0844c45
removed conditional logic for hotel discount
nicktaras Feb 6, 2021
1b8bdc1
text update
nicktaras Feb 6, 2021
448079b
logic to show ticket instruction to user when there are tickets only
nicktaras Feb 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated ui to work with filters. Tidied code naming of components
  • Loading branch information
nicktaras committed Jan 26, 2021
commit 4edc40e583797fb2fd1014ccb2fccf328eab08aa
20 changes: 15 additions & 5 deletions examples/sites/devcon-issuer/react-third-party-v2/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useState, useEffect } from 'react';
// import { Negotiator, Authenticator } from './TokenScript';
import LogoCard from './LogoCard';
import RoomCard from './RoomCard';
import TokenCard from './TokenCard';
import TokenNotificationCard from './TokenNotificationCard';
import Typography from '@material-ui/core/Typography';
// import roomTypesData from './roomTypesDataMock.json';
import './App.css';
Expand All @@ -17,6 +17,9 @@ function App() {
// Devcon Tickets
let [tokens, setTokens] = useState([]);

// Devcon non-discount offers
let [freeTaxi, setFreeTaxi] = useState(false);

// Room Types Data
let [roomTypesData, setRoomTypesData] = useState([]);

Expand Down Expand Up @@ -86,6 +89,12 @@ function App() {
// Get tokens with applied filter
negotiator.negotiate(tokens => {
setTokens(tokens);
// apply any upfront discounts
tokens.map(token => {
if (token.ticketClass == 2n) {
setFreeTaxi(true);
}
});
});
// Get mock rooms data
getRoomTypesData().then((data) => {
Expand All @@ -98,15 +107,16 @@ function App() {
<LogoCard title={"Hotel Bogota"} />
<div style={{ position: 'absolute', top: '0px', right: '20px' }}>
{tokens.length > 0 &&
<TokenCard tokensNumber={tokens.length} />
<TokenNotificationCard tokensNumber={tokens.length} />
}
</div>
<div className="roomCardsContainer">
{roomTypesData.map((room, index) => {
return <RoomCard key={index} room={room} applyDiscount={applyDiscount} discount={discount} tokens={tokens} book={book} />
})}
</div>
{discount.value &&
{
freeTaxi &&
<div>
<div className="ethScale">
<div id="space">
Expand All @@ -122,11 +132,11 @@ function App() {
</div>
</div>
<Typography className="applyDiscountCopyContainer" gutterBottom variant="body2" component="p">
Devcon discount of {discount.value}% has been granted towards your booking! Enjoy the event.
Free Taxi service available as a Devcon Ticket Class 2n holder! Enjoy the event.
</Typography>
</div>
}
</div>
</div >
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.title {
font-size: 0.8rem;
margin-bottom: 12px;
padding-bottom: 0;
}
.subTitle {
font-size: 1rem;
margin: 0px;
padding-top: 0;
}
.smallCopy {
font-size: 0.8rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import DatePicker from './../DatePicker';
import Card from './../Card';
import TokenCard from './../TokenCard';
import './BookingModal.css';

export default function FormDialog({ roomType, applyDiscount, discount, price, tokens, book }) {
// BOOKING MODAL COMPONENT
// Booking form

export default function BookingModal({ roomType, applyDiscount, discount, price, tokens, book }) {

// Modal State (open boolean).
const [open, setOpen] = React.useState(false);
Expand Down Expand Up @@ -57,10 +61,10 @@ export default function FormDialog({ roomType, applyDiscount, discount, price, t
Book
</Button>
<Dialog open={open} onClose={handleClose} aria-labelledby="form-dialog-title">
<DialogTitle style={{ fontSize: "0.8rem", marginBottom: "12px", paddingBottom: 0 }} disableTypography={true}>
<DialogTitle className="title" disableTypography={true}>
{roomType}
</DialogTitle>
<DialogTitle style={{ fontSize: "1rem", margin: 0, paddingTop: 0 }} disableTypography={true}>
<DialogTitle className="subTitle" disableTypography={true}>
{viewPrice} ETH per night.
</DialogTitle>
<DialogContent>
Expand All @@ -86,11 +90,11 @@ export default function FormDialog({ roomType, applyDiscount, discount, price, t
handleInput={handleInput}
/>
{tokens.length > 0 &&
<p style={{ fontSize: "0.8rem" }}>Select a ticket to apply discount:</p>
<p className="smallCopy">Select a ticket to apply discount:</p>
}
{tokens &&
tokens.map((token, index) => {
return <Card key={index} applyDiscount={applyDiscount} tokenInstance={token} discount={discount}></Card>
return <TokenCard key={index} applyDiscount={applyDiscount} tokenInstance={token} discount={discount}></TokenCard>
})
}
</form>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { MuiPickersUtilsProvider, KeyboardDatePicker } from '@material-ui/picker
// DATE PICKER COMPONENT
// Simply wraps the Date picker material ui component

export default function MaterialUIPickers({ label, handleInput }) {
export default function DatePicker({ label, handleInput }) {

const [selectedDate, setSelectedDate] = React.useState();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import './logoCard.css';
// LOGO CARD COMPONENT
// Simply shows the Hotel title

function MediaCard({ title }) {
function LogoCard({ title }) {
return (
<Card className="logoCard">
<CardContent>
Expand All @@ -19,5 +19,5 @@ function MediaCard({ title }) {
);
}

export default MediaCard;
export default LogoCard;

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const useStyles = makeStyles({
},
});

export default function MediaCard({ room, applyDiscount, discount, tokens, book }) {
export default function RoomCard({ room, applyDiscount, discount, tokens, book }) {
const classes = useStyles();
const { type, price, image, frequency } = room;
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.tokenCard {
margin: 12px;
margin: 24px 0;
flex-grow: 1;
flex-basis: 0;
max-width: 220px;
min-width: 220px;
max-width: 345px;
}

.tokenCard h1 {
font-size: 1.1rem;
}
.tokenCard.selected {
transition: all .35s;
background: #dcdcdc;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,39 @@ import CardActionArea from '@material-ui/core/CardActionArea';
import CardContent from '@material-ui/core/CardContent';
import CardMedia from '@material-ui/core/CardMedia';
import Typography from '@material-ui/core/Typography';
import Zoom from '@material-ui/core/Zoom';
import './TokenCard.css';
// import Skeleton from '@material-ui/lab/Skeleton';
// <Skeleton variant="rect" width={216} height={64} />

// TOKEN CARD COMPONENT
// To show a discount is available to Devcon ticket holders.

const useStyles = makeStyles({
root: {
maxWidth: 345,
},
root: {},
media: {
height: 3,
height: 5,
},
});

function MediaCard({ tokensNumber }) {
function TokenCard({ tokenInstance, applyDiscount, discount }) {
const classes = useStyles();
return (
<Zoom in={true} style={{ transitionDelay: true ? '500ms' : '0ms' }}>
<Card className="tokenCard">
<CardContent>
<Typography gutterBottom variant="h1" component="h1">
{tokensNumber} Devcon Tickets found
</Typography>
<Typography gutterBottom variant="body1" component="p" style={{ fontSize: '0.75rem' }}>
booking discounts available
</Typography>
</CardContent>
<Card className={discount.tokenInstance && discount.tokenInstance.ticketClass === tokenInstance.ticketClass ? 'tokenCard selected' : 'tokenCard'}>
<CardActionArea>
<CardMedia
className={classes.media}
image="./mock.png"
title="token"
/>
</Card>
</Zoom>
<CardContent onClick={e => applyDiscount(tokenInstance)}>
<Typography gutterBottom variant="h5" component="h2">
{tokenInstance.ticketClass.toString()}
</Typography>
<Typography variant="body2" color="textSecondary" component="p">
Ticket Id: {tokenInstance.ticketId.toString()}
</Typography>
<Typography variant="body2" color="textSecondary" component="p">
Devcon Id: {tokenInstance.devconId.toString()}
</Typography>
</CardContent>
</CardActionArea>
</Card >
);
}

export default MediaCard;

export default TokenCard;
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.tokenNotificationCard {
margin: 12px;
flex-grow: 1;
flex-basis: 0;
max-width: 220px;
}

.tokenNotificationCard h1 {
font-size: 1.1rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
import CardMedia from '@material-ui/core/CardMedia';
import Typography from '@material-ui/core/Typography';
import Zoom from '@material-ui/core/Zoom';
import './TokenNotificationCard.css';

// TOKEN NOTIFICATION CARD COMPONENT
// To show a discount is available to Devcon ticket holders.

const useStyles = makeStyles({
root: {
maxWidth: 345,
},
media: {
height: 3,
},
});

function TokenNotificationCard({ tokensNumber }) {
const classes = useStyles();
return (
<Zoom in={true} style={{ transitionDelay: true ? '500ms' : '0ms' }}>
<Card className="tokenNotificationCard">
<CardContent>
<Typography gutterBottom variant="h1" component="h1">
{tokensNumber} Devcon Tickets found
</Typography>
<Typography gutterBottom variant="body1" component="p" style={{ fontSize: '0.75rem' }}>
booking discounts available
</Typography>
</CardContent>
<CardMedia
className={classes.media}
image="./mock.png"
title="token"
/>
</Card>
</Zoom>
);
}

export default TokenNotificationCard;