2
0

fix(docker): 🐛 Runtime public environment

This commit is contained in:
Baptiste Arnaud
2022-06-22 07:36:11 +02:00
parent 3e47b37c2e
commit f801a29539
55 changed files with 358 additions and 167 deletions

View File

@ -4,14 +4,13 @@ import { Grid, SearchContext } from '@giphy/react-components'
import { GiphyLogo } from 'assets/logos'
import React, { useContext, useState, useEffect } from 'react'
import { useDebounce } from 'use-debounce'
import { env } from 'utils'
type GiphySearchProps = {
onSubmit: (url: string) => void
}
const giphyFetch = new GiphyFetch(
process.env.NEXT_PUBLIC_GIPHY_API_KEY as string
)
const giphyFetch = new GiphyFetch(env('GIPHY_API_KEY') as string)
export const GiphySearch = ({ onSubmit }: GiphySearchProps) => {
const { fetchGifs, searchKey, setSearch } = useContext(SearchContext)

View File

@ -16,12 +16,7 @@ import { useTypebot } from 'contexts/TypebotContext'
import { BaseEmoji, emojiIndex } from 'emoji-mart'
import { emojis } from './emojis'
import { Input } from '../Textbox/Input'
import { isEmpty } from 'utils'
import getConfig from 'next/config'
const {
publicRuntimeConfig: { NEXT_PUBLIC_GIPHY_API_KEY },
} = getConfig()
import { env, isEmpty } from 'utils'
type Props = {
url?: string
@ -188,10 +183,10 @@ const EmojiContent = ({
}
const GiphyContent = ({ onNewUrl }: ContentProps) => {
if (isEmpty(NEXT_PUBLIC_GIPHY_API_KEY))
if (isEmpty(env('GIPHY_API_KEY')))
return <Text>NEXT_PUBLIC_GIPHY_API_KEY is missing in environment</Text>
return (
<SearchContextManager apiKey={NEXT_PUBLIC_GIPHY_API_KEY}>
<SearchContextManager apiKey={env('GIPHY_API_KEY') as string}>
<GiphySearch onSubmit={onNewUrl} />
</SearchContextManager>
)