0xVantrex / 0xVantrex/DevHub-JS

Manage Developer Profiles (js/profiles.js)

Open
#9 0 comments 0 reactions 1 assignee Claimed by @0xVantrex View on GitHub
wontfix
Dominant language
HTML
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

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.

Contributor guide

No contributing guide indexed for this repository

Research direction

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.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.