Merge remote-tracking branch 'origin/dev'
|
@ -6,14 +6,15 @@ import usePageQuery from 'hooks/usePageQuery';
|
||||||
import useMessages from 'hooks/useMessages';
|
import useMessages from 'hooks/useMessages';
|
||||||
import styles from './FilterLink.module.css';
|
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 { formatMessage, labels } = useMessages();
|
||||||
const { resolveUrl, query } = usePageQuery();
|
const { resolveUrl, query } = usePageQuery();
|
||||||
const active = query[id] !== undefined;
|
const active = query[id] !== undefined;
|
||||||
const selected = query[id] === value;
|
const selected = query[id] === value;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.row}>
|
<div className={classNames(styles.row, className)}>
|
||||||
|
{children}
|
||||||
{!value && `(${label || formatMessage(labels.unknown)})`}
|
{!value && `(${label || formatMessage(labels.unknown)})`}
|
||||||
{value && (
|
{value && (
|
||||||
<Link
|
<Link
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
.row {
|
.row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row .inactive {
|
.row .inactive {
|
||||||
|
|
|
@ -11,9 +11,14 @@ export function CountriesTable({ websiteId, ...props }) {
|
||||||
|
|
||||||
function renderLink({ x: code }) {
|
function renderLink({ x: code }) {
|
||||||
return (
|
return (
|
||||||
<div className={locale}>
|
<FilterLink
|
||||||
<FilterLink id="country" value={countryNames[code] && code} label={countryNames[code]} />
|
id="country"
|
||||||
</div>
|
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;
|
return regions[x] ? `${regions[x]}, ${countryNames[x.split('-')[0]]}` : x;
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderLink = ({ x }) => {
|
const renderLink = ({ x: code }) => {
|
||||||
return (
|
return (
|
||||||
<div className={locale}>
|
<FilterLink id="region" className={locale} value={code} label={renderLabel(code)}>
|
||||||
<FilterLink id="region" value={x} label={renderLabel(x)} />
|
<img src={`/images/flags/${code.split('-')[0].toLowerCase()}.png`} alt={code} />
|
||||||
</div>
|
</FilterLink>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,19 @@ export const useCors = createMiddleware(
|
||||||
);
|
);
|
||||||
|
|
||||||
export const useSession = createMiddleware(async (req, res, next) => {
|
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) {
|
if (!session) {
|
||||||
log('useSession: Session not found');
|
log('useSession: Session not found');
|
||||||
return badRequest(res, '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();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ export async function findSession(req: NextApiRequestCollect) {
|
||||||
const { payload } = getJsonBody<CollectRequestBody>(req);
|
const { payload } = getJsonBody<CollectRequestBody>(req);
|
||||||
|
|
||||||
if (!payload) {
|
if (!payload) {
|
||||||
return null;
|
throw new Error('Invalid payload.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if cache token is passed
|
// Check if cache token is passed
|
||||||
|
@ -29,14 +29,14 @@ export async function findSession(req: NextApiRequestCollect) {
|
||||||
const { website: websiteId, hostname, screen, language } = payload;
|
const { website: websiteId, hostname, screen, language } = payload;
|
||||||
|
|
||||||
if (!validate(websiteId)) {
|
if (!validate(websiteId)) {
|
||||||
return null;
|
throw new Error('Invalid website ID.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find website
|
// Find website
|
||||||
const website = await loadWebsite(websiteId);
|
const website = await loadWebsite(websiteId);
|
||||||
|
|
||||||
if (!website) {
|
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 } =
|
const { userAgent, browser, os, ip, country, subdivision1, subdivision2, city, device } =
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
"merge-messages": "node scripts/merge-messages.js",
|
"merge-messages": "node scripts/merge-messages.js",
|
||||||
"generate-lang": "npm-run-all extract-messages merge-messages",
|
"generate-lang": "npm-run-all extract-messages merge-messages",
|
||||||
"format-lang": "node scripts/format-lang.js",
|
"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",
|
"check-lang": "node scripts/check-lang.js",
|
||||||
"download-country-names": "node scripts/download-country-names.js",
|
"download-country-names": "node scripts/download-country-names.js",
|
||||||
"download-language-names": "node scripts/download-language-names.js",
|
"download-language-names": "node scripts/download-language-names.js",
|
||||||
|
|
After Width: | Height: | Size: 235 B |
After Width: | Height: | Size: 122 B |
After Width: | Height: | Size: 296 B |
After Width: | Height: | Size: 281 B |
After Width: | Height: | Size: 245 B |
After Width: | Height: | Size: 183 B |
After Width: | Height: | Size: 110 B |
After Width: | Height: | Size: 201 B |
After Width: | Height: | Size: 186 B |
After Width: | Height: | Size: 141 B |
After Width: | Height: | Size: 237 B |
After Width: | Height: | Size: 102 B |
After Width: | Height: | Size: 211 B |
After Width: | Height: | Size: 139 B |
After Width: | Height: | Size: 163 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 175 B |
After Width: | Height: | Size: 149 B |
After Width: | Height: | Size: 129 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 140 B |
After Width: | Height: | Size: 97 B |
After Width: | Height: | Size: 153 B |
After Width: | Height: | Size: 264 B |
After Width: | Height: | Size: 107 B |
After Width: | Height: | Size: 353 B |
After Width: | Height: | Size: 286 B |
After Width: | Height: | Size: 350 B |
After Width: | Height: | Size: 145 B |
After Width: | Height: | Size: 321 B |
After Width: | Height: | Size: 260 B |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 316 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 145 B |
After Width: | Height: | Size: 253 B |
After Width: | Height: | Size: 171 B |
After Width: | Height: | Size: 211 B |
After Width: | Height: | Size: 233 B |
After Width: | Height: | Size: 206 B |
After Width: | Height: | Size: 164 B |
After Width: | Height: | Size: 129 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 230 B |
After Width: | Height: | Size: 144 B |
After Width: | Height: | Size: 135 B |
After Width: | Height: | Size: 144 B |
After Width: | Height: | Size: 112 B |
After Width: | Height: | Size: 142 B |
After Width: | Height: | Size: 163 B |
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 240 B |
After Width: | Height: | Size: 196 B |
After Width: | Height: | Size: 196 B |
After Width: | Height: | Size: 97 B |
After Width: | Height: | Size: 234 B |
After Width: | Height: | Size: 127 B |
After Width: | Height: | Size: 200 B |
After Width: | Height: | Size: 164 B |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 237 B |
After Width: | Height: | Size: 117 B |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 230 B |
After Width: | Height: | Size: 204 B |
After Width: | Height: | Size: 190 B |
After Width: | Height: | Size: 215 B |
After Width: | Height: | Size: 121 B |
After Width: | Height: | Size: 257 B |
After Width: | Height: | Size: 285 B |
After Width: | Height: | Size: 156 B |
After Width: | Height: | Size: 147 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 98 B |
After Width: | Height: | Size: 119 B |
After Width: | Height: | Size: 169 B |
After Width: | Height: | Size: 190 B |
After Width: | Height: | Size: 420 B |
After Width: | Height: | Size: 196 B |
After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 179 B |
After Width: | Height: | Size: 232 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 223 B |
After Width: | Height: | Size: 190 B |
After Width: | Height: | Size: 119 B |
After Width: | Height: | Size: 113 B |
After Width: | Height: | Size: 299 B |
After Width: | Height: | Size: 244 B |
After Width: | Height: | Size: 158 B |