0xVantrex / 0xVantrex/DevHub-JS
Manage Developer Profiles (js/profiles.js)
- Lingua principale
- HTML
- Stelle
- 0
- Fork
- 0
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Goal
You’re building the main logic for handling developer profiles — CRUD (Create, Read, Update, Delete) operations — and rendering them dynamically into the UI grid.
This file powers the “Add Profile” modal and everything inside the .profiles-grid section.
File Ownership
You fully own:
/js/profiles.js
You are responsible for all logic related to:
Adding new profiles
Editing existing profiles
Deleting profiles
Rendering the updated UI
🧠 Learning Focus
DOM manipulation
Event delegation
Data-driven rendering
Modular JS exports/imports
Array methods (map, filter, findIndex)
🔧 Functions to Implement
1. addProfile(profileData)
Adds a new profile to the in-memory array and re-renders.
export function addProfile(profileData, profiles) {
const newProfile = {
id: Date.now(),
...profileData,
skills: profileData.skills.split(',').map(s => s.trim()).filter(Boolean),
};
profiles.push(newProfile);
renderProfiles(profiles);
return profiles;
}
2. editProfile(id, updatedData)
Finds the profile by id and updates its fields.
export function editProfile(id, updatedData, profiles) {
const index = profiles.findIndex(p => p.id === id);
if (index !== -1) {
profiles[index] = {
...profiles[index],
...updatedData,
skills: updatedData.skills.split(',').map(s => s.trim()).filter(Boolean),
};
}
renderProfiles(profiles);
return profiles;
}
3. deleteProfile(id)
Removes a profile after confirmation.
export function deleteProfile(id, profiles) {
if (!confirm("Are you sure you want to delete this profile?")) return profiles;
const updated = profiles.filter(p => p.id !== id);
renderProfiles(updated);
return updated;
}
4. renderProfiles(profiles)
Takes an array of profiles and injects HTML into #profilesGrid.
export function renderProfiles(profiles) {
const grid = document.getElementById("profilesGrid");
if (profiles.length === 0) {
grid.innerHTML = `
No profiles found
Click "Add Profile" to create one.
return;
}
grid.innerHTML = profiles.map(p => `
✏️
${p.skills.map(skill => `${skill}`).join('')}
${p.github ? `
` : ""}
`).join("");
}
🪄 DOM Event Handling
You’ll listen for clicks on the edit and delete buttons using event delegation:
document.getElementById("profilesGrid").addEventListener("click", (e) => {
const action = e.target.dataset.action;
const id = Number(e.target.dataset.id);
if (!action || !id) return;
if (action === "edit") openEditModal(id);
if (action === "delete") deleteProfile(id, profiles);
});
Integration Points
Your functions will be called from:
app.js (main initializer)
modal.js (when saving or editing profiles)
You will not handle search or stats — those are in separate modules.
Definition of Done
Profiles can be created, edited, and deleted.
UI updates instantly after each action.
No console errors or warnings.
Functions are exported and usable from other modules.
Code is clean, commented, and modular.
Optional
Add transition animations when profiles appear/disappear.
Add basic input validation (e.g., name/role required).
Use localStorage to persist profiles between reloads.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
The work is in /js/profiles.js. Start by reading the existing function stubs and the renderProfiles implementation. The entry point is the event listener on #profilesGrid. Integrate with app.js and modal.js as described. 'Done' means all CRUD operations work, the UI updates, and the functions are exported cleanly.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript
- Ambito
- frontend
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 75/100