Skip to content

Commit

Permalink
feat: hide username and password for guest
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Feb 4, 2023
1 parent 7a810e4 commit a081da0
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions src/pages/manage/users/AddOrEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useFetch, useRouter, useT } from "~/hooks"
import { handleResp, notify, r } from "~/utils"
import { PEmptyResp, PResp, User, UserMethods, UserPermissions } from "~/types"
import { createStore } from "solid-js/store"
import { For } from "solid-js"
import { For, Show } from "solid-js"

const Permission = (props: {
can: boolean
Expand Down Expand Up @@ -73,28 +73,31 @@ const AddOrEdit = () => {
<MaybeLoading loading={userLoading()}>
<VStack w="$full" alignItems="start" spacing="$2">
<Heading>{t(`global.${id ? "edit" : "add"}`)}</Heading>
<FormControl w="$full" display="flex" flexDirection="column" required>
<FormLabel for="username" display="flex" alignItems="center">
{t(`users.username`)}
</FormLabel>
<Input
id="username"
value={user.username}
onInput={(e) => setUser("username", e.currentTarget.value)}
/>
</FormControl>
<FormControl w="$full" display="flex" flexDirection="column" required>
<FormLabel for="password" display="flex" alignItems="center">
{t(`users.password`)}
</FormLabel>
<Input
id="password"
type="password"
placeholder="********"
value={user.password}
onInput={(e) => setUser("password", e.currentTarget.value)}
/>
</FormControl>
<Show when={!UserMethods.is_guest(user)}>
<FormControl w="$full" display="flex" flexDirection="column" required>
<FormLabel for="username" display="flex" alignItems="center">
{t(`users.username`)}
</FormLabel>
<Input
id="username"
value={user.username}
onInput={(e) => setUser("username", e.currentTarget.value)}
/>
</FormControl>
<FormControl w="$full" display="flex" flexDirection="column" required>
<FormLabel for="password" display="flex" alignItems="center">
{t(`users.password`)}
</FormLabel>
<Input
id="password"
type="password"
placeholder="********"
value={user.password}
onInput={(e) => setUser("password", e.currentTarget.value)}
/>
</FormControl>
</Show>

<FormControl w="$full" display="flex" flexDirection="column" required>
<FormLabel for="base_path" display="flex" alignItems="center">
{t(`users.base_path`)}
Expand Down

0 comments on commit a081da0

Please sign in to comment.