Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 7218 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import React from 'react'
import { Avatar } from '@mui/material'
import { Link } from 'react-router-dom'
import parse from 'html-react-parser'
import { useSelector } from 'react-redux'
import EditIcon from '@mui/icons-material/Edit'
import DeleteIcon from '@mui/icons-material/Delete'

import {
  QuestionActions,
  QuestionDetails,
  QuestionStats,
  QuestionUserInfo,
  StyledQuestionCard,
} from './QuestionCard'
import CommentSection from '../feed/CommentSection'

const AnswerCard = ({
  unique = '',
  uuid = '',
  question_uuid = '',
  user_image = '',
  user_url = '',
  user_name = '',
  time_elapsed = '',
  text = '',
  reaction = '',
  total_comments = 0,
  total_reactions = 0,
  comments = [
    {
      unique: '64de4a4714a45',
      answer_uuid: '0370dcb5-453c-4e6e-8fbf-c40b0488ca83',
      user_image:
        '/storage/type/user/code/e85129fa-18eb-4149-8640-fea9ae916cdc/filename/user-profile-64d514603a742.png/',
      user_url: '/profile/view/e85129fa-18eb-4149-8640-fea9ae916cdc',
      user_name: 'Santiago Olivera',
      time_elapsed: '2 meses',
      comment: 'weerwerwe',
      link_delete:
        '/my-coach/questions/comments/0370dcb5-453c-4e6e-8fbf-c40b0488ca83/delete/d2eda6ff-ca35-425c-b791-fe0e97aafc28',
    },
  ],
  link_edit = '',
  link_delete = '',
  link_reaction_delete = '',
  link_save_reaction = '',
  link_add_comment = '',
}) => {
  const labels = useSelector(({ intl }) => intl.labels)

  const onEdit = () => {}

  const onDelete = () => {}

  return (
    <>
      <StyledQuestionCard>
        <QuestionDetails>
          <QuestionUserInfo>
            <Link to={user_url}>
              <Avatar
                src={user_image}
                alt={`${user_name} profile image`}
                sx={{ width: '50px', height: '50px' }}
              />
            </Link>
            <p>{user_name}</p>
          </QuestionUserInfo>

          <QuestionStats className="mb-2">
            <span>{`${comments} ${labels.comments}`}</span>
          </QuestionStats>
        </QuestionDetails>
        {text && parse(text)}

        <QuestionActions>
          {link_edit && (
            <button
              className="btn feed__share-option"
              onClick={() => onEdit(link_edit)}
            >
              <EditIcon />
              {labels.edit}
            </button>
          )}
          {link_delete && (
            <button
              className="btn feed__share-option"
              onClick={() => onDelete(link_delete)}
            >
              <DeleteIcon />
              {labels.delete}
            </button>
          )}
        </QuestionActions>
        <CommentSection
          addUrl={link_add_comment}
          currentComments={comments}
          isShow
        />
      </StyledQuestionCard>
    </>
  )
}

export default AnswerCard