Next.js Discord

Discord Forum

Separate components

Unanswered
In&Out posted this in #help-forum
Open in Discord
Hey folks, I am trying to make a modal that will show info of a card by clicking the card, will look like this. How can I make a modal get info of that certain card and only that card

11 Replies

This is how it looks now, but I can't figure out how to get individual info from the columns
"use client";
import Modal from "../../utils/modal/Modal";
import useModalStore from "../../utils/modal/Store";
import styles from "./Column.module.css";

interface Iprops {
  order: string;
  date: string;
  status: string;
  total: string;
  action: string;
  index: number;
}

function Columns({ order, date, status, total, action, index }: Iprops) {
  const { opened, openModal, closeModal } = useModalStore();

  return (
    <div className={styles.Container}>
      <div className={styles.LeftRows}>
        <div className={styles.Row}>{order}</div>
        <div className={styles.Row}>{date}</div>
        <div className={styles.Row}>{status}</div>
        <div className={styles.Row}>{total}</div>
      </div>
      <div>
        <button className={styles.Button} onClick={openModal}>
          {action}
        </button>
      </div>
      <Modal debug={index} />
    </div>
  );
}

export default Columns;
Currently this is the code for a column
Don't need a ready code, just a roadmap or something on how to do that
create state in the modal and when card is rendered pass setter to it and set the state of the modal?
isn't modal wrapper on this card?
another approach can be to use event emitter, emit state from card and listen for this event in the modal
@AM create state in the modal and when card is rendered pass setter to it and set the state of the modal?
Aha so to have useState, and when clicked on card, it fills the useState then display that to modal?