Add dictionary feature with term management and UI components
- Implement backend API for term CRUD operations - Add frontend dictionary page with search and filtering - Integrate shadcn/ui components (Dialog) - Create term management UI with add/edit/delete functionality - Update database seed with initial terms - Add API client for term operations - Complete Phase 2 of development plan
This commit is contained in:
@@ -44,7 +44,110 @@ async function main() {
|
||||
console.log(' Email: demo@znakovni.hr');
|
||||
console.log(' Password: demo123');
|
||||
|
||||
// Add sample terms here in future phases
|
||||
// Create sample terms
|
||||
console.log('🌱 Creating sample terms...');
|
||||
|
||||
const sampleTerms = [
|
||||
{
|
||||
wordText: 'Dobar dan',
|
||||
normalizedText: 'dobar dan',
|
||||
wordType: 'PHRASE',
|
||||
cefrLevel: 'A1',
|
||||
shortDescription: 'Pozdrav koji se koristi tijekom dana',
|
||||
tags: JSON.stringify(['pozdrav', 'osnovno']),
|
||||
},
|
||||
{
|
||||
wordText: 'Hvala',
|
||||
normalizedText: 'hvala',
|
||||
wordType: 'INTERJECTION',
|
||||
cefrLevel: 'A1',
|
||||
shortDescription: 'Izraz zahvalnosti',
|
||||
tags: JSON.stringify(['zahvala', 'osnovno']),
|
||||
},
|
||||
{
|
||||
wordText: 'Molim',
|
||||
normalizedText: 'molim',
|
||||
wordType: 'INTERJECTION',
|
||||
cefrLevel: 'A1',
|
||||
shortDescription: 'Izraz ljubaznosti pri traženju nečega',
|
||||
tags: JSON.stringify(['ljubaznost', 'osnovno']),
|
||||
},
|
||||
{
|
||||
wordText: 'Kuća',
|
||||
normalizedText: 'kuca',
|
||||
wordType: 'NOUN',
|
||||
cefrLevel: 'A1',
|
||||
shortDescription: 'Zgrada u kojoj ljudi žive',
|
||||
tags: JSON.stringify(['dom', 'zgrada']),
|
||||
},
|
||||
{
|
||||
wordText: 'Škola',
|
||||
normalizedText: 'skola',
|
||||
wordType: 'NOUN',
|
||||
cefrLevel: 'A1',
|
||||
shortDescription: 'Ustanova za obrazovanje',
|
||||
tags: JSON.stringify(['obrazovanje', 'ustanova']),
|
||||
},
|
||||
{
|
||||
wordText: 'Učiti',
|
||||
normalizedText: 'uciti',
|
||||
wordType: 'VERB',
|
||||
cefrLevel: 'A1',
|
||||
shortDescription: 'Stjecati znanje ili vještine',
|
||||
tags: JSON.stringify(['obrazovanje', 'aktivnost']),
|
||||
},
|
||||
{
|
||||
wordText: 'Jesti',
|
||||
normalizedText: 'jesti',
|
||||
wordType: 'VERB',
|
||||
cefrLevel: 'A1',
|
||||
shortDescription: 'Uzimati hranu',
|
||||
tags: JSON.stringify(['hrana', 'aktivnost']),
|
||||
},
|
||||
{
|
||||
wordText: 'Piti',
|
||||
normalizedText: 'piti',
|
||||
wordType: 'VERB',
|
||||
cefrLevel: 'A1',
|
||||
shortDescription: 'Uzimati tekućinu',
|
||||
tags: JSON.stringify(['piće', 'aktivnost']),
|
||||
},
|
||||
{
|
||||
wordText: 'Voda',
|
||||
normalizedText: 'voda',
|
||||
wordType: 'NOUN',
|
||||
cefrLevel: 'A1',
|
||||
shortDescription: 'Bezbojna tekućina neophodna za život',
|
||||
tags: JSON.stringify(['piće', 'osnovno']),
|
||||
},
|
||||
{
|
||||
wordText: 'Lijep',
|
||||
normalizedText: 'lijep',
|
||||
wordType: 'ADJECTIVE',
|
||||
cefrLevel: 'A1',
|
||||
shortDescription: 'Privlačan, ugodan za gledanje',
|
||||
tags: JSON.stringify(['opis', 'pozitivno']),
|
||||
},
|
||||
];
|
||||
|
||||
for (const termData of sampleTerms) {
|
||||
// Check if term already exists
|
||||
const existing = await prisma.term.findFirst({
|
||||
where: {
|
||||
normalizedText: termData.normalizedText,
|
||||
},
|
||||
});
|
||||
|
||||
if (!existing) {
|
||||
const term = await prisma.term.create({
|
||||
data: termData,
|
||||
});
|
||||
console.log(` ✅ Created term: ${term.wordText}`);
|
||||
} else {
|
||||
console.log(` ⏭️ Term already exists: ${termData.wordText}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('✅ Seed completed successfully!');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user