-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1097470
commit e615341
Showing
12 changed files
with
239 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Base from './Base'; | ||
|
||
|
||
export default class GiftCard extends Base { | ||
|
||
del() { | ||
throw new Error("Gift card delete not supported."); | ||
} | ||
} | ||
|
||
GiftCard.model = { | ||
id: "id", | ||
root: "/webshop/gift-card", | ||
attributes: { | ||
created_at: null, | ||
email: "", | ||
status: "", | ||
validation_code: 0, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Base from './Base'; | ||
|
||
|
||
export default class GiftCardRow extends Base { | ||
|
||
del() { | ||
throw new Error("GiftCard delete not supported."); | ||
} | ||
} | ||
|
||
GiftCardRow.model = { | ||
id: "id", | ||
attributes: { | ||
amount: null, | ||
product_quantity: null, | ||
product_id: null, | ||
name: "", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import { Link } from "react-router-dom"; | ||
import GiftCard from "../Models/GiftCard"; | ||
import Collection from "../Models/Collection"; | ||
import CollectionTable from "../Components/CollectionTable"; | ||
import DateTimeShow from "../Components/DateTimeShow"; | ||
import SearchBox from "../Components/SearchBox"; | ||
import CollectionNavigation from "../Models/CollectionNavigation"; | ||
|
||
const Row = props => { | ||
const { item } = props; | ||
return ( | ||
<tr> | ||
<td><Link to={"/sales/gift-card/" + item.id}>{item.id}</Link></td> | ||
<td><DateTimeShow date={item.created_at} /></td> | ||
<td>{item.status}</td> | ||
<td>{item.email}</td> | ||
</tr> | ||
); | ||
}; | ||
|
||
|
||
class GiftCardList extends CollectionNavigation { | ||
|
||
constructor(props) { | ||
super(props); | ||
const { search, page } = this.state; | ||
|
||
this.collection = new Collection({ type: GiftCard, url: "/webshop/gift-card", search, page }); | ||
} | ||
|
||
render() { | ||
const columns = [ | ||
{ title: "Presentkort" }, | ||
{ title: "Skapad" }, | ||
{ title: "Status" }, | ||
{ title: "Email" }, | ||
]; | ||
|
||
return ( | ||
<div className="uk-margin-top"> | ||
<h2>Presentkort</h2> | ||
<SearchBox handleChange={this.onSearch} value={this.state.search} /> | ||
<CollectionTable emptyMessage="Inga presentkort" rowComponent={Row} collection={this.collection} columns={columns} onPageNav={this.onPageNav} /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
|
||
export default GiftCardList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from 'react'; | ||
import { Link } from "react-router-dom"; | ||
import GiftCard from "../Models/GiftCard"; | ||
import Collection from "../Models/Collection"; | ||
import CollectionTable from "../Components/CollectionTable"; | ||
import GiftCardRow from "../Models/GiftCardRow"; | ||
import Currency from "../Components/Currency"; | ||
|
||
class GiftCardShow extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
const { id } = props.match.params; | ||
this.gift_card = GiftCard.get(id); | ||
this.state = {}; | ||
this.gift_cardRows = new Collection({ type: GiftCardRow, url: `/webshop/gift-card/${id}/products`, pageSize: 0, expand: 'product' }); | ||
} | ||
|
||
componentDidMount() { | ||
this.unsubscribe = this.gift_card.subscribe(() => { | ||
const { email, validation_code } = this.gift_card; | ||
this.setState({ email, validation_code }); | ||
}); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.unsubscribe(); | ||
} | ||
|
||
render() { | ||
const { email, validation_code } = this.state; | ||
const { id } = this.props.match.params; | ||
|
||
return ( | ||
<div> | ||
<div className="uk-margin-top"> | ||
<h2>Presentkort #{id}</h2> | ||
<div> | ||
<h3>Email</h3> | ||
<td>{email}</td> | ||
</div> | ||
<div> | ||
<h3>Valideringskod</h3> | ||
<td>{validation_code}</td> | ||
</div> | ||
</div> | ||
<div className="uk-margin-top"> | ||
<h3>Orderrader</h3> | ||
<CollectionTable | ||
emptyMessage="Listan är tom" | ||
collection={this.gift_cardRows} | ||
columns={[ | ||
{ title: "Produkt" }, | ||
{ title: "Pris", class: 'uk-text-right' }, | ||
{ title: "Antal" }, | ||
{ title: "Summa", class: 'uk-text-right' } | ||
]} | ||
rowComponent={({ item }) => | ||
<tr> | ||
<td><Link to={"/sales/product/" + item.product_id}>{item.name}</Link></td> | ||
<td className="uk-text-right"><Currency value={100 * item.amount / item.product_quantity} /> kr</td> | ||
<td>{item.product_quantity}</td> | ||
<td className="uk-text-right"><Currency value={100 * item.amount} /> kr</td> | ||
</tr> | ||
} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default GiftCardShow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,7 +312,7 @@ def create_shop_transactions() -> None: | |
transaction = get_or_create( | ||
Transaction, | ||
id=index, | ||
defaults=dict(member_id=1, amount=membership_prod.price, status="completed", created_at=test_date), | ||
defaults=dict(member_id=1, amount=membership_prod.price, status="completed", created_at=datetime.now()), | ||
) | ||
transaction_content = get_or_create( | ||
TransactionContent, | ||
|
@@ -332,7 +332,7 @@ def create_shop_transactions() -> None: | |
action_type="add_labaccess_days", | ||
value=10, | ||
status="completed", | ||
completed_at=test_date, | ||
completed_at=datetime.now(), | ||
), | ||
) | ||
index += 1 | ||
|
@@ -411,17 +411,27 @@ def create_shop_accounts_cost_centers() -> None: | |
def create_shop_gift_cards() -> None: | ||
banner(YELLOW, "Creating Fake 'Gift Cards' and 'Gift Card & Product Mappings'") | ||
|
||
gift_card = get_or_create( | ||
GiftCard, amount=299.00, validation_code=12989519, email="[email protected]", status="activated" | ||
) | ||
|
||
# Get existing product with ID: 64 (Makerspace access starter pack) | ||
# Get existing product Makerspace access starter pack | ||
product = get_or_create( | ||
Product, | ||
name="Makerspace access starter pack", | ||
) | ||
|
||
get_or_create(ProductGiftCardMapping, gift_card_id=gift_card.id, product_id=product.id) | ||
gift_card = get_or_create( | ||
GiftCard, | ||
amount=product.price, | ||
validation_code=12989519, | ||
email="[email protected]", | ||
status="activated", | ||
) | ||
|
||
get_or_create( | ||
ProductGiftCardMapping, | ||
gift_card_id=gift_card.id, | ||
product_id=product.id, | ||
product_quantity=1, | ||
amount=product.price, | ||
) | ||
|
||
db_session.commit() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters