Merge remote-tracking branch 'origin/dev'

This commit is contained in:
Mike Cao 2023-04-23 19:55:35 -07:00
commit 26a9cb67d8
263 changed files with 41 additions and 20 deletions

View File

@ -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

View File

@ -1,6 +1,7 @@
.row {
display: flex;
align-items: center;
gap: 10px;
}
.row .inactive {

View File

@ -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>
);
}

View File

@ -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>
);
};

View File

@ -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();
});

View File

@ -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 } =

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

BIN
public/images/flags/ae.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

BIN
public/images/flags/af.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

BIN
public/images/flags/ag.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

BIN
public/images/flags/ai.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

BIN
public/images/flags/al.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

BIN
public/images/flags/am.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

BIN
public/images/flags/ao.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

BIN
public/images/flags/aq.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

BIN
public/images/flags/ar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

BIN
public/images/flags/as.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
public/images/flags/at.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 B

BIN
public/images/flags/au.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

BIN
public/images/flags/aw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

BIN
public/images/flags/ax.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

BIN
public/images/flags/az.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
public/images/flags/ba.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

BIN
public/images/flags/bb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
public/images/flags/bd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

BIN
public/images/flags/be.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

BIN
public/images/flags/bf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

BIN
public/images/flags/bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

BIN
public/images/flags/bh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

BIN
public/images/flags/bi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

BIN
public/images/flags/bj.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 B

BIN
public/images/flags/bl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

BIN
public/images/flags/bm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

BIN
public/images/flags/bn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

BIN
public/images/flags/bo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

BIN
public/images/flags/bq.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

BIN
public/images/flags/br.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

BIN
public/images/flags/bs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
public/images/flags/bt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

BIN
public/images/flags/bv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
public/images/flags/bw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

BIN
public/images/flags/by.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

BIN
public/images/flags/bz.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

BIN
public/images/flags/ca.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

BIN
public/images/flags/cc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

BIN
public/images/flags/cd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

BIN
public/images/flags/cf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

BIN
public/images/flags/cg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

BIN
public/images/flags/ch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

BIN
public/images/flags/ci.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

BIN
public/images/flags/ck.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

BIN
public/images/flags/cl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

BIN
public/images/flags/cm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

BIN
public/images/flags/cn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

BIN
public/images/flags/co.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

BIN
public/images/flags/cr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

BIN
public/images/flags/cu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

BIN
public/images/flags/cv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

BIN
public/images/flags/cw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

BIN
public/images/flags/cx.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

BIN
public/images/flags/cy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

BIN
public/images/flags/cz.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

BIN
public/images/flags/de.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

BIN
public/images/flags/dj.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

BIN
public/images/flags/dk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

BIN
public/images/flags/dm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

BIN
public/images/flags/do.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

BIN
public/images/flags/dz.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

BIN
public/images/flags/ec.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
public/images/flags/ee.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B

BIN
public/images/flags/eg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

BIN
public/images/flags/eh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

BIN
public/images/flags/er.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

BIN
public/images/flags/es.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

BIN
public/images/flags/et.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

BIN
public/images/flags/fi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

BIN
public/images/flags/fj.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

BIN
public/images/flags/fk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

BIN
public/images/flags/fm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

BIN
public/images/flags/fo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
public/images/flags/fr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

BIN
public/images/flags/ga.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

BIN
public/images/flags/gb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

BIN
public/images/flags/gd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

BIN
public/images/flags/ge.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

BIN
public/images/flags/gf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

BIN
public/images/flags/gg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

BIN
public/images/flags/gh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

BIN
public/images/flags/gi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

BIN
public/images/flags/gl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

BIN
public/images/flags/gm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

BIN
public/images/flags/gn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

BIN
public/images/flags/gp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

BIN
public/images/flags/gq.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

BIN
public/images/flags/gr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Some files were not shown because too many files have changed in this diff Show More