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 TablePagination from '@mui/material/TablePagination';
|
||||||
import TableRow from '@mui/material/TableRow';
|
import TableRow from '@mui/material/TableRow';
|
||||||
import TableSortLabel from '@mui/material/TableSortLabel';
|
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 { visuallyHidden } from '@mui/utils';
|
||||||
import { GetServerSideProps } from 'next';
|
import { GetServerSideProps } from 'next';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
@ -194,7 +191,7 @@ export default function FaqTable({questionData}: any) {
|
|||||||
|
|
||||||
const handleSelectAllClick = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleSelectAllClick = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (event.target.checked) {
|
if (event.target.checked) {
|
||||||
const newSelecteds = questionData.map((n) => n.questionData);
|
const newSelecteds = questionData.map((n) => n.id);
|
||||||
setSelected(newSelecteds);
|
setSelected(newSelecteds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,26 @@
|
|||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
|
import getAPIClient from '../../services/ssrApi';
|
||||||
import { FaqQuestionsCardBody, FaqQuestionsCardHeader, CommonQuestionsCardView } from './FaqQuestionsCardView'
|
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)
|
const [ showCardBody, setShowCardBody ] = useState<boolean>(false)
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<CommonQuestionsCardView>
|
<CommonQuestionsCardView>
|
||||||
<FaqQuestionsCardHeader>
|
<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)} />
|
<Image src={showCardBody? '/assets/less-icon.svg' : '/assets/plus-icon.svg' } width={32} height={32} onClick={() => setShowCardBody(!showCardBody)} />
|
||||||
</FaqQuestionsCardHeader>
|
</FaqQuestionsCardHeader>
|
||||||
|
|
||||||
<FaqQuestionsCardBody showCardBody={showCardBody} >
|
<FaqQuestionsCardBody showCardBody={showCardBody} >
|
||||||
<p>
|
<p>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
{answer}
|
||||||
Consequat porta faucibus elementum pharetra varius
|
|
||||||
</p>
|
</p>
|
||||||
</FaqQuestionsCardBody>
|
</FaqQuestionsCardBody>
|
||||||
</CommonQuestionsCardView>
|
</CommonQuestionsCardView>
|
||||||
|
|||||||
@ -70,7 +70,7 @@ export default function Sidebar({faqData}) {
|
|||||||
<PageTitle title='Perguntas Frequentes' subtitle='Perguntas Frequentes'/>
|
<PageTitle title='Perguntas Frequentes' subtitle='Perguntas Frequentes'/>
|
||||||
|
|
||||||
<div className='buttons'>
|
<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>
|
<button className='btn1' onClick={handleOpen}>Inativar</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -95,6 +95,7 @@ export default function Sidebar({faqData}) {
|
|||||||
throw new Error('Function not implemented.');
|
throw new Error('Function not implemented.');
|
||||||
} } />
|
} } />
|
||||||
<FaqButton2 title='Salvar' onClick={() => handleRegisterNewFaq(faq)}
|
<FaqButton2 title='Salvar' onClick={() => handleRegisterNewFaq(faq)}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,15 @@
|
|||||||
|
import { GetServerSideProps } from 'next'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
|
import { parseCookies } from 'nookies'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import CommonQuestionsCard from '../components/faqQuestionsCard/FaqQuestionsCard'
|
import CommonQuestionsCard from '../components/faqQuestionsCard/FaqQuestionsCard'
|
||||||
import Header from '../components/header/Header'
|
import Header from '../components/header/Header'
|
||||||
|
import { api } from '../services/api'
|
||||||
|
import getAPIClient from '../services/ssrApi'
|
||||||
import { FaqView } from '../styles/layouts/commonQuestions/FaqView'
|
import { FaqView } from '../styles/layouts/commonQuestions/FaqView'
|
||||||
|
|
||||||
export default function commonQuestions() {
|
|
||||||
|
export default function commonQuestions({faqData}) {
|
||||||
return (
|
return (
|
||||||
<FaqView>
|
<FaqView>
|
||||||
<Head>
|
<Head>
|
||||||
@ -14,17 +19,44 @@ export default function commonQuestions() {
|
|||||||
<h1>Perguntas Frequentes</h1>
|
<h1>Perguntas Frequentes</h1>
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
||||||
<section className='CommonQuestionsSection' >
|
<section className='CommonQuestionsSection' >
|
||||||
<CommonQuestionsCard />
|
{
|
||||||
<hr />
|
faqData.map((value, index ) => {
|
||||||
<CommonQuestionsCard />
|
return <>
|
||||||
<hr />
|
<CommonQuestionsCard key={index} question={value.question} answer={value.answer}/>
|
||||||
<CommonQuestionsCard />
|
<hr />
|
||||||
<hr />
|
</>
|
||||||
<CommonQuestionsCard />
|
})
|
||||||
<hr />
|
}
|
||||||
<CommonQuestionsCard />
|
|
||||||
<hr />
|
|
||||||
</section>
|
</section>
|
||||||
</FaqView>
|
</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