This file contains hidden or 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
<svelte:head> | |
<title>Giftcards</title> | |
</svelte:head> | |
<script> | |
import { onMount } from 'svelte'; | |
const accessToken = 'Bearer ACCESS_TOKEN' |
This file contains hidden or 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
package com.example.restapi; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.boot.CommandLineRunner; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.boot.web.client.RestTemplateBuilder; | |
import org.springframework.context.annotation.Bean; |
This file contains hidden or 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
package com.example.restapi; | |
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
import java.util.List; | |
@JsonIgnoreProperties(ignoreUnknown = true) | |
public class Countries { |
This file contains hidden or 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
import React, { useReducer } from "react"; | |
const myStyle = { | |
color: "white", | |
fontSize: "20px" | |
}; | |
export default function Recipe() { | |
const initialState = { | |
RecipePrice: 0, |
This file contains hidden or 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
import useLockBodyScroll from "./useLockBodyScroll"; | |
export default function Landing() { | |
useLockBodyScroll(); | |
const [data, setData] = useState([]); | |
useEffect(() => { | |
fetch(URL) | |
.then(response => response.json()) | |
.then(data => setData(data)); | |
}, []); |
This file contains hidden or 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
import { useLayoutEffect } from "react"; | |
export default function useLockBodyScroll() { | |
useLayoutEffect(() => { | |
// Get original value of body overflow | |
const originalStyle = window.getComputedStyle(document.body).overflow; | |
// Prevent scrolling on mount | |
document.body.style.overflow = "hidden"; | |
// Re-enable scrolling when component unmounts | |
return () => (document.body.style.overflow = originalStyle); |
This file contains hidden or 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
import React from "react"; | |
import { useArray } from "react-hanger"; | |
const myStyle = { | |
color: "white" | |
}; | |
export default function App() { | |
const todos = useArray(["35cl", "50cl", "60cl"]); | |
return ( | |
<div style={myStyle}> |
This file contains hidden or 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
import React from "react"; | |
import Purchase from "./components/Purchase"; | |
import Landing from "./components/Landing"; | |
import HomePage from "./components/HomePage"; | |
const Routes = { | |
"/": () => <HomePage />, | |
"/purchase": () => <Purchase />, | |
"/landing": () => <Landing /> | |
}; |
This file contains hidden or 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
import React from "react"; | |
import useForm from "react-hook-form"; | |
const active = { | |
fontSize: "15px" | |
}; | |
export default function Purchase() { | |
const { register, handleSubmit, errors } = useForm(); | |
const onSubmit = data => { // upload the data retreived from the form to a database, return value to a user, etc | |
console.log(data); |
This file contains hidden or 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
import React, { useState, useEffect } from "react"; | |
const URL = "https://api.punkapi.com/v2/beers"; | |
export default function Landing() { | |
const [beer, setBeer] = useState([]); | |
useEffect(() => { | |
fetch(URL) | |
.then(response => response.json()) | |
.then(beer => setBeer(beer)); | |
}, {}); |
NewerOlder