Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel committed Jul 16, 2024
1 parent 9abc385 commit e950517
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 23 deletions.
17 changes: 6 additions & 11 deletions components/CallToActionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@ import { FormattedMessage } from 'react-intl'
const CallToActionBox = ({ title, text }) => {
return (
<div className="flex p-4 bg-gray-300 flex-wrap min-h-[180px]">
<div className='mb-2'>
<h4>
{title}
</h4>
<div className="text-xl">
{text}
</div>
<div className="mb-2">
<h4>{title}</h4>
<div className="text-xl">{text}</div>
</div>
<Link href='https://ooni.org/install'>
<button className="btn btn-primary">
<FormattedMessage id='Country.Overview.NoData.Button.InstallProbe' />
<Link href="https://ooni.org/install">
<button type="button" className="btn btn-primary">
<FormattedMessage id="Country.Overview.NoData.Button.InstallProbe" />
</button>
</Link>
</div>

)
}

Expand Down
42 changes: 33 additions & 9 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export const getUserEmail = () => {
: ''
}

const axios = Axios.create({ baseURL: process.env.NEXT_PUBLIC_USER_FEEDBACK_API })
const axios = Axios.create({
baseURL: process.env.NEXT_PUBLIC_USER_FEEDBACK_API,
})

export const getAPI = async (endpoint, params = {}, config = {}) => {
const bearerToken = getBearerToken()
Expand All @@ -38,7 +40,9 @@ export const getAPI = async (endpoint, params = {}, config = {}) => {
url: endpoint,
params: params,
...config,
...(bearerToken && { headers: { Authorization: `Bearer ${bearerToken}` } }),
...(bearerToken && {
headers: { Authorization: `Bearer ${bearerToken}` },
}),
})
.then((res) => res.data)
.catch((e) => {
Expand All @@ -53,11 +57,15 @@ const postAPI = async (endpoint, params, config) => {
return await getAPI(endpoint, null, { method: 'POST', data: params })
}

export const registerUser = async (email_address, redirectUrl = 'https://explorer.ooni.org') => {
export const registerUser = async (
email_address,
redirectUrl = 'https://explorer.ooni.org',
) => {
// current testing setup does not enable us to check process.env.NODE_ENV (it's set to production
// in headless mode), therefore custom NEXT_PUBLIC_IS_TEST_ENV is used
const redirectTo =
process.env.NODE_ENV === 'development' || process.env.NEXT_PUBLIC_IS_TEST_ENV
process.env.NODE_ENV === 'development' ||
process.env.NEXT_PUBLIC_IS_TEST_ENV
? 'https://explorer.test.ooni.org'
: redirectUrl

Expand All @@ -73,10 +81,19 @@ export const submitFeedback = (feedback) => {
}

export const loginUser = (token) => {
return axios.get(apiEndpoints.USER_LOGIN, { params: { k: token } }).then(({ data }) => {
localStorage.setItem('bearer', JSON.stringify({ token: data?.bearer, email_address: data?.email_address, created_at: Date.now() }))
return data
})
return axios
.get(apiEndpoints.USER_LOGIN, { params: { k: token } })
.then(({ data }) => {
localStorage.setItem(
'bearer',
JSON.stringify({
token: data?.bearer,
email_address: data?.email_address,
created_at: Date.now(),
}),
)
return data
})
}

export const createIncidentReport = (report) => {
Expand All @@ -102,7 +119,14 @@ export const unpublishIncidentReport = (report) => {
export const refreshToken = () => {
const email_address = getUserEmail()
return getAPI(apiEndpoints.TOKEN_REFRESH).then((data) => {
localStorage.setItem('bearer', JSON.stringify({ token: data.bearer, email_address, created_at: Date.now() }))
localStorage.setItem(
'bearer',
JSON.stringify({
token: data.bearer,
email_address,
created_at: Date.now(),
}),
)
})
}

Expand Down
6 changes: 3 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const DEFAULT_LOCALE = 'en'
function getSupportedLanguages() {
const supportedLanguages = new Set()
supportedLanguages.add(DEFAULT_LOCALE) // at least 1 supported language
glob.sync(`${LANG_DIR}/**/*.json`).forEach((f) =>
supportedLanguages.add(basename(f, '.json'))
)
glob
.sync(`${LANG_DIR}/**/*.json`)
.forEach((f) => supportedLanguages.add(basename(f, '.json')))
return [...supportedLanguages]
}

Expand Down

0 comments on commit e950517

Please sign in to comment.