-
Notifications
You must be signed in to change notification settings - Fork 3
feat: tourism api/tms #375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tsebaa0310
wants to merge
4
commits into
main
Choose a base branch
from
feat/tourism_api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import React, { lazy, Suspense } from 'react' | ||
| import { Navigate, Route, Routes } from 'react-router-dom' | ||
|
|
||
| const Tms = lazy(() => | ||
| import('~/pages/tms/IndexPage').then((module) => ({ | ||
| default: module.IndexPage, | ||
| })), | ||
| ); | ||
| const TmsPreview = lazy(() => | ||
| import('~/pages/tms/PreviewPage').then((module) => ({ | ||
| default: module.PreviewPage, | ||
| })), | ||
| ); | ||
| const Pms = lazy(() => | ||
| import('~/pages/pms/IndexPage').then((module) => ({ | ||
| default: module.IndexPage, | ||
| })), | ||
| ); | ||
|
|
||
| const App = () => { | ||
| return ( | ||
| <Suspense fallback={<div />}> | ||
| <Routes> | ||
| <Route path="/" element={<Navigate to="tms" replace />} /> | ||
| <Route path="/tms" element={<Tms />} /> | ||
| <Route path="/tms/PreviewPage" element={<TmsPreview />} /> | ||
| <Route path="/pms" element={<Pms />} /> | ||
| </Routes> | ||
| </Suspense> | ||
| ) | ||
| } | ||
|
|
||
| export default App |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
frontend/plugins/tourism_ui/src/modules/tms/atoms/formAtoms.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { atom } from 'jotai'; | ||
| import { atomWithStorage, RESET } from 'jotai/utils'; | ||
|
|
||
| type TmsFormStorage = TmsForm; | ||
|
|
||
| export type TmsForm = { | ||
| name: string; | ||
| color: string; | ||
| logo: string; | ||
| favIcon: string; | ||
| generalManager: string[]; | ||
| managers: string[]; | ||
| payment: string; | ||
| token: string; | ||
| otherPayments: Array<{ | ||
| type: string; | ||
| title: string; | ||
| icon: string; | ||
| config?: string; | ||
| }>; | ||
| }; | ||
|
|
||
| const DEFAULT_STORAGE_FORM: TmsFormStorage = { | ||
| name: '', | ||
| color: '#4F46E5', | ||
| logo: '', | ||
| favIcon: '', | ||
| generalManager: [], | ||
| managers: [], | ||
| payment: '', | ||
| token: '', | ||
| otherPayments: [], | ||
| }; | ||
|
|
||
| export const DEFAULT_TMS_FORM: TmsForm = { | ||
| name: '', | ||
| color: '#4F46E5', | ||
| logo: '', | ||
| favIcon: '', | ||
| generalManager: [], | ||
| managers: [], | ||
| payment: '', | ||
| token: '', | ||
| otherPayments: [], | ||
| }; | ||
|
|
||
| const tmsFormStorageAtom = atomWithStorage<TmsFormStorage>( | ||
| 'tms_form_data', | ||
| DEFAULT_STORAGE_FORM, | ||
| ); | ||
|
|
||
| export const tmsFormAtom = atom( | ||
| (get) => { | ||
| const storage = get(tmsFormStorageAtom); | ||
| return { | ||
| ...DEFAULT_TMS_FORM, | ||
| ...storage, | ||
| }; | ||
| }, | ||
| (get, set, update: TmsForm) => { | ||
| const prev = get(tmsFormStorageAtom); | ||
| set(tmsFormStorageAtom, { | ||
| ...prev, | ||
| ...update, | ||
| }); | ||
| }, | ||
| ); | ||
|
|
||
| export const resetFormAtom = atom(null, (get, set) => { | ||
| set(tmsFormStorageAtom, RESET); | ||
| }); |
89 changes: 89 additions & 0 deletions
89
frontend/plugins/tourism_ui/src/modules/tms/components/ActionMenu.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { | ||
| IconEdit, | ||
| IconCopy, | ||
| IconTrash, | ||
| IconChevronDown, | ||
| } from '@tabler/icons-react'; | ||
| import { Popover, Spinner } from 'erxes-ui'; | ||
|
|
||
| interface ActionMenuProps { | ||
| onEdit: () => void; | ||
| onDuplicate: () => void; | ||
| onDelete: () => void; | ||
| duplicateLoading: boolean; | ||
| } | ||
|
|
||
| export const ActionMenu = ({ | ||
| onEdit, | ||
| onDuplicate, | ||
| onDelete, | ||
| duplicateLoading, | ||
| }: ActionMenuProps) => { | ||
| const dropdownItems = [ | ||
| { | ||
| label: 'Edit', | ||
| icon: <IconEdit size={16} stroke={1.5} />, | ||
| onClick: () => onEdit(), | ||
| }, | ||
| { | ||
| label: duplicateLoading ? 'Duplicating…' : 'Duplicate', | ||
| icon: duplicateLoading ? ( | ||
| <Spinner className="w-4 h-4" /> | ||
| ) : ( | ||
| <IconCopy className="size-4" /> | ||
| ), | ||
| onClick: () => onDuplicate(), | ||
| disabled: duplicateLoading, | ||
| }, | ||
| // { | ||
| // label: 'Visit website', | ||
| // icon: <IconWorld size={16} stroke={1.5} />, | ||
| // onClick: () => window.open(branch.website, '_blank'), | ||
| // }, | ||
| { | ||
| label: 'Delete', | ||
| icon: <IconTrash size={16} stroke={1.5} />, | ||
| onClick: () => onDelete(), | ||
| }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <Popover> | ||
| <Popover.Trigger asChild> | ||
| <button | ||
| className="flex items-center leading-[100%] text-foreground font-inter gap-1 text-sm font-medium rounded-md p-1 hover:bg-muted focus:outline-none" | ||
| aria-label="Open action menu" | ||
| aria-haspopup="true" | ||
| role="menuitem" | ||
| > | ||
| Action | ||
| <IconChevronDown size={18} stroke={2} /> | ||
| </button> | ||
| </Popover.Trigger> | ||
| <Popover.Content | ||
| className="p-1 w-48 rounded-lg border shadow-lg bg-background" | ||
| side="bottom" | ||
| align="end" | ||
| > | ||
| {dropdownItems.map((item) => ( | ||
| <div | ||
| key={item.label} | ||
| className={`flex gap-3 items-center px-4 py-2 w-full text-left rounded-md cursor-pointer hover:bg-muted ${ | ||
| (item as any).disabled ? 'opacity-60 pointer-events-none' : '' | ||
| }`} | ||
| aria-disabled={(item as any).disabled ? true : undefined} | ||
| onClick={(e) => { | ||
| if ((item as any).disabled) return; | ||
| item.onClick(); | ||
| }} | ||
| > | ||
| {item.icon} | ||
| <p className="text-sm font-medium leading-[100%] font-inter"> | ||
| {item.label} | ||
| </p> | ||
| </div> | ||
| ))} | ||
| </Popover.Content> | ||
| </Popover> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each item in the dropdown map should have a unique key prop to avoid React key warnings.