roggervalf / react-seat-picker

React component to pick a seat
MIT License
28 stars 16 forks source link

Could not find a declaration file for module 'react-seat-picker' #46

Open ryanFonseka opened 3 years ago

ryanFonseka commented 3 years ago

Hi, I get the following error when trying to render the seat plan. image

also "Null" in between seats also not been taken properly image image

hope someone will help

roggervalf commented 3 years ago

hi @ryanFonseka, react-seat-picker does not have a declaration file for now, also you could run the example project that it's in this repo, testing from there I'm getting the expected result Selection_040 Could you please provide more details about it? to try to reproduce it

ryanFonseka commented 3 years ago

Hi, this is my code

`import React, {Component} from 'react'

import SeatPicker from 'react-seat-picker';
// const SeatPicker = require('react-seat-picker');

export default class SeatPlan extends Component {
  state = {
    loading: false
  }

  addSeatCallback = ({ row, number, id }, addCb) => {
    this.setState({
      loading: true
    }, async () => {
      await new Promise(resolve => setTimeout(resolve, 1500))
      console.log(`Added seat ${number}, row ${row}, id ${id}`)
      const newTooltip = `tooltip for id-${id} added by callback`
      addCb(row, number, id, newTooltip)
      this.setState({ loading: false })
    })
  }

  addSeatCallbackContinousCase = ({ row, number, id }, addCb, params, removeCb) => {
    this.setState({
      loading: true
    }, async () => {
      if (removeCb) {
        await new Promise(resolve => setTimeout(resolve, 750))
        console.log(`Removed seat ${params.number}, row ${params.row}, id ${params.id}`)
        removeCb(params.row, params.number)
      }
      await new Promise(resolve => setTimeout(resolve, 750))
      console.log(`Added seat ${number}, row ${row}, id ${id}`)
      const newTooltip = `tooltip for id-${id} added by callback`
      addCb(row, number, id, newTooltip)
      this.setState({ loading: false })
    })
  }

  removeSeatCallback = ({ row, number, id }, removeCb) => {
    this.setState({
      loading: true
    }, async () => {
      await new Promise(resolve => setTimeout(resolve, 1500))
      console.log(`Removed seat ${number}, row ${row}, id ${id}`)
      // A value of null will reset the tooltip to the original while '' will hide the tooltip
      const newTooltip = ['A', 'B', 'C'].includes(row) ? null : ''
      removeCb(row, number, newTooltip)
      this.setState({ loading: false })
    })
  }

  render() {
    const rows = [
      [
        { id: 1, number: 1, isSelected: true, tooltip: "Reserved by you" },
        { id: 2, number: 2, tooltip: "Cost: 15$" },
        null,
        {
          id: 3,
          number: "3",
          isReserved: true,
          orientation: "east",
          tooltip: "Reserved by Rogger"
        },
        { id: 4, number: "4", orientation: "west" },
        null,
        { id: 5, number: 5 },
        { id: 6, number: 6 }
      ],
      [
        {
          id: 7,
          number: 1,
          isReserved: true,
          tooltip: "Reserved by Matthias Nadler"
        },
        { id: 8, number: 2, isReserved: true },
        null,
        { id: 9, number: "3", isReserved: true, orientation: "east" },
        { id: 10, number: "4", orientation: "west" },
        null,
        { id: 11, number: 5 },
        { id: 12, number: 6 }
      ],
      [
        { id: 13, number: 1 },
        { id: 14, number: 2 },
        null,
        { id: 15, number: 3, isReserved: true, orientation: "east" },
        { id: 16, number: "4", orientation: "west" },
        null,
        { id: 17, number: 5 },
        { id: 18, number: 6 }
      ],
      [
        { id: 19, number: 1, tooltip: "Cost: 25$" },
        { id: 20, number: 2 },
        null,
        { id: 21, number: 3, orientation: "east" },
        { id: 22, number: "4", orientation: "west" },
        null,
        { id: 23, number: 5 },
        { id: 24, number: 6, orientation: "west" }
      ],

    ]
    const {loading} = this.state
    return (
      <div>
        <h1>Seat Picker</h1>
        <div>
          <SeatPicker   className="AppSeat"
            addSeatCallback={this.addSeatCallback}
            removeSeatCallback={this.removeSeatCallback}
            rows={rows}
            maxReservableSeats={10}
            alpha
            visible
            selectedByDefault
            loading={loading}
            tooltipProps={{multiline: true}}
          />
        </div>
        <h1>Seat Picker Continuous Case</h1>
        <div style={{ marginTop: '100px' }}>
          <SeatPicker
            addSeatCallback={this.addSeatCallbackContinousCase}
            removeSeatCallback={this.removeSeatCallback}
            rows={rows}
            maxReservableSeats={3}
            alpha
            visible
            selectedByDefault
            loading={loading}
            tooltipProps={{ multiline: true }}
            continuous
          />
        </div>

      </div>
    )
  } 
}`

this is my repo at Node modules image

I face some errors when installing this package as npm install react-seat-picker too. I really want to use this library for my exam. what more details do you need?

ryanFonseka commented 3 years ago

@roggervalf any updates for my request?

roggervalf commented 3 years ago

hi @ryanFonseka, sorry for the delay these days are holidays in my country, I tried your code in Firefox and Chrome and it shows the null seat properly, which browser are you using?

ryanFonseka commented 3 years ago

My browser is Edge. I tried reinstall the seat-picker but got this error image

ryanFonseka commented 3 years ago

Hi, It was a CSS issue and I got it fixed by commenting on the following code in my CSS file

div.seat {
    background-color: green;
  }

  div.seat--reserved {
    background-color: rgb(209, 7, 7);
  }

  div.seat--selected {
    background-color: blue;
  }

  .seat-picker {
    margin: auto;
  }

  .seat-picker__row {
  }

  .seat-picker__row__number {
  }

  /* div.blank {
    display: none;
  } */

Thanks, @roggervalf for your help. can we change the row characters as we desired as in "A1, A2, A3.." or "AL1,AR1,AL2..." image

also how to remove an empty row character image

roggervalf commented 3 years ago

Thanks, @roggervalf for your help. can we change the row characters as we desired as in "A1, A2, A3.." or "AL1,AR1,AL2..."

also how to remove an empty row character

Hey @ryanFonseka, rows only can be alpha true or false (letters or numbers) and the row could not be removed as well, but there is a prop visible that hides the row title, and maybe use the seat number could help like AL1, AL2 and so on.

ryanFonseka commented 3 years ago

@roggervalf Hi thanks for the information. If i want to add a title text in a blank row(in row D ) is there a workaround like image

roggervalf commented 3 years ago

@ryanFonseka for now it does not support that, I will add an enhancement label in this issue

ryanFonseka commented 3 years ago

@roggervalf Hi brother any updates for the above?

roggervalf commented 3 years ago

Hi @ryanFonseka, sorry but I didn't have the time to work on this, but I'm open to receive prs for it

congvinhnguyennn commented 1 year ago

My browser is Edge. I tried reinstall the seat-picker but got this error image

hi, can i ask the way to solve this problem ? I got this problem too.