Skip to content

Commit

Permalink
Refactor imports in action-table.tsx and remove-configs.modal.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmesh-hemaram committed Oct 4, 2024
1 parent ee09fd7 commit aeb7fc0
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useConfirmationModalContext } from '@apps/acf-options-page/src/_providers/confirm.provider';
import { useAppDispatch, useAppSelector } from '@apps/acf-options-page/src/hooks';
import { actionSelector, addAction, openActionAddonModalAPI, openActionSettingsModalAPI, openActionStatementModalAPI, removeAction, updateAction } from '@apps/acf-options-page/src/store/config';
import { Action, RANDOM_UUID } from '@dhruv-techapps/acf-common';
import { Action } from '@dhruv-techapps/acf-common';
import { RANDOM_UUID } from '@dhruv-techapps/core-common';
import { ColumnDef, Row, flexRender, getCoreRowModel, getFilteredRowModel, useReactTable } from '@tanstack/react-table';
import { useMemo } from 'react';
import { Button, Dropdown, Form, Table } from 'react-bootstrap';
Expand Down
2 changes: 1 addition & 1 deletion apps/acf-options-page/src/modal/remove-configs.modal.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { RANDOM_UUID } from '@dhruv-techapps/core-common';
import { ChangeEvent, FormEvent } from 'react';
import { Badge, Button, Form, ListGroup, Modal } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { ErrorAlert } from '../components';
import { useAppDispatch, useAppSelector } from '../hooks';
import { configRemoveSelector, configRemoveUpdateAPI, switchConfigRemoveModal, switchConfigRemoveSelection } from '../store/config';
import { RANDOM_UUID } from '@dhruv-techapps/acf-common';

const RemoveConfigsModal = () => {
const { visible, configs, error } = useAppSelector(configRemoveSelector);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RANDOM_UUID, getDefaultAction } from '@dhruv-techapps/acf-common';
import { getDefaultAction } from '@dhruv-techapps/acf-common';
import { RANDOM_UUID } from '@dhruv-techapps/core-common';
import { PayloadAction } from '@reduxjs/toolkit';
import { ConfigStore } from '../config.slice';
import { actionAddonActions } from './addon';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Addon } from '@dhruv-techapps/acf-common';
import { RANDOM_UUID } from '@dhruv-techapps/core-common';
import { createAsyncThunk } from '@reduxjs/toolkit';
import { RootState } from '../../../../store';
import { Addon, RANDOM_UUID } from '@dhruv-techapps/acf-common';

export const openActionAddonModalAPI = createAsyncThunk<{ addon: Addon | undefined; selectedActionId: RANDOM_UUID }, RANDOM_UUID, { state: RootState }>(
'action-addon/open',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ActionSettings } from '@dhruv-techapps/acf-common';
import { RANDOM_UUID } from '@dhruv-techapps/core-common';
import { createAsyncThunk } from '@reduxjs/toolkit';
import { RootState } from '../../../../store';
import { ActionSettings, RANDOM_UUID } from '@dhruv-techapps/acf-common';

export const openActionSettingsModalAPI = createAsyncThunk<{ settings: ActionSettings | undefined; selectedActionId: RANDOM_UUID }, RANDOM_UUID, { state: RootState }>(
'action-setting/open',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ActionStatement } from '@dhruv-techapps/acf-common';
import { RANDOM_UUID } from '@dhruv-techapps/core-common';
import { createAsyncThunk } from '@reduxjs/toolkit';
import { RootState } from '../../../../store';
import { ActionStatement, RANDOM_UUID } from '@dhruv-techapps/acf-common';

export const openActionStatementModalAPI = createAsyncThunk<{ statement: ActionStatement | undefined; selectedActionId: RANDOM_UUID }, RANDOM_UUID, { state: RootState }>(
'action-statement/open',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ACTION_RUNNING, ActionCondition, ActionStatement, getDefaultActionStatement } from '@dhruv-techapps/acf-common';
import { RANDOM_UUID } from '@dhruv-techapps/core-common';
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
import { RootState } from '../../../../store';
import { ACTION_RUNNING, ActionCondition, ActionStatement, RANDOM_UUID, getDefaultActionStatement } from '@dhruv-techapps/acf-common';
import { openActionStatementModalAPI } from './statement.api';

type ActionStatementStore = {
Expand Down
3 changes: 2 additions & 1 deletion apps/acf-options-page/src/store/config/config.slice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CONFIG_SOURCE, Configuration, RANDOM_UUID, START_TYPES, getDefaultConfig } from '@dhruv-techapps/acf-common';
import { CONFIG_SOURCE, Configuration, START_TYPES, getDefaultConfig } from '@dhruv-techapps/acf-common';
import { RANDOM_UUID } from '@dhruv-techapps/core-common';
import { PayloadAction, createSelector, createSlice } from '@reduxjs/toolkit';
import { LocalStorage } from '../../_helpers';
import { RootState } from '../../store';
Expand Down
3 changes: 2 additions & 1 deletion apps/acf-options-page/src/store/config/config.slice.util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Action, CONFIG_SOURCE, Configuration, RANDOM_UUID, getDefaultAction, getDefaultConfig } from '@dhruv-techapps/acf-common';
import { Action, CONFIG_SOURCE, Configuration, getDefaultAction, getDefaultConfig } from '@dhruv-techapps/acf-common';
import { RANDOM_UUID } from '@dhruv-techapps/core-common';
import { blogCheckAPI } from '../blog';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Configuration } from '@dhruv-techapps/acf-common';
import { RANDOM_UUID } from '@dhruv-techapps/core-common';
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
import { RootState } from '../../../store';
import { Configuration, RANDOM_UUID } from '@dhruv-techapps/acf-common';
import { configRemoveUpdateAPI } from './config-remove.api';

export type ConfigurationRemoveType = Configuration & { checked?: boolean };
Expand Down
15 changes: 7 additions & 8 deletions libs/core/common/src/lib/utilities/random.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ export type RANDOM_UUID = `${string}-${string}-${string}-${string}-${string}`;

export const generateUUID = (): RANDOM_UUID => {
// Generate a random UUID (version 4)
return (
crypto.randomUUID() ||
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
})
);
return crypto.randomUUID
? crypto.randomUUID()
: ('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
}) as RANDOM_UUID);
};

0 comments on commit aeb7fc0

Please sign in to comment.