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 Tooltip from '@mui/material/Tooltip';
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import { visuallyHidden } from '@mui/utils';
|
import { visuallyHidden } from '@mui/utils';
|
||||||
|
import { GetServerSideProps } from 'next';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import getAPIClient from '../../services/ssrApi';
|
||||||
|
|
||||||
import { ClientTableView, StyledStatus } from './ClientsTableView';
|
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 [order, setOrder] = useState<Order>('asc');
|
||||||
const [orderBy, setOrderBy] = useState<keyof Data | string>('status');
|
const [orderBy, setOrderBy] = useState<keyof Data | string>('status');
|
||||||
const [selected, setSelected] = useState<readonly string[]>([]);
|
const [selected, setSelected] = useState<readonly string[]>([]);
|
||||||
@ -179,6 +181,8 @@ export default function FaqTable() {
|
|||||||
const [dense, setDense] = useState<boolean>(false);
|
const [dense, setDense] = useState<boolean>(false);
|
||||||
const [rowsPerPage, setRowsPerPage] = useState<number>(5);
|
const [rowsPerPage, setRowsPerPage] = useState<number>(5);
|
||||||
|
|
||||||
|
console.table(questionData)
|
||||||
|
console.table(rows)
|
||||||
const handleRequestSort = (
|
const handleRequestSort = (
|
||||||
event: React.MouseEvent<unknown>,
|
event: React.MouseEvent<unknown>,
|
||||||
property: keyof Data,
|
property: keyof Data,
|
||||||
@ -190,7 +194,7 @@ export default function FaqTable() {
|
|||||||
|
|
||||||
const handleSelectAllClick = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleSelectAllClick = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (event.target.checked) {
|
if (event.target.checked) {
|
||||||
const newSelecteds = rows.map((n) => n.question);
|
const newSelecteds = questionData.map((n) => n.questionData);
|
||||||
setSelected(newSelecteds);
|
setSelected(newSelecteds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -247,23 +251,23 @@ export default function FaqTable() {
|
|||||||
orderBy={orderBy}
|
orderBy={orderBy}
|
||||||
onSelectAllClick={handleSelectAllClick}
|
onSelectAllClick={handleSelectAllClick}
|
||||||
onRequestSort={handleRequestSort}
|
onRequestSort={handleRequestSort}
|
||||||
rowCount={rows.length}
|
rowCount={questionData.length}
|
||||||
/>
|
/>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{stableSort(rows, getComparator(order, orderBy))
|
{stableSort(questionData, getComparator(order, orderBy))
|
||||||
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
||||||
.map((row, index) => {
|
.map((row, index) => {
|
||||||
const isItemSelected = isSelected(row.question);
|
const isItemSelected = isSelected(row.id);
|
||||||
const labelId = `enhanced-table-checkbox-${index}`;
|
const labelId = `enhanced-table-checkbox-${index}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
hover
|
hover
|
||||||
onClick={(event) => handleClick(event, row.question)}
|
onClick={(event) => handleClick(event, row.id)}
|
||||||
role="checkbox"
|
role="checkbox"
|
||||||
aria-checked={isItemSelected}
|
aria-checked={isItemSelected}
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
key={row.question}
|
key={row.id}
|
||||||
selected={isItemSelected}
|
selected={isItemSelected}
|
||||||
>
|
>
|
||||||
<TableCell padding="checkbox">
|
<TableCell padding="checkbox">
|
||||||
@ -284,7 +288,7 @@ export default function FaqTable() {
|
|||||||
{row.question}
|
{row.question}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="left">{row.answer}</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>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@ -313,3 +317,4 @@ export default function FaqTable() {
|
|||||||
</ClientTableView>
|
</ClientTableView>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import Image from 'next/image'
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
|
import { api } from '../../../services/api';
|
||||||
|
|
||||||
|
|
||||||
import FaqTable from '../../../components/administrativeTables/FaqTable';
|
import FaqTable from '../../../components/administrativeTables/FaqTable';
|
||||||
import BasicButton from '../../../components/buttons/basicButton/BasicButton';
|
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 Header from '../../../components/header/Header'
|
||||||
import PageTitle from '../../../components/pageTitle/PageTitle'
|
import PageTitle from '../../../components/pageTitle/PageTitle'
|
||||||
import { FaqView } from '../../../styles/layouts/commonQuestions/FaqView'
|
import { FaqView } from '../../../styles/layouts/commonQuestions/FaqView'
|
||||||
|
import getAPIClient from '../../../services/ssrApi';
|
||||||
|
import { GetServerSideProps } from 'next';
|
||||||
|
import { parseCookies } from 'nookies';
|
||||||
|
|
||||||
const style = {
|
const style = {
|
||||||
position: 'absolute' as const,
|
position: 'absolute' as const,
|
||||||
@ -31,7 +36,27 @@ const style = {
|
|||||||
p: 4,
|
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 [open, setOpen] = React.useState(false);
|
||||||
const handleOpen = () => setOpen(true);
|
const handleOpen = () => setOpen(true);
|
||||||
@ -61,21 +86,52 @@ export default function Sidebar() {
|
|||||||
Adicionar/Editar Pergunta
|
Adicionar/Editar Pergunta
|
||||||
</Typography>
|
</Typography>
|
||||||
<br />
|
<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 />
|
<br /><br />
|
||||||
<FaqButton1 title='Cancelar' onClick={function (): void {
|
<FaqButton1 title='Cancelar' onClick={function (): void {
|
||||||
throw new Error('Function not implemented.');
|
throw new Error('Function not implemented.');
|
||||||
} } />
|
} } />
|
||||||
<FaqButton2 title='Salvar' onClick={function (): void {
|
<FaqButton2 title='Salvar' onClick={() => handleRegisterNewFaq(faq)}
|
||||||
throw new Error('Function not implemented.');
|
/>
|
||||||
} } />
|
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
</Modal>
|
</Modal>
|
||||||
<FaqTable />
|
<FaqTable questionData={faqData}/>
|
||||||
|
|
||||||
</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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import FaqButton1 from '../../../components/buttons/faqButton/FaqButton1';
|
|||||||
import FaqButton2 from '../../../components/buttons/faqButton/FaqButton2';
|
import FaqButton2 from '../../../components/buttons/faqButton/FaqButton2';
|
||||||
import Header from '../../../components/header/Header'
|
import Header from '../../../components/header/Header'
|
||||||
import PageTitle from '../../../components/pageTitle/PageTitle'
|
import PageTitle from '../../../components/pageTitle/PageTitle'
|
||||||
import { api } from '../../../services/api';
|
import { api } from '../../../services/api';
|
||||||
import { FaqView } from '../../../styles/layouts/commonQuestions/FaqView'
|
import { FaqView } from '../../../styles/layouts/commonQuestions/FaqView'
|
||||||
|
|
||||||
import Radio from '@mui/material/Radio';
|
import Radio from '@mui/material/Radio';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user