brilliant-orangeB
Refine2y ago
41 replies
brilliant-orange

How can I refresh data periodically?

   <Grid item xs={24} lg={12}>
        <List
          headerButtons={<ExportButton onClick={triggerExport} loading={exportLoading} />}
          title={'적립금 지급 내역'}
          wrapperProps={{ sx: { paddingX: { xs: 2, md: 0 } } }}
        >
          <Typography variant="body1" align="right">
            * 주문건에 대한 상세 내용이나, 클레임 처리, 구독신청 내역 확인 등은 기존 카페24 관리자 페이지에서 진행해
            주세요.
          </Typography>
          {open && <PointsDetail open={open} onClose={handleClose} pointDetail={pointDetail} />}
          <DataGrid
            {...dataGridProps}
            columns={columns}
            filterModel={undefined}
            autoHeight
            pageSizeOptions={[10, 20, 50, 100]}
            rowHeight={80}
            sx={{
              ...dataGridProps.sx,
              '& .MuiDataGrid-row': {
                cursor: 'pointer',
              },
            }}
          />
        </List>
      </Grid>
    </Grid>
  )
}

export const getServerSideProps: GetServerSideProps<{}> = async (context) => {
  const { authenticated, redirectTo } = await authProvider.check(context)
  const translateProps = await serverSideTranslations(context.locale ?? 'ko', ['common'])

  const pointResponse = await fetch(`${process.env.NEXT_PUBLIC_PUBLIC_IP}/points`, {
    headers: {
      'Content-Type': 'application/json',
    },
  })

  const points = await pointResponse.json() 

  if (!authenticated) {
    return {
      props: {},
      redirect: {
        destination: redirectTo,
        permanent: false,
      },
    }
  }
  console.log(points)
  return {
    props: {
      points,
      ...translateProps,
    },
  }
}
Was this page helpful?