diff --git a/package.json b/package.json index fd9e885..678a767 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/librarian-org/librarian/issues" }, "productName": "librarian", - "version": "1.0.0", + "version": "1.0.0-alpha", "description": "The Librarian app is ideal for schools libraries and for someone who have many books.", "main": ".webpack/main", "scripts": { diff --git a/src/app/components/Person/Create/index.tsx b/src/app/components/Person/Create/index.tsx index a26443f..e8af353 100644 --- a/src/app/components/Person/Create/index.tsx +++ b/src/app/components/Person/Create/index.tsx @@ -258,6 +258,13 @@ const CreatePerson: React.FC = () => { }, }) as Person; + addToast({ + title: i18n.t('notifications.success'), + type: 'success', + description: i18n + .t('person.successSave'), + }); + trigger(AppEvent.personTab, { action: Actions.read, value: insertedPerson, diff --git a/src/app/components/Person/Update/index.tsx b/src/app/components/Person/Update/index.tsx index 20a2fcd..849e26a 100644 --- a/src/app/components/Person/Update/index.tsx +++ b/src/app/components/Person/Update/index.tsx @@ -318,6 +318,14 @@ const PersonUpdate: React.FC<{ item: Person }> = ({ item }) => { }, }, }) as Person; + + addToast({ + title: i18n.t('notifications.success'), + type: 'success', + description: i18n + .t('person.successSave'), + }); + trigger(AppEvent.personTab, { action: Actions.read, value: insertedPerson, diff --git a/src/app/components/Tabs/index.tsx b/src/app/components/Tabs/index.tsx index dc60ee4..96b0135 100644 --- a/src/app/components/Tabs/index.tsx +++ b/src/app/components/Tabs/index.tsx @@ -29,9 +29,9 @@ interface Event { const Tabs: React.FC = () => { const [tabItems, setTabItems] = useState([]); const [activeTab, setActiveTab] = useState(null); + const [selectedTab, setSelectedTab] = useState(null); const [isOpen, setOpen] = useState(false); - const [action, setAction] = useState('list'); - // const [item, setItem] = useState(undefined); + const [, setAction] = useState('list'); const lastTab = useCallback((): Tab => { return tabItems[tabItems.length - 1]; @@ -79,11 +79,11 @@ const Tabs: React.FC = () => { const tabAlreadyOpened = tabItems.filter((t) => t.type === type); if (tabAlreadyOpened.length > 0) { - setAction(action); tabAlreadyOpened[0].action = action; tabAlreadyOpened[0].item = item; + setAction(action); setTabItems(tabItems); - setActiveTab(tabAlreadyOpened[0]); + setSelectedTab(tabAlreadyOpened[0]); return; } @@ -92,7 +92,7 @@ const Tabs: React.FC = () => { type: type, title: `${type}.label`, action: action, - item: undefined + item: undefined, }; addTab(tab); @@ -123,20 +123,29 @@ const Tabs: React.FC = () => { } }, [activeTab, close]); - const borrowTab = useCallback((params: CustomEvent) => { - const { action, value } = params.detail; - handleCreateTab('borrow', action, value); - }, [handleCreateTab]); + const borrowTab = useCallback( + (params: CustomEvent) => { + const { action, value } = params.detail; + handleCreateTab('borrow', action, value); + }, + [handleCreateTab] + ); - const personTab = useCallback((params: CustomEvent) => { - const { action, value } = params.detail; - handleCreateTab('person', action, value); - }, [handleCreateTab]); + const personTab = useCallback( + (params: CustomEvent) => { + const { action, value } = params.detail; + handleCreateTab('person', action, value); + }, + [handleCreateTab] + ); - const titleTab = useCallback((params: CustomEvent) => { - const { action, value } = params.detail; - handleCreateTab('title', action, value); - }, [handleCreateTab]); + const titleTab = useCallback( + (params: CustomEvent) => { + const { action, value } = params.detail; + handleCreateTab('title', action, value); + }, + [handleCreateTab] + ); const settingsTab = useCallback(() => { handleCreateTab('settings', Actions.update, {}); @@ -185,6 +194,10 @@ const Tabs: React.FC = () => { [tabItems] ); + useEffect(()=>{ + setActiveTab(selectedTab); + }, [selectedTab]); + const rendererTabs = (tab: Tab, index: number, isActive: boolean) => { return ( { key={`tab-content-${tab.id}`} > {tab.type === 'borrow' && } - {tab.type === 'person' && } - {tab.type === 'title' && } + {tab.type === 'person' && ( + <Person action={tab.action} item={tab.item} /> + )} + {tab.type === 'title' && ( + <Title action={tab.action} item={tab.item} /> + )} {tab.type === 'settings' && <Settings />} </TabContent> ) diff --git a/src/app/components/Title/Create/index.tsx b/src/app/components/Title/Create/index.tsx index f565945..34458f4 100644 --- a/src/app/components/Title/Create/index.tsx +++ b/src/app/components/Title/Create/index.tsx @@ -252,6 +252,13 @@ const TitleCreate: React.FC = () => { }, }) as Title; + addToast({ + title: i18n.t('notifications.success'), + type: 'success', + description: i18n + .t('title.successSave'), + }); + trigger(AppEvent.titleTab, { action: Actions.read, value: insertedTitle }); }, [addToast, authors, categories, isbn, publishers, title]); diff --git a/src/app/components/Title/Update/index.tsx b/src/app/components/Title/Update/index.tsx index 0cb7041..b505984 100644 --- a/src/app/components/Title/Update/index.tsx +++ b/src/app/components/Title/Update/index.tsx @@ -299,6 +299,13 @@ const TitleUpdate: React.FC<{ item: Title }> = ({ item }) => { }, }) as Title; + addToast({ + title: i18n.t('notifications.success'), + type: 'success', + description: i18n + .t('title.successSave'), + }); + trigger(AppEvent.titleTab, { action: Actions.read, value: updatedTitle }); }, [addToast, authors, categories, isbn, item, publishers, title]); diff --git a/src/locales/en-US/common.json b/src/locales/en-US/common.json index 798821a..481053a 100644 --- a/src/locales/en-US/common.json +++ b/src/locales/en-US/common.json @@ -113,7 +113,8 @@ "edit": "Edit", - "invalidISBN": "Invalid ISBN" + "invalidISBN": "Invalid ISBN", + "successSave": "Title saved successfully " }, "settings": { "label": "Settings", @@ -230,7 +231,8 @@ "informError": "Please provide information to create person: #errors#", "informErrorsContact": "Please provide information to a contact: #errors#", "informErrorsAddress": "Please profive information to a address: #errors#", - "hasBeenAdd": "This contact already been added" + "hasBeenAdd": "This contact already been added", + "successSave": "Person saved successfully" }, "address":{ "number": "Number", diff --git a/src/locales/pt-BR/common.json b/src/locales/pt-BR/common.json index d1e4edb..bab097d 100644 --- a/src/locales/pt-BR/common.json +++ b/src/locales/pt-BR/common.json @@ -115,7 +115,8 @@ "edit": "Editar", - "invalidISBN": "ISBN inválido" + "invalidISBN": "ISBN inválido", + "successSave": "Título salvo com sucesso" }, "settings": { "label": "Configurações", @@ -232,7 +233,8 @@ "informError": "Por favor forneça as informações para criar a pessoa: #errors#", "informErrorsContact": "Por favor forneça informação do contato: #errors#", "informErrorsAddress": "Por favor forneça informação de endereço: #errors#", - "hasBeenAdd": "Este contato já foi adicionado" + "hasBeenAdd": "Este contato já foi adicionado", + "successSave": "Registro da Pessoa salvo com sucesso" }, "address":{ "zipcode": "CEP",