Merge pull request #1875 from RafaelTaranto/fix/customer-page-fixes

LAM-1442 fix: reload table when customer added
This commit is contained in:
Rafael Taranto 2025-06-05 10:16:40 +01:00 committed by GitHub
commit 305cbea6c9
2 changed files with 7 additions and 14 deletions

View file

@ -86,23 +86,14 @@ const Customers = () => {
const handleCustomerClicked = customer =>
navigate(`/compliance/customer/${customer.id}`)
const [customers, setCustomers] = useState([])
const [showCreationModal, setShowCreationModal] = useState(false)
const { data: customersResponse, loading: customerLoading } = useQuery(
GET_CUSTOMERS,
{
onCompleted: data => setCustomers(R.path(['customers'])(data)),
},
)
const { data: customersResponse, loading: customersLoading } =
useQuery(GET_CUSTOMERS)
const [createNewCustomer] = useMutation(CREATE_CUSTOMER, {
onCompleted: () => setShowCreationModal(false),
refetchQueries: () => [
{
query: GET_CUSTOMERS,
},
],
refetchQueries: () => [GET_CUSTOMERS],
})
const configData = R.path(['config'])(customersResponse) ?? []
@ -120,6 +111,8 @@ const Customers = () => {
const byAuthorized = c => (c.authorizedStatus.label === 'Pending' ? 0 : 1)
const byLastActive = c => new Date(R.prop('lastActive', c) ?? '0')
const customers = R.path(['customers'])(customersResponse)
const customersData = R.pipe(
R.map(setAuthorizedStatus),
R.sortWith([R.ascend(byAuthorized), R.descend(byLastActive)]),
@ -145,7 +138,7 @@ const Customers = () => {
data={customersData}
country={locale?.country}
onClick={handleCustomerClicked}
loading={customerLoading}
loading={customersLoading}
/>
<CreateCustomerModal
showModal={showCreationModal}

View file

@ -109,7 +109,7 @@ const CustomersList = ({ data, country, onClick, loading }) => {
const table = useMaterialReactTable({
...defaultMaterialTableOpts,
columns: columns,
columns,
data,
initialState: {
...defaultMaterialTableOpts.initialState,