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 InfiniteScroll from 'react-infinite-scroller'; | |
| import { MessageListContainer } from './styles'; | |
| const MessagesList = ({ hasMore, loadMore, messages }) => ( | |
| <InfiniteScroll | |
| isReverse | |
| hasMore={hasMore} | |
| loadMore={loadMore} | |
| loader={<span key={0}>Loading</span>} |
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'; | |
| import { MessageRepository, ChannelRepository, EkoChannelType } from 'eko-sdk'; | |
| import MessagesList from '../MessagesList'; | |
| import MessageComposeBar from '../MessageComposeBar'; | |
| import { ChatViewContainer } from './styles'; | |
| const channelRepo = new ChannelRepository(); | |
| const messageRepo = new MessageRepository(); | |
| const initialPagination = { |
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, { useEffect, useState } from 'react'; | |
| import { ChannelRepository } from 'eko-sdk'; | |
| import { ChannelsListContainer, ChannelItem } from './styles'; | |
| // Set up a new channel repository | |
| const channelRepo = new ChannelRepository(); | |
| const ChannelsList = () => { | |
| const [channels, setChannels] = useState([]); | |
| const [currentChannelId, setCurrenChannelId] = useState(null); |
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 { useTranslate } from 'locale/utils/useTranslate.js' | |
| const ComponentUsingTranslate = () => { | |
| const { translate } = useTranslate() | |
| return ( | |
| <div> | |
| <h1>{translate('general.home')}</h1> | |
| <button>Click to get started</button> |
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
| body: { | |
| name: "Ministry of Roasters", | |
| location: "Bangkok", | |
| rating: 4, | |
| shouldTriggerDeploy: true, | |
| authorization" 'my-secret-password', | |
| } |
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
| exports.handler = async event => { | |
| ... | |
| // Always save the new shop in the database. | |
| await dynamo.put(params).promise(); | |
| // Publish a message to SNS topic if a deploy is also required. | |
| let didTriggerDeploy = false; | |
| if (shouldTriggerDeploy) { | |
| try { |
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
| const axios = require('axios'); | |
| exports.handler = async () => { | |
| try { | |
| await axios.post( | |
| `${process.env.NETLIFY_DEPLOY_URL}?trigger_title=add+shop+form`, | |
| {} | |
| ); | |
| } catch (err) { | |
| console.log('Error triggering deploy', err); |
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 { availableLocales, defaultLocale } from './constants'; | |
| // Check if we support the language. | |
| const isSupportedLocale = locale => Object.keys(availableLocales).includes(locale) | |
| export const getInitialLocale = () => { | |
| // Don't run this code if on the server-side. | |
| if (!process.browser) return defaultLocale; | |
| // First check local storage. |
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 fetch from 'isomorphic-unfetch'; | |
| const getFetchAuthOptions = ctx => { | |
| if (ctx?.req) { | |
| return { | |
| headers: { cookie: ctx.req.headers.cookie }, | |
| }; | |
| } | |
| return { credentials: 'include' }; | |
| }; |
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 Router from 'next/router' | |
| export const isomorphicRedirect = (url, ctx) => { | |
| if (ctx?.res) { | |
| ctx.res.writeHead(302, { Location: url }); | |
| ctx.res.end(); | |
| } else { | |
| return Router.push(url); | |
| } | |
| } |