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

Allow Open-Event Ticket #22

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

Sak1012
Copy link
Member

@Sak1012 Sak1012 commented Feb 5, 2025

This PR enables scanning ticket codes from open-event tickets which are stored as strings unlike json in the Eventyay.
The Server value is now stored and checked before parsing the json...

    let qrData = {} 
    if (servername === 'Open-Event') {
      qrData = {
          ticket: cameraStore.qrCodeValue
       }
    } else {
      qrData = JSON.parse(cameraStore.qrCodeValue)
    }

Summary by Sourcery

New Features:

  • Added support for scanning Open-Event ticket codes, which are stored as strings instead of JSON objects.

Copy link

sourcery-ai bot commented Feb 5, 2025

Reviewer's Guide by Sourcery

This pull request adds support for scanning ticket codes from Open-Event tickets, which are stored as strings, unlike JSON in Eventyay. The server value is now stored and checked before parsing the JSON.

Sequence diagram for ticket code scanning process

sequenceDiagram
    participant User as User
    participant App as Check-in App
    participant Camera as Camera Store
    participant Process as Process Store

    User->>App: Scan ticket QR code
    App->>Camera: Store QR code value
    App->>Process: Check-in request
    alt Server is Open-Event
        Process->>Process: Create ticket data from string
    else Other server
        Process->>Process: Parse QR code as JSON
    end
    Process->>Process: Generate nonce
    Process->>Process: Create request body
    Process-->>User: Complete check-in process
Loading

Class diagram showing updated store structure

classDiagram
    class EventyayApi {
        +String apitoken
        +String url
        +String organizer
        +String eventSlug
        +String servername
        +setServer(server)
        +setApiCred()
        +$reset()
    }

    class ProcessEventyayCheckIn {
        +checkIn()
        -handleQRData()
    }

    ProcessEventyayCheckIn ..> EventyayApi : uses
Loading

Flow diagram for QR code processing logic

graph TD
    A[Scan QR Code] --> B{Check Server Type}
    B -->|Open-Event| C[Create ticket data from string]
    B -->|Other| D[Parse QR code as JSON]
    C --> E[Generate nonce]
    D --> E
    E --> F[Create request body]
    F --> G[Complete check-in]
Loading

File-Level Changes

Change Details Files
Added server selection and storage to differentiate between Open-Event and Eventyay ticket formats.
  • Added servername ref to the eventyayapi store.
  • Added setServer function to update the servername ref.
  • Called processApi.setServer in LoginForm.vue to store the selected server.
src/stores/eventyayapi.js
src/components/LoginForm.vue
Modified the check-in process to handle different ticket formats based on the selected server.
  • Retrieved servername from the eventyayapi store.
  • Added conditional logic to parse the QR code value as either JSON or a plain string based on the servername value.
src/stores/processEventyayCheckIn.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

netlify bot commented Feb 5, 2025

Deploy Preview for eventyay-checkin ready!

Name Link
🔨 Latest commit 69b1977
🔍 Latest deploy log https://app.netlify.com/sites/eventyay-checkin/deploys/67ab28c0b1d703000801b95c
😎 Deploy Preview https://deploy-preview-22--eventyay-checkin.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Sak1012 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • The PR removes the Open-Event login validation check without explanation. Please clarify why this validation is no longer needed and confirm it doesn't introduce security risks.
  • There's inconsistent indentation in the new code (mixing tabs and spaces). Please standardize the indentation to match the project's style.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

ticket: cameraStore.qrCodeValue
}
} else {
qrData = JSON.parse(cameraStore.qrCodeValue)
Copy link

Choose a reason for hiding this comment

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

issue: Consider adding error handling for JSON.parse to gracefully handle invalid QR codes

Wrap the JSON.parse in a try-catch block and provide appropriate error feedback to the user when an invalid QR code is scanned.

Comment on lines 99 to 104
const printWindow = window.open(blobUrl, '_blank')
if (printWindow) {
printWindow.onload = function () {
printWindow.onload = function() {
printWindow.print()
URL.revokeObjectURL(blobUrl)
}
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider adding error handling for the print window to ensure blobUrl is always cleaned up

Add an onerror handler to clean up the blobUrl if the window fails to load, preventing potential memory leaks.

Suggested change
const printWindow = window.open(blobUrl, '_blank')
if (printWindow) {
printWindow.onload = function () {
printWindow.onload = function() {
printWindow.print()
URL.revokeObjectURL(blobUrl)
}
const printWindow = window.open(blobUrl, '_blank')
if (printWindow) {
printWindow.onload = function() {
printWindow.print()
URL.revokeObjectURL(blobUrl)
}
printWindow.onerror = function() {
URL.revokeObjectURL(blobUrl)
}
} else {
// Clean up if window failed to open
URL.revokeObjectURL(blobUrl)
}

@mariobehling mariobehling requested a review from hongquan February 5, 2025 06:49
@Sak1012 Sak1012 requested a review from mariobehling February 11, 2025 11:00
@mariobehling mariobehling merged commit 7bf6905 into fossasia:development Feb 11, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants