update Faq
This commit is contained in:
parent
cf3e6c484b
commit
656f2a67f1
@ -15,9 +15,6 @@ import TableHead from '@mui/material/TableHead';
|
||||
import TablePagination from '@mui/material/TablePagination';
|
||||
import TableRow from '@mui/material/TableRow';
|
||||
import TableSortLabel from '@mui/material/TableSortLabel';
|
||||
import Toolbar from '@mui/material/Toolbar';
|
||||
import Tooltip from '@mui/material/Tooltip';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import { visuallyHidden } from '@mui/utils';
|
||||
import { GetServerSideProps } from 'next';
|
||||
import React, { useState } from 'react';
|
||||
@ -194,7 +191,7 @@ export default function FaqTable({questionData}: any) {
|
||||
|
||||
const handleSelectAllClick = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (event.target.checked) {
|
||||
const newSelecteds = questionData.map((n) => n.questionData);
|
||||
const newSelecteds = questionData.map((n) => n.id);
|
||||
setSelected(newSelecteds);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1,21 +1,26 @@
|
||||
import React, { useState } from 'react'
|
||||
import Image from 'next/image'
|
||||
|
||||
import getAPIClient from '../../services/ssrApi';
|
||||
import { FaqQuestionsCardBody, FaqQuestionsCardHeader, CommonQuestionsCardView } from './FaqQuestionsCardView'
|
||||
|
||||
export default function CommonsQuestionsCard() {
|
||||
interface CommonsQuestionsCardInterface {
|
||||
question: string,
|
||||
answer: string,
|
||||
}
|
||||
|
||||
export default function CommonsQuestionsCard({question, answer}: CommonsQuestionsCardInterface) {
|
||||
const [ showCardBody, setShowCardBody ] = useState<boolean>(false)
|
||||
return (
|
||||
|
||||
<CommonQuestionsCardView>
|
||||
<FaqQuestionsCardHeader>
|
||||
<h4>Lorem ipsum dolor sit amet, consectetur adipiscing elit?</h4>
|
||||
<h4>{question}</h4>
|
||||
<Image src={showCardBody? '/assets/less-icon.svg' : '/assets/plus-icon.svg' } width={32} height={32} onClick={() => setShowCardBody(!showCardBody)} />
|
||||
</FaqQuestionsCardHeader>
|
||||
|
||||
<FaqQuestionsCardBody showCardBody={showCardBody} >
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
Consequat porta faucibus elementum pharetra varius
|
||||
{answer}
|
||||
</p>
|
||||
</FaqQuestionsCardBody>
|
||||
</CommonQuestionsCardView>
|
||||
|
||||
@ -70,7 +70,7 @@ export default function Sidebar({faqData}) {
|
||||
<PageTitle title='Perguntas Frequentes' subtitle='Perguntas Frequentes'/>
|
||||
|
||||
<div className='buttons'>
|
||||
<button className='btn2' onClick={handleOpen}>Adicionar</button>
|
||||
<button className='btn2' value="Refresh Page"onClick={handleOpen} >Adicionar</button>
|
||||
<button className='btn1' onClick={handleOpen}>Inativar</button>
|
||||
|
||||
</div>
|
||||
@ -95,6 +95,7 @@ export default function Sidebar({faqData}) {
|
||||
throw new Error('Function not implemented.');
|
||||
} } />
|
||||
<FaqButton2 title='Salvar' onClick={() => handleRegisterNewFaq(faq)}
|
||||
|
||||
/>
|
||||
</Box>
|
||||
|
||||
|
||||
@ -1,10 +1,15 @@
|
||||
import { GetServerSideProps } from 'next'
|
||||
import Head from 'next/head'
|
||||
import { parseCookies } from 'nookies'
|
||||
import React from 'react'
|
||||
import CommonQuestionsCard from '../components/faqQuestionsCard/FaqQuestionsCard'
|
||||
import Header from '../components/header/Header'
|
||||
import { api } from '../services/api'
|
||||
import getAPIClient from '../services/ssrApi'
|
||||
import { FaqView } from '../styles/layouts/commonQuestions/FaqView'
|
||||
|
||||
export default function commonQuestions() {
|
||||
|
||||
export default function commonQuestions({faqData}) {
|
||||
return (
|
||||
<FaqView>
|
||||
<Head>
|
||||
@ -14,17 +19,44 @@ export default function commonQuestions() {
|
||||
<h1>Perguntas Frequentes</h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
||||
<section className='CommonQuestionsSection' >
|
||||
<CommonQuestionsCard />
|
||||
<hr />
|
||||
<CommonQuestionsCard />
|
||||
<hr />
|
||||
<CommonQuestionsCard />
|
||||
<hr />
|
||||
<CommonQuestionsCard />
|
||||
<hr />
|
||||
<CommonQuestionsCard />
|
||||
<hr />
|
||||
{
|
||||
faqData.map((value, index ) => {
|
||||
return <>
|
||||
<CommonQuestionsCard key={index} question={value.question} answer={value.answer}/>
|
||||
<hr />
|
||||
</>
|
||||
})
|
||||
}
|
||||
</section>
|
||||
</FaqView>
|
||||
)
|
||||
}
|
||||
export const getServerSideProps: GetServerSideProps = async (ctx) => {
|
||||
const apiClient = getAPIClient(ctx)
|
||||
const { ['@smartAuth-token']: token } = parseCookies(ctx)
|
||||
console.log('teste')
|
||||
let faqData = [];
|
||||
|
||||
|
||||
await apiClient.get('/faq').then(res => {
|
||||
faqData = res.data
|
||||
}).catch(res => {
|
||||
console.log(res)
|
||||
})
|
||||
console.table(faqData);
|
||||
|
||||
if (!token) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: '/',
|
||||
permanent: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
faqData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user