Skip to content

Commit

Permalink
refactor(table): update table props description on storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
anuradha9712 authored and satyamyadav committed Dec 10, 2024
1 parent 396537a commit f041f10
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions core/components/organisms/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ interface AsyncProps {
* searchTerm?: string;
* }
* </pre>
*
* <pre className="DocPage-codeBlock">
* fetchData returns a promise which
* - resolves with data, schema, count and searchTerm
* - rejects with error: true, errorType: 'FAILED\_TO\_FETCH'
* - resolves with no records found, error: true, errorType: 'NO\_RECORDS\_FOUND'
* </pre>
*/
fetchData?: fetchDataFunction;
}
Expand Down Expand Up @@ -297,6 +304,22 @@ interface SharedTableProps extends BaseProps {
* errorType: TableProps['errorType']
* }
* </pre>
*
* Default errorTemplate:
*
* <pre class="DocPage-codeBlock mx-6 mb-7">
* (props) => {
* const { errorType = 'DEFAULT' } = props;
* const errorMessages = {
* 'FAILED\_TO\_FETCH': 'Failed to fetch data',
* 'NO\_RECORDS\_FOUND': 'No results found',
* 'DEFAULT': 'No results found'
* }
* return(
* \<Heading>{errorMessages[errorType]}\</Heading>
* );
* }
* </pre>
*/
errorTemplate?: React.FunctionComponent<ErrorTemplateProps>;
/**
Expand Down Expand Up @@ -406,33 +429,6 @@ export const defaultProps = {
errorTemplate: defaultErrorTemplate,
};

/**
* ###Note:
* 1. Sync Table:
* - Manually toggle loading/error state to update data, schema.
* 2. Async Table:
* - fetchData return:
* - Promise resolve with no records:
* error: true, errorType: 'NO\_RECORDS\_FOUND'
* - Promise reject:
* error: true, errorType: 'FAILED\_TO\_FETCH'
* 3. Default errorTemplate:
*
* <pre class="DocPage-codeBlock mx-6 mb-7">
* (props) => {
* const { errorType = 'DEFAULT' } = props;
* const errorMessages = {
* 'FAILED\_TO\_FETCH': 'Failed to fetch data',
* 'NO\_RECORDS\_FOUND': 'No results found',
* 'DEFAULT': 'No results found'
* }
* return(
* \<Heading>{errorMessages[errorType]}\</Heading>
* );
* }
* </pre>
*/

export class Table extends React.Component<TableProps, TableState> {
static defaultProps = defaultProps;
debounceUpdate: () => void;
Expand Down

0 comments on commit f041f10

Please sign in to comment.