-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/2.34.0' into main
- Loading branch information
Showing
12 changed files
with
414 additions
and
34 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -35,6 +35,7 @@ html body { | |
|
||
button { | ||
all: unset; | ||
text-align: center; | ||
box-sizing: border-box; | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import firebase from "firebase/app"; | ||
import { db } from "src/firebase"; | ||
import { serverUtils } from "src/services/serverUtils"; | ||
|
||
const PROMOTION_REF = db.ref("promotions"); | ||
const TIERS_REF = db.ref("tiers"); | ||
|
||
const START_TZ = "Z"; // UTC | ||
const END_TZ = "-07:00"; // PACIFIC TIME | ||
|
||
export class promotionService { | ||
static async getAllPromotions() { | ||
return (await PROMOTION_REF.once("value")).val(); | ||
} | ||
|
||
static getPromotionsWithCallback(callback) { | ||
return PROMOTION_REF.on("value", callback); | ||
} | ||
|
||
static async getAllActivePromotions() { | ||
const promotions = (await PROMOTION_REF.once("value")).val(); | ||
const server_time = await serverUtils.getServerTime(); | ||
return Object.values(promotions).filter((promotion) => { | ||
promotion.active_from = new Date(`${promotion.active_from}T00:00:00${START_TZ}`); | ||
promotion.active_until = new Date(`${promotion.active_until}T00:00:00${END_TZ}`); | ||
return ( | ||
promotion.disabled === undefined && | ||
server_time < promotion.active_until && | ||
server_time > promotion.active_from | ||
); | ||
}); | ||
} | ||
|
||
static async getFirstActivePromotion() { | ||
const promotions = await this.getAllActivePromotions(); | ||
return promotions.length > 0 ? promotions[0] : undefined; | ||
} | ||
|
||
static async addNewPromotion(promotion_object) { | ||
promotion_object.code = promotion_object.code.toUpperCase(); | ||
return PROMOTION_REF.child(promotion_object.code).set(promotion_object); | ||
} | ||
|
||
static async deletePromotion(promotion_code) { | ||
return PROMOTION_REF.child(promotion_code).remove(); | ||
} | ||
|
||
static async disablePromotion(promotion_code) { | ||
return PROMOTION_REF.child(promotion_code).child("disabled").set(true); | ||
} | ||
|
||
static async enablePromotion(promotion_code) { | ||
return PROMOTION_REF.child(promotion_code).child("disabled").remove(); | ||
} | ||
} |
Oops, something went wrong.