Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SkillCoins Payment and GitHub Data Integration for Premium Resume Template #942 #1007

Merged
merged 2 commits into from
Nov 9, 2024

Conversation

Mohitranag18
Copy link
Contributor

@Mohitranag18 Mohitranag18 commented Nov 9, 2024

Description

This PR implements the SkillCoins-based payment system and GitHub data integration for the premium resume template. Users can now purchase the premium template for 10 SkillCoins and have it dynamically populated with their GitHub data, including followers, following count, total repositories, and top repositories. The feature also includes a preview option to view the populated template before saving or sharing it.

Tasks

SkillCoins Payment System

  • Display the SkillCoins cost (10 SkillCoins) near the premium template option to inform users of the cost upfront.
  • Prompt users to confirm spending 10 SkillCoins when they select the premium resume template.
  • Deduct 10 SkillCoins from the user's balance upon confirmation and grant access to the premium template.

Testing and Verification

  • Test that the SkillCoins cost displays correctly and the confirmation prompt appears upon selection.
  • Verify that 10 SkillCoins are deducted only upon user confirmation.
  • Confirm the GitHub data is fetched and displayed accurately in the template.
  • Check that the preview functionality shows the populated template correctly before finalizing.

Screenshot:

Screenshot 2024-11-08 at 13-11-39 Build Resume

Screenshot 2024-11-08 at 13-11-55 Build Resume

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced skill coins management, allowing users to track and utilize coins for premium features.
    • Added a premium section in the "Developer" template, enabling access to premium features with skill coins.
    • Enhanced resume generation to include achievements alongside education and experience.
  • Bug Fixes

    • Improved consistency in event listeners and display updates related to skill coins.
  • Style

    • Updated CSS for better visual appeal, including new styles for icons and buttons.
  • Documentation

    • Minor adjustments to inline styles for improved layout.

Copy link

coderabbitai bot commented Nov 9, 2024

Walkthrough

The changes in this pull request involve modifications to several files related to the resume builder application. Key updates include the removal of a script reference in RateMyResume.html, enhancements to skill coin management in RateMyResume.js and Resume.js, and the addition of new CSS classes in Resume.css. The HTML structure has been updated to include a premium feature section that displays skill coins and allows users to access premium templates. Overall, these changes aim to improve user interaction and functionality within the resume builder.

Changes

File Change Summary
RateMyResume.html Removed script reference to Resume.js. Minor HTML structure adjustments.
RateMyResume.js Added functions for managing skill coins, including getSkillCoins, updateCoinsDisplay, and updateCoins. Updated logic for handling skill coins and event listeners.
Resume.css Introduced new classes for layout and styling, including .icons, .premium, and .fa-coins. Enhanced button styles with transitions.
Resume.js Added logic for managing skill coins and achievements. Introduced collectAchiveData function and updated generateResumeHTML to include achievements.
resume.html Added skill coins icon and display in the header. Introduced a premium section for the developer template with a skill coins display and button.

Possibly related issues

Possibly related PRs

Suggested labels

hacktoberfest, level3, gssoc-ext, hacktoberfest-accepted

Suggested reviewers

  • GarimaSingh0109

Poem

🐰 In the land of resumes, bright and bold,
Skill coins shimmer, a treasure to hold.
With templates so premium, the choices abound,
Crafting careers with each click and sound.
A hop and a skip, let’s build with delight,
For every achievement, our futures shine bright! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

🧹 Outside diff range and nitpick comments (10)
RateMyResume.js (4)

Line range hint 33-47: Enhance form submission with proper validations and user feedback.

The current implementation lacks proper file validation and uses basic alerts for user feedback.

 document.getElementById('resumeForm').addEventListener('submit', function(event) {
     event.preventDefault();
 
     const username = document.getElementById('username').value;
     const jobRole = document.getElementById('jobRole').value;
     const resume = document.getElementById('resume').files[0];
 
+    // Validate file type and size
+    const isValidFileType = resume?.type === 'application/pdf';
+    const isValidFileSize = resume?.size <= 5 * 1024 * 1024; // 5MB limit
+
+    if (!isValidFileType) {
+        showToast('Please upload a PDF file only.', 'error');
+        return;
+    }
+
+    if (!isValidFileSize) {
+        showToast('File size should be less than 5MB.', 'error');
+        return;
+    }
 
     if (resume) {
-        alert(`Your resume has been successfully uploaded...`);
+        showToast('Resume uploaded successfully!', 'success');
     } else {
-        alert('Please select a PDF file.');
+        showToast('Please select a file.', 'error');
     }
 });

48-67: Refactor UI toggle to use CSS classes instead of inline styles.

The current implementation uses direct style manipulation and hardcoded colors.

+// Add to your CSS file
+.section-hidden {
+  display: none;
+}
+.tab-active {
+  background-color: var(--primary-color);
+}
+.tab-inactive {
+  background-color: var(--secondary-color);
+}

