Skip to content

Commit

Permalink
Updated moderation pane user route to work for deleted users
Browse files Browse the repository at this point in the history
  • Loading branch information
SupertigerDev committed Jul 29, 2023
1 parent 916a58d commit 55486c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/chat-api/services/ModerationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ export const getOnlineUsers = async () => {
};


export interface ModerationUser {
email: string;
user: RawUser
export type ModerationUser = RawUser & {
account: {email: string}
}

export const updateUser = async (userId: string, update: {email?: string, username?: string, tag?: string}) => {
Expand Down
11 changes: 5 additions & 6 deletions src/components/moderation-pane/ModerationPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,11 @@ function UserPage() {
const [showChangePassword, setShowChangePassword] = createSignal(false);


const [account, setAccount] = createSignal<ModerationUser | null>(null);
const [user, setUser] = createSignal<ModerationUser | null>(null);

const user = () => account()?.user;

const defaultInput = () => ({
email: account()?.email || '',
email: user()?.account?.email || '',
username: user()?.username || '',
tag: user()?.tag || '',
badges: user()?.badges || 0,
Expand All @@ -562,7 +561,7 @@ function UserPage() {


onMount(() => {
getUser(params.userId).then(setAccount)
getUser(params.userId).then(setUser)
})

const requestStatus = () => requestSent() ? 'Saving...' : 'Save Changes';
Expand All @@ -573,7 +572,7 @@ function UserPage() {
const values = updatedInputValues();
await updateUser(params.userId, values)
.then(() => {
getUser(params.userId).then(setAccount)
getUser(params.userId).then(setUser)
setInputValue("password", '');
})
.catch(err => {
Expand Down Expand Up @@ -666,7 +665,7 @@ const StatCardContainer = styled(FlexColumn)`
border-radius: 8px;
`

function StatCard(props: {loading?: boolean; title: string, description: string}) {
function StatCard(props: {title: string, description?: string}) {
return (
<StatCardContainer>
<Text size={12} color="rgba(255,255,255,0.6)">{props.title}</Text>
Expand Down

0 comments on commit 55486c2

Please sign in to comment.