Hebrew group names + multilingual API + cleanup mock data
- task_groups.names JSONB with cs/he/ru/ua translations - GET /groups?lang=he returns Hebrew names - Removed 14 test users, cleaned orphan data - 6 real users, 2 real tasks remain Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,16 +1,28 @@
|
||||
// Task Team — Groups CRUD — 2026-03-29
|
||||
async function groupRoutes(app) {
|
||||
app.get('/groups', async (req) => {
|
||||
const lang = req.query.lang;
|
||||
const { rows } = await app.db.query(
|
||||
'SELECT * FROM task_groups ORDER BY order_index ASC'
|
||||
);
|
||||
return { data: rows };
|
||||
const data = rows.map(row => {
|
||||
if (lang && row.names && row.names[lang]) {
|
||||
return { ...row, name: row.names[lang] };
|
||||
}
|
||||
return row;
|
||||
});
|
||||
return { data };
|
||||
});
|
||||
|
||||
app.get('/groups/:id', async (req) => {
|
||||
const lang = req.query.lang;
|
||||
const { rows } = await app.db.query('SELECT * FROM task_groups WHERE id = $1', [req.params.id]);
|
||||
if (!rows.length) throw { statusCode: 404, message: 'Group not found' };
|
||||
return { data: rows[0] };
|
||||
const row = rows[0];
|
||||
if (lang && row.names && row.names[lang]) {
|
||||
row.name = row.names[lang];
|
||||
}
|
||||
return { data: row };
|
||||
});
|
||||
|
||||
app.post('/groups', async (req) => {
|
||||
@@ -64,7 +76,6 @@ async function groupRoutes(app) {
|
||||
if (!Array.isArray(time_zones)) {
|
||||
throw { statusCode: 400, message: 'time_zones must be an array of [{days, from, to}]' };
|
||||
}
|
||||
// Validate each timezone entry
|
||||
for (const tz of time_zones) {
|
||||
if (!Array.isArray(tz.days) || !tz.from || !tz.to) {
|
||||
throw { statusCode: 400, message: 'Each timezone must have days (array), from (HH:MM), to (HH:MM)' };
|
||||
@@ -84,7 +95,6 @@ async function groupRoutes(app) {
|
||||
if (!Array.isArray(locations)) {
|
||||
throw { statusCode: 400, message: 'locations must be an array of [{name, lat, lng, radius_m}]' };
|
||||
}
|
||||
// Validate each location entry
|
||||
for (const loc of locations) {
|
||||
if (!loc.name || loc.lat === undefined || loc.lng === undefined) {
|
||||
throw { statusCode: 400, message: 'Each location must have name, lat, lng' };
|
||||
|
||||
Reference in New Issue
Block a user