@hedhog/admin 0.51.2 → 0.51.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth.controller.d.ts +4 -0
- package/dist/auth/auth.controller.d.ts.map +1 -1
- package/dist/auth/auth.controller.js +18 -0
- package/dist/auth/auth.controller.js.map +1 -1
- package/dist/auth/auth.service.d.ts +4 -0
- package/dist/auth/auth.service.d.ts.map +1 -1
- package/dist/auth/auth.service.js +22 -0
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/auth/dto/register.dto.d.ts +8 -0
- package/dist/auth/dto/register.dto.d.ts.map +1 -0
- package/dist/auth/dto/register.dto.js +47 -0
- package/dist/auth/dto/register.dto.js.map +1 -0
- package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +11 -11
- package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +11 -11
- package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +3 -3
- package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +3 -3
- package/dist/menu/menu.controller.d.ts +3 -3
- package/dist/menu/menu.service.d.ts +3 -3
- package/dist/screen/screen.service.js +1 -1
- package/dist/screen/screen.service.js.map +1 -1
- package/dist/setting/setting.service.js +1 -1
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/user/user.controller.d.ts +10 -0
- package/dist/user/user.controller.d.ts.map +1 -1
- package/dist/user/user.controller.js +10 -0
- package/dist/user/user.controller.js.map +1 -1
- package/dist/user/user.service.d.ts +10 -0
- package/dist/user/user.service.d.ts.map +1 -1
- package/dist/user/user.service.js +7 -0
- package/dist/user/user.service.js.map +1 -1
- package/frontend/dashboard/components/create-panel.tsx.ejs +63 -63
- package/frontend/dashboard/components/dashboard.screen.tsx.ejs +116 -116
- package/frontend/dashboard/components/update-panel.tsx.ejs +80 -80
- package/frontend/dashboard/locales/en/dashboard.dashboard.json +11 -11
- package/frontend/dashboard/locales/pt/dashboard.dashboard.json +11 -11
- package/frontend/dashboard/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard/react-query/requests.ts.ejs +56 -56
- package/frontend/dashboard-component/components/create-panel.tsx.ejs +130 -130
- package/frontend/dashboard-component/components/update-panel.tsx.ejs +164 -164
- package/frontend/dashboard-component/locales/en/dashboard.dashboard-component.json +11 -11
- package/frontend/dashboard-component/locales/pt/dashboard.dashboard-component.json +11 -11
- package/frontend/dashboard-component/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard-component/react-query/requests.ts.ejs +61 -61
- package/frontend/dashboard-item/components/create-panel.tsx.ejs +108 -108
- package/frontend/dashboard-item/components/update-panel.tsx.ejs +141 -141
- package/frontend/dashboard-item/locales/en/dashboard.dashboard-item.json +11 -11
- package/frontend/dashboard-item/locales/pt/dashboard.dashboard-item.json +11 -11
- package/frontend/dashboard-item/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard-item/react-query/requests.ts.ejs +58 -58
- package/frontend/dashboard-user/components/create-panel.tsx.ejs +108 -108
- package/frontend/dashboard-user/components/update-panel.tsx.ejs +137 -137
- package/frontend/dashboard-user/locales/en/dashboard.dashboard-user.json +11 -11
- package/frontend/dashboard-user/locales/pt/dashboard.dashboard-user.json +11 -11
- package/frontend/dashboard-user/react-query/handlers.ts.ejs +28 -28
- package/frontend/dashboard-user/react-query/requests.ts.ejs +58 -58
- package/hedhog.yaml +60 -0
- package/package.json +1 -1
- package/src/auth/auth.controller.ts +15 -0
- package/src/auth/auth.service.ts +28 -0
- package/src/auth/dto/register.dto.ts +38 -0
- package/src/dashboard/dashboard-component/dashboard-component.controller.ts +55 -55
- package/src/dashboard/dashboard-component/dto/create.dto.ts +36 -36
- package/src/dashboard/dashboard-component/dto/update.dto.ts +4 -4
- package/src/dashboard/dashboard-item/dto/update.dto.ts +4 -4
- package/src/dashboard/dashboard-user/dto/update.dto.ts +4 -4
- package/src/dashboard/index.ts +1 -1
- package/src/screen/screen.service.ts +2 -2
- package/src/setting/setting.service.ts +2 -2
- package/src/user/user.controller.ts +5 -0
- package/src/user/user.service.ts +9 -1
@@ -80,6 +80,13 @@ let UserService = class UserService {
|
|
80
80
|
},
|
81
81
|
});
|
82
82
|
}
|
83
|
+
async getByEmail(email) {
|
84
|
+
return this.prismaService.user.findFirst({
|
85
|
+
where: {
|
86
|
+
email,
|
87
|
+
},
|
88
|
+
});
|
89
|
+
}
|
83
90
|
async update({ id, data }) {
|
84
91
|
return this.prismaService.user.update({
|
85
92
|
where: { id },
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,2CAKwB;AACxB,mCAAuC;AAGvC,+DAAyD;AAKlD,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;
|
1
|
+
{"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAAsE;AACtE,2CAA+C;AAC/C,2CAKwB;AACxB,mCAAuC;AAGvC,+DAAyD;AAKlD,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,gBAA+B;QAC7D,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CACpC,IAAI,CAAC,aAAa,CAAC,IAAI,EACvB,gBAAgB,EAChB;YACE,OAAO,EAAE;gBACP,SAAS,EAAE;oBACT,KAAK,EAAE;wBACL,OAAO,EAAE,MAAM;qBAChB;oBACD,MAAM,EAAE;wBACN,OAAO,EAAE,IAAI;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AA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8BAAiB,CAAC,CAAC,CAAA;qCADZ,sBAAa;QAET,8BAAiB;GAL5C,WAAW,CAwHvB"}
|
@@ -1,63 +1,63 @@
|
|
1
|
-
import FormPanel, {
|
2
|
-
FormPanelRef,
|
3
|
-
getFieldsLocale,
|
4
|
-
} from '@/components/panels/form-panel'
|
5
|
-
import { EnumFieldType } from '@/enums/EnumFieldType'
|
6
|
-
import { useDashboardCreate } from '@/features/admin/dashboard'
|
7
|
-
import { Dashboard } from '@/types/models'
|
8
|
-
import { forwardRef, useImperativeHandle, useRef } from 'react'
|
9
|
-
import { useTranslation } from 'react-i18next'
|
10
|
-
|
11
|
-
export type DashboardCreatePanelRef = {
|
12
|
-
submit: () => void
|
13
|
-
}
|
14
|
-
|
15
|
-
export type DashboardCreatePanelProps = {
|
16
|
-
onCreated?: (data: Dashboard) => void
|
17
|
-
}
|
18
|
-
|
19
|
-
const DashboardCreatePanel = forwardRef(
|
20
|
-
({ onCreated }: DashboardCreatePanelProps, ref) => {
|
21
|
-
const formRef = useRef<FormPanelRef>(null)
|
22
|
-
const { t } = useTranslation(['actions', 'fields', 'translations'])
|
23
|
-
const { mutateAsync: createDashboard } = useDashboardCreate()
|
24
|
-
|
25
|
-
useImperativeHandle(
|
26
|
-
ref,
|
27
|
-
() => ({
|
28
|
-
submit: () => {
|
29
|
-
formRef.current?.submit()
|
30
|
-
},
|
31
|
-
}),
|
32
|
-
[formRef]
|
33
|
-
)
|
34
|
-
|
35
|
-
return (
|
36
|
-
<FormPanel
|
37
|
-
ref={formRef}
|
38
|
-
fields={[
|
39
|
-
{
|
40
|
-
name: 'slug',
|
41
|
-
label: { text: t('dashboard.slug', { ns: 'fields' }) },
|
42
|
-
type: EnumFieldType.TEXT,
|
43
|
-
required: true,
|
44
|
-
},
|
45
|
-
...getFieldsLocale([{ name: 'name' }]),
|
46
|
-
]}
|
47
|
-
button={{ text: t('create', { ns: 'actions' }) }}
|
48
|
-
onSubmit={async (data) => {
|
49
|
-
const createdData = await createDashboard({
|
50
|
-
data,
|
51
|
-
})
|
52
|
-
if (typeof onCreated === 'function') {
|
53
|
-
onCreated(createdData as any)
|
54
|
-
}
|
55
|
-
}}
|
56
|
-
/>
|
57
|
-
)
|
58
|
-
}
|
59
|
-
)
|
60
|
-
|
61
|
-
DashboardCreatePanel.displayName = 'DashboardCreatePanel'
|
62
|
-
|
63
|
-
export default DashboardCreatePanel
|
1
|
+
import FormPanel, {
|
2
|
+
FormPanelRef,
|
3
|
+
getFieldsLocale,
|
4
|
+
} from '@/components/panels/form-panel'
|
5
|
+
import { EnumFieldType } from '@/enums/EnumFieldType'
|
6
|
+
import { useDashboardCreate } from '@/features/admin/dashboard'
|
7
|
+
import { Dashboard } from '@/types/models'
|
8
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react'
|
9
|
+
import { useTranslation } from 'react-i18next'
|
10
|
+
|
11
|
+
export type DashboardCreatePanelRef = {
|
12
|
+
submit: () => void
|
13
|
+
}
|
14
|
+
|
15
|
+
export type DashboardCreatePanelProps = {
|
16
|
+
onCreated?: (data: Dashboard) => void
|
17
|
+
}
|
18
|
+
|
19
|
+
const DashboardCreatePanel = forwardRef(
|
20
|
+
({ onCreated }: DashboardCreatePanelProps, ref) => {
|
21
|
+
const formRef = useRef<FormPanelRef>(null)
|
22
|
+
const { t } = useTranslation(['actions', 'fields', 'translations'])
|
23
|
+
const { mutateAsync: createDashboard } = useDashboardCreate()
|
24
|
+
|
25
|
+
useImperativeHandle(
|
26
|
+
ref,
|
27
|
+
() => ({
|
28
|
+
submit: () => {
|
29
|
+
formRef.current?.submit()
|
30
|
+
},
|
31
|
+
}),
|
32
|
+
[formRef]
|
33
|
+
)
|
34
|
+
|
35
|
+
return (
|
36
|
+
<FormPanel
|
37
|
+
ref={formRef}
|
38
|
+
fields={[
|
39
|
+
{
|
40
|
+
name: 'slug',
|
41
|
+
label: { text: t('dashboard.slug', { ns: 'fields' }) },
|
42
|
+
type: EnumFieldType.TEXT,
|
43
|
+
required: true,
|
44
|
+
},
|
45
|
+
...getFieldsLocale([{ name: 'name' }]),
|
46
|
+
]}
|
47
|
+
button={{ text: t('create', { ns: 'actions' }) }}
|
48
|
+
onSubmit={async (data) => {
|
49
|
+
const createdData = await createDashboard({
|
50
|
+
data,
|
51
|
+
})
|
52
|
+
if (typeof onCreated === 'function') {
|
53
|
+
onCreated(createdData as any)
|
54
|
+
}
|
55
|
+
}}
|
56
|
+
/>
|
57
|
+
)
|
58
|
+
}
|
59
|
+
)
|
60
|
+
|
61
|
+
DashboardCreatePanel.displayName = 'DashboardCreatePanel'
|
62
|
+
|
63
|
+
export default DashboardCreatePanel
|
@@ -1,116 +1,116 @@
|
|
1
|
-
import { PageTitle } from '@/components/custom/page-title'
|
2
|
-
import DataPanel from '@/components/panels/data-panel'
|
3
|
-
import { useDashboardDelete } from '@/features/admin/dashboard'
|
4
|
-
import { useApp } from '@/hooks/use-app'
|
5
|
-
import { isPlural } from '@/lib/utils'
|
6
|
-
import { Dashboard } from '@/types/models'
|
7
|
-
import { IconEdit, IconPlus, IconTrash } from '@tabler/icons-react'
|
8
|
-
import { useState } from 'react'
|
9
|
-
import { useTranslation } from 'react-i18next'
|
10
|
-
import DashboardCreatePanel from './components/dashboard-create-panel'
|
11
|
-
import DashboardUpdatePanel from './components/dashboard-update-panel'
|
12
|
-
import DashboardCard from '@/components/cards/dashboard-card'
|
13
|
-
|
14
|
-
export default function Page() {
|
15
|
-
const [selectedItems, setSelectedItems] = useState<Dashboard[]>([])
|
16
|
-
const { mutate: deleteDashboard } = useDashboardDelete()
|
17
|
-
const { openSheet, confirm, closeSheet } = useApp()
|
18
|
-
const { t } = useTranslation([
|
19
|
-
'dashboard.dashboard',
|
20
|
-
'modules',
|
21
|
-
'actions',
|
22
|
-
'fields',
|
23
|
-
])
|
24
|
-
|
25
|
-
const openCreate = () => {
|
26
|
-
const id = openSheet({
|
27
|
-
title: t('create', { ns: 'dashboard.dashboard' }),
|
28
|
-
description: t('createText', { ns: 'dashboard.dashboard' }),
|
29
|
-
children: () => <DashboardCreatePanel onCreated={() => closeSheet(id)} />,
|
30
|
-
})
|
31
|
-
|
32
|
-
return id
|
33
|
-
}
|
34
|
-
|
35
|
-
const openDelete = (items: Dashboard[]) => {
|
36
|
-
return confirm({
|
37
|
-
title: `${t('delete', { ns: 'dashboard.dashboard' })} ${items.length} ${isPlural(items.length) ? t('items', { ns: 'actions' }) : t('item', { ns: 'actions' })}`,
|
38
|
-
description: t('deleteText', { ns: 'dashboard.dashboard' }),
|
39
|
-
})
|
40
|
-
.then(() =>
|
41
|
-
deleteDashboard(
|
42
|
-
items
|
43
|
-
.map((item) => (item as any).dashboard_id)
|
44
|
-
.filter((id) => id !== undefined)
|
45
|
-
)
|
46
|
-
)
|
47
|
-
.catch(() => setSelectedItems(items))
|
48
|
-
}
|
49
|
-
|
50
|
-
const openUpdate = (item: Dashboard) => {
|
51
|
-
const id = openSheet({
|
52
|
-
children: () => (
|
53
|
-
<DashboardUpdatePanel data={item} onUpdated={() => closeSheet(id)} />
|
54
|
-
),
|
55
|
-
title: t('edit', { ns: 'dashboard.dashboard' }),
|
56
|
-
description: t('editText', { ns: 'dashboard.dashboard' }),
|
57
|
-
})
|
58
|
-
|
59
|
-
return id
|
60
|
-
}
|
61
|
-
|
62
|
-
return (
|
63
|
-
<>
|
64
|
-
<PageTitle title={t('dashboard', { ns: 'modules' })} />
|
65
|
-
<DataPanel
|
66
|
-
url='/dashboard'
|
67
|
-
layout='grid'
|
68
|
-
id='dashboard'
|
69
|
-
selectable
|
70
|
-
render={(item: Dashboard) => <DashboardCard item={item} />}
|
71
|
-
responsiveColumns={{
|
72
|
-
default: 1,
|
73
|
-
sm: 2,
|
74
|
-
md: 1,
|
75
|
-
lg: 2,
|
76
|
-
xl: 3,
|
77
|
-
}}
|
78
|
-
selected={selectedItems as Dashboard[]}
|
79
|
-
multiple
|
80
|
-
hasSearch
|
81
|
-
onItemDoubleClick={(item) => openUpdate(item)}
|
82
|
-
menuActions={[
|
83
|
-
{
|
84
|
-
icon: <IconEdit className='mr-1 w-8 cursor-pointer' />,
|
85
|
-
label: t('edit', { ns: 'actions' }),
|
86
|
-
tooltip: t('editTooltip', { ns: 'contact.dashboard' }),
|
87
|
-
handler: (items: Dashboard[]) => {
|
88
|
-
if (items.length === 1) openUpdate(items[0])
|
89
|
-
},
|
90
|
-
show: 'once',
|
91
|
-
},
|
92
|
-
{
|
93
|
-
icon: <IconTrash className='mr-1 w-8 cursor-pointer' />,
|
94
|
-
label: t('delete', { ns: 'actions' }),
|
95
|
-
tooltip: t('deleteTooltip', { ns: 'contact.dashboard' }),
|
96
|
-
variant: 'destructive',
|
97
|
-
handler: (items: Dashboard[]) => {
|
98
|
-
openDelete(items)
|
99
|
-
},
|
100
|
-
show: 'some',
|
101
|
-
},
|
102
|
-
{
|
103
|
-
icon: <IconPlus className='mr-1 w-8 cursor-pointer' />,
|
104
|
-
label: t('create', { ns: 'actions' }),
|
105
|
-
tooltip: t('createTooltip', { ns: 'contact.dashboard' }),
|
106
|
-
variant: 'default',
|
107
|
-
handler: () => {
|
108
|
-
openCreate()
|
109
|
-
},
|
110
|
-
show: 'none',
|
111
|
-
},
|
112
|
-
]}
|
113
|
-
/>
|
114
|
-
</>
|
115
|
-
)
|
116
|
-
}
|
1
|
+
import { PageTitle } from '@/components/custom/page-title'
|
2
|
+
import DataPanel from '@/components/panels/data-panel'
|
3
|
+
import { useDashboardDelete } from '@/features/admin/dashboard'
|
4
|
+
import { useApp } from '@/hooks/use-app'
|
5
|
+
import { isPlural } from '@/lib/utils'
|
6
|
+
import { Dashboard } from '@/types/models'
|
7
|
+
import { IconEdit, IconPlus, IconTrash } from '@tabler/icons-react'
|
8
|
+
import { useState } from 'react'
|
9
|
+
import { useTranslation } from 'react-i18next'
|
10
|
+
import DashboardCreatePanel from './components/dashboard-create-panel'
|
11
|
+
import DashboardUpdatePanel from './components/dashboard-update-panel'
|
12
|
+
import DashboardCard from '@/components/cards/dashboard-card'
|
13
|
+
|
14
|
+
export default function Page() {
|
15
|
+
const [selectedItems, setSelectedItems] = useState<Dashboard[]>([])
|
16
|
+
const { mutate: deleteDashboard } = useDashboardDelete()
|
17
|
+
const { openSheet, confirm, closeSheet } = useApp()
|
18
|
+
const { t } = useTranslation([
|
19
|
+
'dashboard.dashboard',
|
20
|
+
'modules',
|
21
|
+
'actions',
|
22
|
+
'fields',
|
23
|
+
])
|
24
|
+
|
25
|
+
const openCreate = () => {
|
26
|
+
const id = openSheet({
|
27
|
+
title: t('create', { ns: 'dashboard.dashboard' }),
|
28
|
+
description: t('createText', { ns: 'dashboard.dashboard' }),
|
29
|
+
children: () => <DashboardCreatePanel onCreated={() => closeSheet(id)} />,
|
30
|
+
})
|
31
|
+
|
32
|
+
return id
|
33
|
+
}
|
34
|
+
|
35
|
+
const openDelete = (items: Dashboard[]) => {
|
36
|
+
return confirm({
|
37
|
+
title: `${t('delete', { ns: 'dashboard.dashboard' })} ${items.length} ${isPlural(items.length) ? t('items', { ns: 'actions' }) : t('item', { ns: 'actions' })}`,
|
38
|
+
description: t('deleteText', { ns: 'dashboard.dashboard' }),
|
39
|
+
})
|
40
|
+
.then(() =>
|
41
|
+
deleteDashboard(
|
42
|
+
items
|
43
|
+
.map((item) => (item as any).dashboard_id)
|
44
|
+
.filter((id) => id !== undefined)
|
45
|
+
)
|
46
|
+
)
|
47
|
+
.catch(() => setSelectedItems(items))
|
48
|
+
}
|
49
|
+
|
50
|
+
const openUpdate = (item: Dashboard) => {
|
51
|
+
const id = openSheet({
|
52
|
+
children: () => (
|
53
|
+
<DashboardUpdatePanel data={item} onUpdated={() => closeSheet(id)} />
|
54
|
+
),
|
55
|
+
title: t('edit', { ns: 'dashboard.dashboard' }),
|
56
|
+
description: t('editText', { ns: 'dashboard.dashboard' }),
|
57
|
+
})
|
58
|
+
|
59
|
+
return id
|
60
|
+
}
|
61
|
+
|
62
|
+
return (
|
63
|
+
<>
|
64
|
+
<PageTitle title={t('dashboard', { ns: 'modules' })} />
|
65
|
+
<DataPanel
|
66
|
+
url='/dashboard'
|
67
|
+
layout='grid'
|
68
|
+
id='dashboard'
|
69
|
+
selectable
|
70
|
+
render={(item: Dashboard) => <DashboardCard item={item} />}
|
71
|
+
responsiveColumns={{
|
72
|
+
default: 1,
|
73
|
+
sm: 2,
|
74
|
+
md: 1,
|
75
|
+
lg: 2,
|
76
|
+
xl: 3,
|
77
|
+
}}
|
78
|
+
selected={selectedItems as Dashboard[]}
|
79
|
+
multiple
|
80
|
+
hasSearch
|
81
|
+
onItemDoubleClick={(item) => openUpdate(item)}
|
82
|
+
menuActions={[
|
83
|
+
{
|
84
|
+
icon: <IconEdit className='mr-1 w-8 cursor-pointer' />,
|
85
|
+
label: t('edit', { ns: 'actions' }),
|
86
|
+
tooltip: t('editTooltip', { ns: 'contact.dashboard' }),
|
87
|
+
handler: (items: Dashboard[]) => {
|
88
|
+
if (items.length === 1) openUpdate(items[0])
|
89
|
+
},
|
90
|
+
show: 'once',
|
91
|
+
},
|
92
|
+
{
|
93
|
+
icon: <IconTrash className='mr-1 w-8 cursor-pointer' />,
|
94
|
+
label: t('delete', { ns: 'actions' }),
|
95
|
+
tooltip: t('deleteTooltip', { ns: 'contact.dashboard' }),
|
96
|
+
variant: 'destructive',
|
97
|
+
handler: (items: Dashboard[]) => {
|
98
|
+
openDelete(items)
|
99
|
+
},
|
100
|
+
show: 'some',
|
101
|
+
},
|
102
|
+
{
|
103
|
+
icon: <IconPlus className='mr-1 w-8 cursor-pointer' />,
|
104
|
+
label: t('create', { ns: 'actions' }),
|
105
|
+
tooltip: t('createTooltip', { ns: 'contact.dashboard' }),
|
106
|
+
variant: 'default',
|
107
|
+
handler: () => {
|
108
|
+
openCreate()
|
109
|
+
},
|
110
|
+
show: 'none',
|
111
|
+
},
|
112
|
+
]}
|
113
|
+
/>
|
114
|
+
</>
|
115
|
+
)
|
116
|
+
}
|
@@ -1,80 +1,80 @@
|
|
1
|
-
import FormPanel, {
|
2
|
-
FormPanelRef,
|
3
|
-
getFieldsLocale,
|
4
|
-
} from '@/components/panels/form-panel'
|
5
|
-
import { Overlay } from '@/components/custom/overlay'
|
6
|
-
import { TabPanel } from '@/components/panels/tab-panel'
|
7
|
-
import {
|
8
|
-
useDashboardGet,
|
9
|
-
useDashboardUpdate,
|
10
|
-
} from '@/features/admin/dashboard'
|
11
|
-
import useEffectAfterFirstUpdate from '@/hooks/use-effect-after-first-update'
|
12
|
-
import { Dashboard } from '@/types/models'
|
13
|
-
import { forwardRef, useImperativeHandle, useRef } from 'react'
|
14
|
-
import { useTranslation } from 'react-i18next'
|
15
|
-
import { EnumFieldType } from '@/enums/EnumFieldType'
|
16
|
-
|
17
|
-
export type DashboardUpdatePanelProps = {
|
18
|
-
data: Dashboard
|
19
|
-
onUpdated?: (data: Dashboard) => void
|
20
|
-
}
|
21
|
-
|
22
|
-
const DashboardUpdatePanel = forwardRef(
|
23
|
-
({ data, onUpdated }: DashboardUpdatePanelProps, ref) => {
|
24
|
-
const { t } = useTranslation(['actions', 'fields', 'translations'])
|
25
|
-
const { data: item, isLoading } = useDashboardGet(
|
26
|
-
(data as any).dashboard_id as number
|
27
|
-
)
|
28
|
-
const { mutate: dashboardUpdate } = useDashboardUpdate()
|
29
|
-
const formRef = useRef<FormPanelRef>(null)
|
30
|
-
|
31
|
-
useEffectAfterFirstUpdate(() => {
|
32
|
-
if (item && formRef.current) {
|
33
|
-
formRef.current.setValuesFromItem(item)
|
34
|
-
}
|
35
|
-
}, [item])
|
36
|
-
|
37
|
-
useImperativeHandle(ref, () => ({}))
|
38
|
-
|
39
|
-
return (
|
40
|
-
<TabPanel
|
41
|
-
activeTabIndex={0}
|
42
|
-
tabs={[
|
43
|
-
{
|
44
|
-
title: t('details', { ns: 'actions' }),
|
45
|
-
children: (
|
46
|
-
<Overlay loading={isLoading}>
|
47
|
-
<FormPanel
|
48
|
-
ref={formRef}
|
49
|
-
fields={[
|
50
|
-
{
|
51
|
-
name: 'slug',
|
52
|
-
label: { text: t('dashboard.slug', { ns: 'fields' }) },
|
53
|
-
type: EnumFieldType.TEXT,
|
54
|
-
required: true,
|
55
|
-
},
|
56
|
-
...getFieldsLocale([{ name: 'name' }], item),
|
57
|
-
]}
|
58
|
-
button={{ text: t('save', { ns: 'actions' }) }}
|
59
|
-
onSubmit={(data) => {
|
60
|
-
dashboardUpdate({
|
61
|
-
id: data.id,
|
62
|
-
data,
|
63
|
-
})
|
64
|
-
if (typeof onUpdated === 'function') {
|
65
|
-
onUpdated(data)
|
66
|
-
}
|
67
|
-
}}
|
68
|
-
/>
|
69
|
-
</Overlay>
|
70
|
-
),
|
71
|
-
},
|
72
|
-
]}
|
73
|
-
/>
|
74
|
-
)
|
75
|
-
}
|
76
|
-
)
|
77
|
-
|
78
|
-
DashboardUpdatePanel.displayName = 'DashboardUpdatePanel'
|
79
|
-
|
80
|
-
export default DashboardUpdatePanel
|
1
|
+
import FormPanel, {
|
2
|
+
FormPanelRef,
|
3
|
+
getFieldsLocale,
|
4
|
+
} from '@/components/panels/form-panel'
|
5
|
+
import { Overlay } from '@/components/custom/overlay'
|
6
|
+
import { TabPanel } from '@/components/panels/tab-panel'
|
7
|
+
import {
|
8
|
+
useDashboardGet,
|
9
|
+
useDashboardUpdate,
|
10
|
+
} from '@/features/admin/dashboard'
|
11
|
+
import useEffectAfterFirstUpdate from '@/hooks/use-effect-after-first-update'
|
12
|
+
import { Dashboard } from '@/types/models'
|
13
|
+
import { forwardRef, useImperativeHandle, useRef } from 'react'
|
14
|
+
import { useTranslation } from 'react-i18next'
|
15
|
+
import { EnumFieldType } from '@/enums/EnumFieldType'
|
16
|
+
|
17
|
+
export type DashboardUpdatePanelProps = {
|
18
|
+
data: Dashboard
|
19
|
+
onUpdated?: (data: Dashboard) => void
|
20
|
+
}
|
21
|
+
|
22
|
+
const DashboardUpdatePanel = forwardRef(
|
23
|
+
({ data, onUpdated }: DashboardUpdatePanelProps, ref) => {
|
24
|
+
const { t } = useTranslation(['actions', 'fields', 'translations'])
|
25
|
+
const { data: item, isLoading } = useDashboardGet(
|
26
|
+
(data as any).dashboard_id as number
|
27
|
+
)
|
28
|
+
const { mutate: dashboardUpdate } = useDashboardUpdate()
|
29
|
+
const formRef = useRef<FormPanelRef>(null)
|
30
|
+
|
31
|
+
useEffectAfterFirstUpdate(() => {
|
32
|
+
if (item && formRef.current) {
|
33
|
+
formRef.current.setValuesFromItem(item)
|
34
|
+
}
|
35
|
+
}, [item])
|
36
|
+
|
37
|
+
useImperativeHandle(ref, () => ({}))
|
38
|
+
|
39
|
+
return (
|
40
|
+
<TabPanel
|
41
|
+
activeTabIndex={0}
|
42
|
+
tabs={[
|
43
|
+
{
|
44
|
+
title: t('details', { ns: 'actions' }),
|
45
|
+
children: (
|
46
|
+
<Overlay loading={isLoading}>
|
47
|
+
<FormPanel
|
48
|
+
ref={formRef}
|
49
|
+
fields={[
|
50
|
+
{
|
51
|
+
name: 'slug',
|
52
|
+
label: { text: t('dashboard.slug', { ns: 'fields' }) },
|
53
|
+
type: EnumFieldType.TEXT,
|
54
|
+
required: true,
|
55
|
+
},
|
56
|
+
...getFieldsLocale([{ name: 'name' }], item),
|
57
|
+
]}
|
58
|
+
button={{ text: t('save', { ns: 'actions' }) }}
|
59
|
+
onSubmit={(data) => {
|
60
|
+
dashboardUpdate({
|
61
|
+
id: data.id,
|
62
|
+
data,
|
63
|
+
})
|
64
|
+
if (typeof onUpdated === 'function') {
|
65
|
+
onUpdated(data)
|
66
|
+
}
|
67
|
+
}}
|
68
|
+
/>
|
69
|
+
</Overlay>
|
70
|
+
),
|
71
|
+
},
|
72
|
+
]}
|
73
|
+
/>
|
74
|
+
)
|
75
|
+
}
|
76
|
+
)
|
77
|
+
|
78
|
+
DashboardUpdatePanel.displayName = 'DashboardUpdatePanel'
|
79
|
+
|
80
|
+
export default DashboardUpdatePanel
|
@@ -1,11 +1,11 @@
|
|
1
|
-
{
|
2
|
-
"create": "Create dashboard",
|
3
|
-
"createText": "Fill the dashboard informations.",
|
4
|
-
"createTooltip": "Create new dashboard",
|
5
|
-
"delete": "Delete dashboard",
|
6
|
-
"deleteText": "Are you sure to delete these dashboard?",
|
7
|
-
"deleteTooltip": "Delete the selected dashboard",
|
8
|
-
"edit": "Edit dashboard",
|
9
|
-
"editText": "View and edit dashboard information.",
|
10
|
-
"editTooltip": "Edit the selected dashboard"
|
11
|
-
}
|
1
|
+
{
|
2
|
+
"create": "Create dashboard",
|
3
|
+
"createText": "Fill the dashboard informations.",
|
4
|
+
"createTooltip": "Create new dashboard",
|
5
|
+
"delete": "Delete dashboard",
|
6
|
+
"deleteText": "Are you sure to delete these dashboard?",
|
7
|
+
"deleteTooltip": "Delete the selected dashboard",
|
8
|
+
"edit": "Edit dashboard",
|
9
|
+
"editText": "View and edit dashboard information.",
|
10
|
+
"editTooltip": "Edit the selected dashboard"
|
11
|
+
}
|
@@ -1,11 +1,11 @@
|
|
1
|
-
{
|
2
|
-
"create": "Criar dashboard",
|
3
|
-
"createText": "Preencha as informações do dashboard.",
|
4
|
-
"createTooltip": "Criar novo dashboard",
|
5
|
-
"delete": "Excluir dashboard",
|
6
|
-
"deleteText": "Você tem certeza de que deseja excluir estes dashboards?",
|
7
|
-
"deleteTooltip": "Excluir o dashboard selecionado",
|
8
|
-
"edit": "Editar dashboard",
|
9
|
-
"editText": "Visualizar e editar informações do dashboard.",
|
10
|
-
"editTooltip": "Editar o dashboard selecionado"
|
11
|
-
}
|
1
|
+
{
|
2
|
+
"create": "Criar dashboard",
|
3
|
+
"createText": "Preencha as informações do dashboard.",
|
4
|
+
"createTooltip": "Criar novo dashboard",
|
5
|
+
"delete": "Excluir dashboard",
|
6
|
+
"deleteText": "Você tem certeza de que deseja excluir estes dashboards?",
|
7
|
+
"deleteTooltip": "Excluir o dashboard selecionado",
|
8
|
+
"edit": "Editar dashboard",
|
9
|
+
"editText": "Visualizar e editar informações do dashboard.",
|
10
|
+
"editTooltip": "Editar o dashboard selecionado"
|
11
|
+
}
|
@@ -1,28 +1,28 @@
|
|
1
|
-
import { useDefaultMutation } from "@/hooks/use-default-mutation";
|
2
|
-
import { useQuery } from "@tanstack/react-query";
|
3
|
-
import { requests } from "./requests";
|
4
|
-
|
5
|
-
const scope = "dashboard";
|
6
|
-
|
7
|
-
export function useDashboardCreate() {
|
8
|
-
const { dashboardCreate } = requests();
|
9
|
-
return useDefaultMutation(scope, "create", dashboardCreate);
|
10
|
-
}
|
11
|
-
|
12
|
-
export function useDashboardDelete() {
|
13
|
-
const { dashboardDelete } = requests();
|
14
|
-
return useDefaultMutation(scope, "delete", dashboardDelete);
|
15
|
-
}
|
16
|
-
|
17
|
-
export function useDashboardUpdate() {
|
18
|
-
const { dashboardUpdate } = requests();
|
19
|
-
return useDefaultMutation(scope, "update", dashboardUpdate);
|
20
|
-
}
|
21
|
-
|
22
|
-
export function useDashboardGet(id: number) {
|
23
|
-
const { dashboardGet } = requests();
|
24
|
-
return useQuery({
|
25
|
-
queryKey: [scope, "get"],
|
26
|
-
queryFn: () => dashboardGet(id),
|
27
|
-
});
|
28
|
-
}
|
1
|
+
import { useDefaultMutation } from "@/hooks/use-default-mutation";
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
3
|
+
import { requests } from "./requests";
|
4
|
+
|
5
|
+
const scope = "dashboard";
|
6
|
+
|
7
|
+
export function useDashboardCreate() {
|
8
|
+
const { dashboardCreate } = requests();
|
9
|
+
return useDefaultMutation(scope, "create", dashboardCreate);
|
10
|
+
}
|
11
|
+
|
12
|
+
export function useDashboardDelete() {
|
13
|
+
const { dashboardDelete } = requests();
|
14
|
+
return useDefaultMutation(scope, "delete", dashboardDelete);
|
15
|
+
}
|
16
|
+
|
17
|
+
export function useDashboardUpdate() {
|
18
|
+
const { dashboardUpdate } = requests();
|
19
|
+
return useDefaultMutation(scope, "update", dashboardUpdate);
|
20
|
+
}
|
21
|
+
|
22
|
+
export function useDashboardGet(id: number) {
|
23
|
+
const { dashboardGet } = requests();
|
24
|
+
return useQuery({
|
25
|
+
queryKey: [scope, "get"],
|
26
|
+
queryFn: () => dashboardGet(id),
|
27
|
+
});
|
28
|
+
}
|