0xVantrex / 0xVantrex/DevHub-JS

Manage Developer Profiles (js/profiles.js)

Ouverte
#9 0 commentaires 0 réactions 1 personne assignée Réclamée par @0xVantrex Voir sur GitHub
wontfix
Langage dominant
HTML
Étoiles
0
Forks
0
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.name}

${p.role}



✏️




${p.skills.map(skill => `${skill}`).join('')}

${p.github ? `

GitHub:
@${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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript
Domaine
frontend
Type d'issue
Fonctionnalité
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
75/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.