-ratingboard.style.display = 'none';
+ratingboard.classList.add('section-hidden');

 ratingboardhead.addEventListener('click', () => {
-    rating.style.display = 'none';
-    ratingboard.style.display = '';
-    ratingboardhead.style.backgroundColor = 'gray';
-    myratinghead.style.backgroundColor = 'blue';
+    rating.classList.add('section-hidden');
+    ratingboard.classList.remove('section-hidden');
+    ratingboardhead.classList.add('tab-active');
+    myratinghead.classList.add('tab-inactive');
 });

104-109: Move keywords data to a configuration file.

The keywords data should be maintained separately for easier updates and maintenance.

-const keywords = {
-    "Software Developer": ["JavaScript", "React", "Node.js", "API", "Agile", "Version Control"],
-    "Data Analyst": ["SQL", "Python", "Excel", "Data Visualization", "Machine Learning", "Tableau"],
-    "Graphic Designer": ["Adobe Photoshop", "Illustrator", "InDesign", "Branding", "Typography", "Creative Suite"]
-};
+import { jobKeywords } from '../config/keywords.js';

131-136: Enhance clipboard functionality with better feedback and error handling.

The current clipboard implementation could be more robust.

-function copyKeywords() {
+async function copyKeywords() {
     const keywordText = document.getElementById("keyword-text").innerText;
-    navigator.clipboard.writeText(keywordText)
-        .then(() => alert("Keywords copied to clipboard!"))
-        .catch(err => console.error("Failed to copy keywords:", err));
+    try {
+        await navigator.clipboard.writeText(keywordText);
+        showToast("Keywords copied to clipboard!", "success");
+    } catch (err) {
+        console.error("Failed to copy keywords:", err);
+        showToast("Failed to copy keywords. Please try again.", "error");
+    }
 }
Resume.css (2)

7-20: Enhance maintainability and responsiveness of icon styling.

Consider the following improvements:

  1. Use CSS variables for consistent styling
  2. Add media queries for better mobile responsiveness
+:root {
+  --icon-text-color: white;
+  --icon-text-size: 2.3rem;
+  --icon-spacing: 1.5rem;
+}

 .icons{
     display: flex;
     align-items: center;
 }
 .icons i{
-    margin-left: 1.5rem;
+    margin-left: var(--icon-spacing);
 }
 .icons p{
     display: inline;
-    color: white;
-    font-size: 2.3rem;
-    margin-left: 1rem;
-    line-height: 2.3rem;
+    color: var(--icon-text-color);
+    font-size: var(--icon-text-size);
+    margin-left: calc(var(--icon-spacing) / 1.5);
+    line-height: var(--icon-text-size);
 }

+@media (max-width: 768px) {
+  :root {
+    --icon-text-size: 1.8rem;
+    --icon-spacing: 1rem;
+  }
+}

426-430: Improve semantic naming and spacing consistency.

The .premium class could be more descriptive, and spacing should use CSS variables.

-.premium{
+.premium-template-header {
-    margin-top: 1rem;
+    margin-top: var(--spacing-md, 1rem);
     display: flex;
     justify-content: space-between;
 }
Resume.js (4)

175-204: Refactor card selection logic to eliminate code duplication

The event listeners for basicCard, classicCard, and modernCard contain repetitive code for updating background colors and setting selecttemp. Refactoring this logic into a single function would improve maintainability and readability.

Here's how you might refactor:

const cards = [
    { element: basicCard, selectTempValue: 1 },
    { element: classicCard, selectTempValue: 2 },
    { element: modernCard, selectTempValue: 3 }
];

cards.forEach(card => {
    card.element.addEventListener('click', () => {
        [basicCard, classicCard, modernCard, developerCard].forEach(c => c.style.backgroundColor = '#f4f4f4');
        card.element.style.backgroundColor = '#ADD8E6';
        selecttemp = card.selectTempValue;
    });
});

Line range hint 260-329: Correct the misspelling of 'achive' to 'achieve'

The variable names, function names, and identifiers use 'achive' instead of 'achieve' or 'achievement'. Correct spelling enhances code readability and professionalism.

Here's the corrected version:

-const achiveEntries = collectAchiveData();
+const achievementEntries = collectAchievementData();

...

-function collectAchiveData() {
+function collectAchievementData() {
    return Array.from(document.querySelectorAll('.achievement-entry')).map(entry => ({
        heading: entry.querySelector('input[placeholder="e.g., Best Employee of the Year"]').value,
        description: entry.querySelector('textarea[placeholder="Describe your achievement or certification"]').value,
    }));
}

...

-let achiveHTML = achiveEntries.map(achi => `
+let achievementHTML = achievementEntries.map(achieve => `
    <div>
-        <strong>${achi.heading}</strong><br>
-        <p>${achi.description}</p>
+        <strong>${achieve.heading}</strong><br>
+        <p>${achieve.description}</p>
    </div>
`).join('');

...

// Update all occurrences in the code where 'achive' is used.

Line range hint 264-467: Use 'selectedTemplate' consistently instead of 'selecttemp'

There is inconsistency in using selecttemp and selectedTemplate to track the selected template. This can lead to confusion and bugs. Use selectedTemplate throughout for consistency.

Update your code as follows:

  • In the event listeners for template cards, set selectedTemplate to the template name:

    basicCard.addEventListener('click', () => {
        selectedTemplate = 'basic';
        // Update card backgrounds...
    });
    
    classicCard.addEventListener('click', () => {
        selectedTemplate = 'classic';
        // Update card backgrounds...
    });
    
    modernCard.addEventListener('click', () => {
        selectedTemplate = 'modern';
        // Update card backgrounds...
    });
    
    // Similarly for developerCard when unlocked
  • In generateResumeHTML, use the template parameter:

    function generateResumeHTML(name, profile, email, contact, location, githubid, skills, educationEntries, experienceEntries, achievementEntries, projectEntries, template) {
        if(template === 'basic'){
            // Generate Basic template
        } else if(template === 'classic'){
            // Generate Classic template
        } else if(template === 'modern'){
            // Generate Modern template
        } else if(template === 'developer'){
            // Generate Developer template
        }
        // Rest of the code...
    }
  • Remove selecttemp if it's no longer needed.

This ensures consistent usage and improves code clarity.


Line range hint 362-376: Use dynamic GitHub username instead of hardcoded value

In the init() function, the username is hardcoded to "mohitranag18". This prevents fetching GitHub data for other users.

Update the code to use the GitHub ID provided by the user:

async function init() {
    const username = githubid; // Ensure 'githubid' contains the user's input
    if (username) {
        const data = await fetchGitHubData(username);
        // Use 'data' as needed
    } else {
        console.error("GitHub ID is not provided.");
    }
}

Ensure that githubid is properly captured from the user's input fields.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 42c118b and 32573eb.

📒 Files selected for processing (5)
  • RateMyResume.html (0 hunks)
  • RateMyResume.js (2 hunks)
  • Resume.css (2 hunks)
  • Resume.js (11 hunks)
  • resume.html (2 hunks)
💤 Files with no reviewable changes (1)
  • RateMyResume.html
🔇 Additional comments (2)
resume.html (1)

266-269: Verify SkillCoins integration with backend.

Let's verify the integration of SkillCoins management system:

✅ Verification successful

SkillCoins integration is properly implemented

The codebase shows a complete and working implementation of the SkillCoins system:

  • Proper coin management through localStorage with getSkillCoins()
  • UI updates via updateCoinsDisplay()
  • Premium button handler with correct coin validation (10 coins requirement)
  • Proper deduction logic when purchasing premium features
  • Error handling for insufficient coins

The integration appears to be fully functional and properly implemented across both Resume.js and RateMyResume.js files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for SkillCoins related function implementations

# Check for SkillCoins management functions
echo "Checking for SkillCoins management functions..."
rg -l "updateSkillCoins|getSkillCoins|deductSkillCoins" --type js

# Check for premium template handling
echo "Checking for premium template handlers..."
rg -l "handlePremiumPurchase|validateSkillCoins" --type js

# Check for error handling
echo "Checking for error handling..."
rg -l "handleInsufficientCoins|handlePurchaseError" --type js

Length of output: 487


Script:

#!/bin/bash
# Let's examine the actual implementation of SkillCoins functions in the identified files

echo "Checking SkillCoins implementation in RateMyResume.js:"
rg "updateSkillCoins|getSkillCoins|deductSkillCoins" RateMyResume.js -C 2

echo -e "\nChecking SkillCoins implementation in Resume.js:"
rg "updateSkillCoins|getSkillCoins|deductSkillCoins" Resume.js -C 2

echo -e "\nChecking premium button click handlers:"
rg "getpremium.*click" -C 2

Length of output: 2290

Resume.js (1)

Line range hint 423-575: Ensure GitHub data is ready before generating the resume

In the generateResumeHTML function, variables like followers, following, etc., are used to populate the Developer template. Ensure that the GitHub data has been fetched and is available before generating the resume.

You can check whether GitHub data has been fetched before generating the resume and handle cases where data is not available.

RateMyResume.js Show resolved Hide resolved
RateMyResume.js Show resolved Hide resolved
RateMyResume.js Show resolved Hide resolved
RateMyResume.js Show resolved Hide resolved
RateMyResume.js Show resolved Hide resolved
Resume.css Show resolved Hide resolved
resume.html Show resolved Hide resolved
resume.html Show resolved Hide resolved
Resume.js Show resolved Hide resolved
Resume.js Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants