Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b614be79c1 |
@@ -1,7 +1,14 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { getSessionUser, updateProfile, changePassword, getSettings, getUserNotificationConfig, updateUserNotificationConfig } from '@/app/actions'
|
import {
|
||||||
|
getSessionUser,
|
||||||
|
updateProfile,
|
||||||
|
changePassword,
|
||||||
|
getSettings,
|
||||||
|
getUserNotificationConfig,
|
||||||
|
updateUserNotificationConfig,
|
||||||
|
} from '@/app/actions'
|
||||||
import { Card, CardContent, CardHeader, CardTitle, CardFooter } from '@/components/ui/card'
|
import { Card, CardContent, CardHeader, CardTitle, CardFooter } from '@/components/ui/card'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
@@ -65,7 +72,7 @@ export default function ProfilePage() {
|
|||||||
|
|
||||||
const [globalSettings, notifConfig] = await Promise.all([
|
const [globalSettings, notifConfig] = await Promise.all([
|
||||||
getSettings(),
|
getSettings(),
|
||||||
getUserNotificationConfig(sessionUser.id)
|
getUserNotificationConfig(sessionUser.id),
|
||||||
])
|
])
|
||||||
|
|
||||||
if (globalSettings?.MATTERMOST_NOTIF_ENABLED === 'true') {
|
if (globalSettings?.MATTERMOST_NOTIF_ENABLED === 'true') {
|
||||||
@@ -93,10 +100,12 @@ export default function ProfilePage() {
|
|||||||
|
|
||||||
const [res, notifRes] = await Promise.all([
|
const [res, notifRes] = await Promise.all([
|
||||||
updateProfile(user.id, name.trim(), photo.trim() || null),
|
updateProfile(user.id, name.trim(), photo.trim() || null),
|
||||||
globalNotifEnabled ? updateUserNotificationConfig(user.id, {
|
globalNotifEnabled
|
||||||
|
? updateUserNotificationConfig(user.id, {
|
||||||
mattermost_channel_id: mmChannelId,
|
mattermost_channel_id: mmChannelId,
|
||||||
is_active: mmActive
|
is_active: mmActive,
|
||||||
}) : Promise.resolve({ success: true, error: null })
|
})
|
||||||
|
: Promise.resolve({ success: true, error: null }),
|
||||||
])
|
])
|
||||||
|
|
||||||
if (res.success && notifRes.success) {
|
if (res.success && notifRes.success) {
|
||||||
@@ -244,7 +253,7 @@ export default function ProfilePage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{globalNotifEnabled && (
|
{globalNotifEnabled && (
|
||||||
<div className="space-y-6 pt-6 mt-6 border-t border-slate-100 dark:border-slate-800">
|
<div className="mt-6 space-y-6 border-t border-slate-100 pt-6 dark:border-slate-800">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-purple-100 text-purple-600 dark:bg-purple-900/30 dark:text-purple-400">
|
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-purple-100 text-purple-600 dark:bg-purple-900/30 dark:text-purple-400">
|
||||||
<MessageCircle className="h-5 w-5" />
|
<MessageCircle className="h-5 w-5" />
|
||||||
@@ -259,7 +268,7 @@ export default function ProfilePage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flex-row items-start space-x-3 space-y-0 rounded-md border border-slate-200 p-4 dark:border-slate-800">
|
<div className="flex flex-row items-start space-y-0 space-x-3 rounded-md border border-slate-200 p-4 dark:border-slate-800">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="mmActive"
|
id="mmActive"
|
||||||
@@ -278,14 +287,17 @@ export default function ProfilePage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-1.5">
|
<div className="space-y-1.5">
|
||||||
<Label htmlFor="mm-channel" className="text-xs font-bold tracking-wider text-slate-700 uppercase dark:text-slate-300">
|
<Label
|
||||||
|
htmlFor="mm-channel"
|
||||||
|
className="text-xs font-bold tracking-wider text-slate-700 uppercase dark:text-slate-300"
|
||||||
|
>
|
||||||
Username / Channel ID
|
Username / Channel ID
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id="mm-channel"
|
id="mm-channel"
|
||||||
value={mmChannelId}
|
value={mmChannelId}
|
||||||
onChange={(e) => setMmChannelId(e.target.value)}
|
onChange={(e) => setMmChannelId(e.target.value)}
|
||||||
placeholder="Contoh: @firman atau 9dpxnitm..."
|
placeholder="Contoh: budisantoso atau 9dpxnitm..."
|
||||||
className="h-11 rounded-xl"
|
className="h-11 rounded-xl"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -321,7 +333,6 @@ export default function ProfilePage() {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right 1 Col: Account Details */}
|
{/* Right 1 Col: Account Details */}
|
||||||
|
|||||||
Reference in New Issue
Block a user