Skip to content

Commit

Permalink
donate
Browse files Browse the repository at this point in the history
  • Loading branch information
zai committed Nov 14, 2023
1 parent 9a69cff commit cd2ded5
Show file tree
Hide file tree
Showing 9 changed files with 997 additions and 1 deletion.
88 changes: 88 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ app.get("/fundraiser/winter-23", async (req, res) => {
res.render("fundraiser/winter-23/storefront", { products: productsData, testimonials: testimonialData });
});



app.get("/fundraiser/winter-23/:slug", async (req, res) => {
//filter by slug here
console.log(req.params.slug);
Expand Down Expand Up @@ -815,6 +817,92 @@ app.get("/fundraiser/winter-23/:slug", async (req, res) => {



app.get("/donate", async (req, res) => {

const responseTest = await getDatabaseEntries("16ea90c83765437c86f87bd13a205ca6", [{property:"Date", direction:"descending"}])
const testimonialData = responseTest.map((testimonial) => {
console.log(testimonial)
return parseTestimonials(testimonial)
})
console.log(testimonialData)

const response = await getDatabaseEntries(NOTION_STORE_DATABASE_ID, [
{ property: "Name", direction: "descending" },
]);
console.log(response);

const productsData = response.map((product) => {
return parseProductData(product);
});

const shopifyData = await getShopifyProducts();

for (const product of productsData) {
const shopifyId = product["Shopify ID"];

if (!shopifyId) {
continue;
}

const node = shopifyData[`gid://shopify/Product/${shopifyId}`];

if (node) {
product.availableForSale = node.availableForSale;
product.totalInventory = node.totalInventory;
product.availableInventory = node.variants.edges.reduce((accum, val) => {
return accum + val.node.quantityAvailable;
}, 0);
}
}

console.log(productsData);
res.render("donate/storefront", { products: productsData, testimonials: testimonialData });
});



app.get("/donate/:slug", async (req, res) => {
//filter by slug here
console.log(req.params.slug);
const response = await getDatabaseEntry(NOTION_STORE_DATABASE_ID, {
property: "Website-Slug",
rich_text: { equals: req.params.slug },
});
console.log(response);

if (response) {
const productData = parseProductData(response);
const shopifyId = productData["Shopify ID"];

if (shopifyId) {
try {
const shopifyData = await getShopifyProduct(shopifyId);

if (shopifyData) {
productData.availableForSale = shopifyData.availableForSale;
productData.totalInventory = shopifyData.totalInventory;
productData.availableInventory = shopifyData.variants.edges.reduce(
(accum, val) => {
return accum + val.node.quantityAvailable;
},
0
);
}
} catch (e) {
console.error(e);
}
}

console.log(productData);
res.render("donate/product", productData);
}
});






app.get("/participate", async (req,res) => {
const sessions = await getDatabaseEntries("ba1f9876ad3e4810880d4802d3d70d6f", [{property:"Date", direction:"descending"}])
const events = await getDatabaseEntries("10c62665c6ca4383bbdc12788c45df14", [{property:"Date", direction:"descending"}])
Expand Down
Binary file added public/images/market/10yrs-stickers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/market/crt-hat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/market/learn-unlearn.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions public/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,20 @@ h1 {



.sfp .sponsorlogo.grayarea::after {
background-image: url('/images/fundraiser/winter-23/gray-area-logo.svg');
fill: var(--text-color);
}

.sfpc .small .sponsorlogo.grayarea::after {
width: calc(75px + 2.54vw);
height: calc(9px + 0.24vw);
background-image: url('/images/fundraiser/winter-23/gray-area-logo.svg');
fill: var(--text-color);
}




.socials img {
width: 5vw;
Expand Down
Binary file modified public/templates/.DS_Store
Binary file not shown.
Loading

0 comments on commit cd2ded5

Please sign in to comment.