fix pull conflicts
This commit is contained in:
commit
481b78ea41
@ -19,7 +19,9 @@ 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';
|
||||
import getAPIClient from '../../services/ssrApi';
|
||||
|
||||
import { ClientTableView, StyledStatus } from './ClientsTableView';
|
||||
|
||||
@ -171,7 +173,7 @@ function EnhancedTableHead(props: EnhancedTableProps) {
|
||||
);
|
||||
}
|
||||
|
||||
export default function FaqTable() {
|
||||
export default function FaqTable({questionData}: any) {
|
||||
const [order, setOrder] = useState<Order>('asc');
|
||||
const [orderBy, setOrderBy] = useState<keyof Data | string>('status');
|
||||
const [selected, setSelected] = useState<readonly string[]>([]);
|
||||
@ -179,6 +181,8 @@ export default function FaqTable() {
|
||||
const [dense, setDense] = useState<boolean>(false);
|
||||
const [rowsPerPage, setRowsPerPage] = useState<number>(5);
|
||||
|
||||
console.table(questionData)
|
||||
console.table(rows)
|
||||
const handleRequestSort = (
|
||||
event: React.MouseEvent<unknown>,
|
||||
property: keyof Data,
|
||||
@ -190,7 +194,7 @@ export default function FaqTable() {
|
||||
|
||||
const handleSelectAllClick = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (event.target.checked) {
|
||||
const newSelecteds = rows.map((n) => n.question);
|
||||
const newSelecteds = questionData.map((n) => n.questionData);
|
||||
setSelected(newSelecteds);
|
||||
return;
|
||||
}
|
||||
@ -247,23 +251,23 @@ export default function FaqTable() {
|
||||
orderBy={orderBy}
|
||||
onSelectAllClick={handleSelectAllClick}
|
||||
onRequestSort={handleRequestSort}
|
||||
rowCount={rows.length}
|
||||
rowCount={questionData.length}
|
||||
/>
|
||||
<TableBody>
|
||||
{stableSort(rows, getComparator(order, orderBy))
|
||||
{stableSort(questionData, getComparator(order, orderBy))
|
||||
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
||||
.map((row, index) => {
|
||||
const isItemSelected = isSelected(row.question);
|
||||
const isItemSelected = isSelected(row.id);
|
||||
const labelId = `enhanced-table-checkbox-${index}`;
|
||||
|
||||
return (
|
||||
<TableRow
|
||||
hover
|
||||
onClick={(event) => handleClick(event, row.question)}
|
||||
onClick={(event) => handleClick(event, row.id)}
|
||||
role="checkbox"
|
||||
aria-checked={isItemSelected}
|
||||
tabIndex={-1}
|
||||
key={row.question}
|
||||
key={row.id}
|
||||
selected={isItemSelected}
|
||||
>
|
||||
<TableCell padding="checkbox">
|
||||
@ -284,7 +288,7 @@ export default function FaqTable() {
|
||||
{row.question}
|
||||
</TableCell>
|
||||
<TableCell align="left">{row.answer}</TableCell>
|
||||
<TableCell align="left"><StyledStatus status={row.status}>{row.status}</StyledStatus></TableCell>
|
||||
<TableCell align="left"><StyledStatus status={row.deleted_at? 'ativo' : 'inativo'}> {row.deleted_at? 'ativo' : 'inativo'}</StyledStatus></TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
@ -313,3 +317,4 @@ export default function FaqTable() {
|
||||
</ClientTableView>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,8 @@ import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { api } from '../../../services/api';
|
||||
|
||||
|
||||
import FaqTable from '../../../components/administrativeTables/FaqTable';
|
||||
import BasicButton from '../../../components/buttons/basicButton/BasicButton';
|
||||
@ -17,6 +19,9 @@ import FaqButton2 from '../../../components/buttons/faqButton/FaqButton2';
|
||||
import Header from '../../../components/header/Header'
|
||||
import PageTitle from '../../../components/pageTitle/PageTitle'
|
||||
import { FaqView } from '../../../styles/layouts/commonQuestions/FaqView'
|
||||
import getAPIClient from '../../../services/ssrApi';
|
||||
import { GetServerSideProps } from 'next';
|
||||
import { parseCookies } from 'nookies';
|
||||
|
||||
const style = {
|
||||
position: 'absolute' as const,
|
||||
@ -31,7 +36,27 @@ const style = {
|
||||
p: 4,
|
||||
};
|
||||
|
||||
export default function Sidebar() {
|
||||
type FaqInterface = {
|
||||
question: string;
|
||||
answer: string;
|
||||
|
||||
}
|
||||
|
||||
|
||||
export default function Sidebar({faqData}) {
|
||||
async function handleRegisterNewFaq({question, answer}: FaqInterface) {
|
||||
await api.post('/faq', {
|
||||
"question": question,
|
||||
"answer": answer,
|
||||
|
||||
}).then(res => console.log(res.data))
|
||||
}
|
||||
|
||||
const [faq, setFaq] = useState<FaqInterface>({
|
||||
question: '',
|
||||
answer: '',
|
||||
})
|
||||
|
||||
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const handleOpen = () => setOpen(true);
|
||||
@ -61,21 +86,52 @@ export default function Sidebar() {
|
||||
Adicionar/Editar Pergunta
|
||||
</Typography>
|
||||
<br />
|
||||
<TextField id="outlined-basic" label="Pergunta" sx={{width:710, ml:8}} variant="outlined" /> <br /><br />
|
||||
<TextField id="outlined-basic" label="Resposta" sx={{width:710, ml:8}} variant="outlined" />
|
||||
|
||||
<TextField id="outlined-basic" label="Pergunta" onChange={value=>setFaq({...faq, question:value.target.value})} sx={{width:710, ml:8}} variant="outlined" /> <br /><br />
|
||||
<TextField id="outlined-basic" label="Resposta" onChange={value=>setFaq({...faq, answer:value.target.value})} sx={{width:710, ml:8}} variant="outlined" />
|
||||
|
||||
<br /><br />
|
||||
<FaqButton1 title='Cancelar' onClick={function (): void {
|
||||
throw new Error('Function not implemented.');
|
||||
} } />
|
||||
<FaqButton2 title='Salvar' onClick={function (): void {
|
||||
throw new Error('Function not implemented.');
|
||||
} } />
|
||||
<FaqButton2 title='Salvar' onClick={() => handleRegisterNewFaq(faq)}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
</Modal>
|
||||
<FaqTable />
|
||||
<FaqTable questionData={faqData}/>
|
||||
|
||||
</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