Merge remote-tracking branch 'origin/dev'
@ -6,14 +6,15 @@ import usePageQuery from 'hooks/usePageQuery';
|
||||
import useMessages from 'hooks/useMessages';
|
||||
import styles from './FilterLink.module.css';
|
||||
|
||||
export function FilterLink({ id, value, label, externalUrl }) {
|
||||
export function FilterLink({ id, value, label, externalUrl, children, className }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { resolveUrl, query } = usePageQuery();
|
||||
const active = query[id] !== undefined;
|
||||
const selected = query[id] === value;
|
||||
|
||||
return (
|
||||
<div className={styles.row}>
|
||||
<div className={classNames(styles.row, className)}>
|
||||
{children}
|
||||
{!value && `(${label || formatMessage(labels.unknown)})`}
|
||||
{value && (
|
||||
<Link
|
||||
|
@ -1,6 +1,7 @@
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.row .inactive {
|
||||
|
@ -11,9 +11,14 @@ export function CountriesTable({ websiteId, ...props }) {
|
||||
|
||||
function renderLink({ x: code }) {
|
||||
return (
|
||||
<div className={locale}>
|
||||
<FilterLink id="country" value={countryNames[code] && code} label={countryNames[code]} />
|
||||
</div>
|
||||
<FilterLink
|
||||
id="country"
|
||||
className={locale}
|
||||
value={countryNames[code] && code}
|
||||
label={countryNames[code]}
|
||||
>
|
||||
<img src={`/images/flags/${code.toLowerCase()}.png`} alt={code} />
|
||||
</FilterLink>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,11 @@ export function RegionsTable({ websiteId, ...props }) {
|
||||
return regions[x] ? `${regions[x]}, ${countryNames[x.split('-')[0]]}` : x;
|
||||
};
|
||||
|
||||
const renderLink = ({ x }) => {
|
||||
const renderLink = ({ x: code }) => {
|
||||
return (
|
||||
<div className={locale}>
|
||||
<FilterLink id="region" value={x} label={renderLabel(x)} />
|
||||
</div>
|
||||
<FilterLink id="region" className={locale} value={code} label={renderLabel(code)}>
|
||||
<img src={`/images/flags/${code.split('-')[0].toLowerCase()}.png`} alt={code} />
|
||||
</FilterLink>
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -20,14 +20,19 @@ export const useCors = createMiddleware(
|
||||
);
|
||||
|
||||
export const useSession = createMiddleware(async (req, res, next) => {
|
||||
const session = await findSession(req as NextApiRequestCollect);
|
||||
try {
|
||||
const session = await findSession(req as NextApiRequestCollect);
|
||||
|
||||
if (!session) {
|
||||
log('useSession: Session not found');
|
||||
return badRequest(res, 'Session not found.');
|
||||
if (!session) {
|
||||
log('useSession: Session not found');
|
||||
return badRequest(res, 'Session not found.');
|
||||
}
|
||||
|
||||
(req as any).session = session;
|
||||
} catch (e: any) {
|
||||
return badRequest(res, e.message);
|
||||
}
|
||||
|
||||
(req as any).session = session;
|
||||
next();
|
||||
});
|
||||
|
||||
|
@ -11,7 +11,7 @@ export async function findSession(req: NextApiRequestCollect) {
|
||||
const { payload } = getJsonBody<CollectRequestBody>(req);
|
||||
|
||||
if (!payload) {
|
||||
return null;
|
||||
throw new Error('Invalid payload.');
|
||||
}
|
||||
|
||||
// Check if cache token is passed
|
||||
@ -29,14 +29,14 @@ export async function findSession(req: NextApiRequestCollect) {
|
||||
const { website: websiteId, hostname, screen, language } = payload;
|
||||
|
||||
if (!validate(websiteId)) {
|
||||
return null;
|
||||
throw new Error('Invalid website ID.');
|
||||
}
|
||||
|
||||
// Find website
|
||||
const website = await loadWebsite(websiteId);
|
||||
|
||||
if (!website) {
|
||||
throw new Error(`Website not found: ${websiteId}`);
|
||||
throw new Error(`Website not found: ${websiteId}.`);
|
||||
}
|
||||
|
||||
const { userAgent, browser, os, ip, country, subdivision1, subdivision2, city, device } =
|
||||
|
@ -32,7 +32,7 @@
|
||||
"merge-messages": "node scripts/merge-messages.js",
|
||||
"generate-lang": "npm-run-all extract-messages merge-messages",
|
||||
"format-lang": "node scripts/format-lang.js",
|
||||
"compile-lang": "formatjs compile-folder --ast build public/intl/messages",
|
||||
"compile-lang": "formatjs compile-folder --ast build/messages public/intl/messages",
|
||||
"check-lang": "node scripts/check-lang.js",
|
||||
"download-country-names": "node scripts/download-country-names.js",
|
||||
"download-language-names": "node scripts/download-language-names.js",
|
||||
|
BIN
public/images/flags/ad.png
Normal file
After Width: | Height: | Size: 235 B |
BIN
public/images/flags/ae.png
Normal file
After Width: | Height: | Size: 122 B |
BIN
public/images/flags/af.png
Normal file
After Width: | Height: | Size: 296 B |
BIN
public/images/flags/ag.png
Normal file
After Width: | Height: | Size: 281 B |
BIN
public/images/flags/ai.png
Normal file
After Width: | Height: | Size: 245 B |
BIN
public/images/flags/al.png
Normal file
After Width: | Height: | Size: 183 B |
BIN
public/images/flags/am.png
Normal file
After Width: | Height: | Size: 110 B |
BIN
public/images/flags/ao.png
Normal file
After Width: | Height: | Size: 201 B |
BIN
public/images/flags/aq.png
Normal file
After Width: | Height: | Size: 186 B |
BIN
public/images/flags/ar.png
Normal file
After Width: | Height: | Size: 141 B |
BIN
public/images/flags/as.png
Normal file
After Width: | Height: | Size: 237 B |
BIN
public/images/flags/at.png
Normal file
After Width: | Height: | Size: 102 B |
BIN
public/images/flags/au.png
Normal file
After Width: | Height: | Size: 211 B |
BIN
public/images/flags/aw.png
Normal file
After Width: | Height: | Size: 139 B |
BIN
public/images/flags/ax.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
public/images/flags/az.png
Normal file
After Width: | Height: | Size: 150 B |
BIN
public/images/flags/ba.png
Normal file
After Width: | Height: | Size: 175 B |
BIN
public/images/flags/bb.png
Normal file
After Width: | Height: | Size: 149 B |
BIN
public/images/flags/bd.png
Normal file
After Width: | Height: | Size: 129 B |
BIN
public/images/flags/be.png
Normal file
After Width: | Height: | Size: 105 B |
BIN
public/images/flags/bf.png
Normal file
After Width: | Height: | Size: 140 B |
BIN
public/images/flags/bg.png
Normal file
After Width: | Height: | Size: 97 B |
BIN
public/images/flags/bh.png
Normal file
After Width: | Height: | Size: 153 B |
BIN
public/images/flags/bi.png
Normal file
After Width: | Height: | Size: 264 B |
BIN
public/images/flags/bj.png
Normal file
After Width: | Height: | Size: 107 B |
BIN
public/images/flags/bl.png
Normal file
After Width: | Height: | Size: 353 B |
BIN
public/images/flags/bm.png
Normal file
After Width: | Height: | Size: 286 B |
BIN
public/images/flags/bn.png
Normal file
After Width: | Height: | Size: 350 B |
BIN
public/images/flags/bo.png
Normal file
After Width: | Height: | Size: 145 B |
BIN
public/images/flags/bq.png
Normal file
After Width: | Height: | Size: 321 B |
BIN
public/images/flags/br.png
Normal file
After Width: | Height: | Size: 260 B |
BIN
public/images/flags/bs.png
Normal file
After Width: | Height: | Size: 147 B |
BIN
public/images/flags/bt.png
Normal file
After Width: | Height: | Size: 316 B |
BIN
public/images/flags/bv.png
Normal file
After Width: | Height: | Size: 150 B |
BIN
public/images/flags/bw.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
public/images/flags/by.png
Normal file
After Width: | Height: | Size: 145 B |
BIN
public/images/flags/bz.png
Normal file
After Width: | Height: | Size: 253 B |
BIN
public/images/flags/ca.png
Normal file
After Width: | Height: | Size: 171 B |
BIN
public/images/flags/cc.png
Normal file
After Width: | Height: | Size: 211 B |
BIN
public/images/flags/cd.png
Normal file
After Width: | Height: | Size: 233 B |
BIN
public/images/flags/cf.png
Normal file
After Width: | Height: | Size: 206 B |
BIN
public/images/flags/cg.png
Normal file
After Width: | Height: | Size: 164 B |
BIN
public/images/flags/ch.png
Normal file
After Width: | Height: | Size: 129 B |
BIN
public/images/flags/ci.png
Normal file
After Width: | Height: | Size: 114 B |
BIN
public/images/flags/ck.png
Normal file
After Width: | Height: | Size: 230 B |
BIN
public/images/flags/cl.png
Normal file
After Width: | Height: | Size: 144 B |
BIN
public/images/flags/cm.png
Normal file
After Width: | Height: | Size: 135 B |
BIN
public/images/flags/cn.png
Normal file
After Width: | Height: | Size: 144 B |
BIN
public/images/flags/co.png
Normal file
After Width: | Height: | Size: 112 B |
BIN
public/images/flags/cr.png
Normal file
After Width: | Height: | Size: 142 B |
BIN
public/images/flags/cu.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
public/images/flags/cv.png
Normal file
After Width: | Height: | Size: 146 B |
BIN
public/images/flags/cw.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
public/images/flags/cx.png
Normal file
After Width: | Height: | Size: 240 B |
BIN
public/images/flags/cy.png
Normal file
After Width: | Height: | Size: 196 B |
BIN
public/images/flags/cz.png
Normal file
After Width: | Height: | Size: 196 B |
BIN
public/images/flags/de.png
Normal file
After Width: | Height: | Size: 97 B |
BIN
public/images/flags/dj.png
Normal file
After Width: | Height: | Size: 234 B |
BIN
public/images/flags/dk.png
Normal file
After Width: | Height: | Size: 127 B |
BIN
public/images/flags/dm.png
Normal file
After Width: | Height: | Size: 200 B |
BIN
public/images/flags/do.png
Normal file
After Width: | Height: | Size: 164 B |
BIN
public/images/flags/dz.png
Normal file
After Width: | Height: | Size: 160 B |
BIN
public/images/flags/ec.png
Normal file
After Width: | Height: | Size: 237 B |
BIN
public/images/flags/ee.png
Normal file
After Width: | Height: | Size: 117 B |
BIN
public/images/flags/eg.png
Normal file
After Width: | Height: | Size: 160 B |
BIN
public/images/flags/eh.png
Normal file
After Width: | Height: | Size: 230 B |
BIN
public/images/flags/er.png
Normal file
After Width: | Height: | Size: 204 B |
BIN
public/images/flags/es.png
Normal file
After Width: | Height: | Size: 190 B |
BIN
public/images/flags/et.png
Normal file
After Width: | Height: | Size: 215 B |
BIN
public/images/flags/fi.png
Normal file
After Width: | Height: | Size: 121 B |
BIN
public/images/flags/fj.png
Normal file
After Width: | Height: | Size: 257 B |
BIN
public/images/flags/fk.png
Normal file
After Width: | Height: | Size: 285 B |
BIN
public/images/flags/fm.png
Normal file
After Width: | Height: | Size: 156 B |
BIN
public/images/flags/fo.png
Normal file
After Width: | Height: | Size: 147 B |
BIN
public/images/flags/fr.png
Normal file
After Width: | Height: | Size: 105 B |
BIN
public/images/flags/ga.png
Normal file
After Width: | Height: | Size: 98 B |
BIN
public/images/flags/gb-eng.png
Normal file
After Width: | Height: | Size: 119 B |
BIN
public/images/flags/gb-nir.png
Normal file
After Width: | Height: | Size: 169 B |
BIN
public/images/flags/gb-sct.png
Normal file
After Width: | Height: | Size: 190 B |
BIN
public/images/flags/gb-wls.png
Normal file
After Width: | Height: | Size: 420 B |
BIN
public/images/flags/gb.png
Normal file
After Width: | Height: | Size: 196 B |
BIN
public/images/flags/gd.png
Normal file
After Width: | Height: | Size: 228 B |
BIN
public/images/flags/ge.png
Normal file
After Width: | Height: | Size: 179 B |
BIN
public/images/flags/gf.png
Normal file
After Width: | Height: | Size: 232 B |
BIN
public/images/flags/gg.png
Normal file
After Width: | Height: | Size: 154 B |
BIN
public/images/flags/gh.png
Normal file
After Width: | Height: | Size: 155 B |
BIN
public/images/flags/gi.png
Normal file
After Width: | Height: | Size: 223 B |
BIN
public/images/flags/gl.png
Normal file
After Width: | Height: | Size: 190 B |
BIN
public/images/flags/gm.png
Normal file
After Width: | Height: | Size: 119 B |
BIN
public/images/flags/gn.png
Normal file
After Width: | Height: | Size: 113 B |
BIN
public/images/flags/gp.png
Normal file
After Width: | Height: | Size: 299 B |
BIN
public/images/flags/gq.png
Normal file
After Width: | Height: | Size: 244 B |
BIN
public/images/flags/gr.png
Normal file
After Width: | Height: | Size: 158 B |