Merge branch 'filip-refactor-user-module' into filip-refactor-users-table

This commit is contained in:
Filip Sodić 2025-02-24 15:10:13 +01:00
commit e97a3412a5
4 changed files with 35 additions and 14 deletions

View File

@ -1,14 +1,14 @@
--- template/app/src/admin/dashboards/users/UsersTable.tsx --- template/app/src/admin/dashboards/users/UsersTable.tsx
+++ opensaas-sh/app/src/admin/dashboards/users/UsersTable.tsx +++ opensaas-sh/app/src/admin/dashboards/users/UsersTable.tsx
@@ -9,6 +9,7 @@ @@ -17,6 +17,7 @@
const [skip, setskip] = useState(0); const [skip, setskip] = useState(0);
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
const [email, setEmail] = useState<string | undefined>(undefined); const [email, setEmail] = useState<string | undefined>(undefined);
+ +
const [isAdminFilter, setIsAdminFilter] = useState<boolean | undefined>(undefined); const [isAdminFilter, setIsAdminFilter] = useState<boolean | undefined>(undefined);
const [statusOptions, setStatusOptions] = useState<SubscriptionStatus[]>([]); const [statusOptions, setStatusOptions] = useState<SubscriptionStatus[]>([]);
const { data, isLoading, error } = useQuery(getPaginatedUsers, { const { data, isLoading } = useQuery(getPaginatedUsers, {
@@ -211,7 +212,7 @@ @@ -223,7 +224,7 @@
<p className='text-sm text-black dark:text-white'>{user.subscriptionStatus}</p> <p className='text-sm text-black dark:text-white'>{user.subscriptionStatus}</p>
</div> </div>
<div className='col-span-2 flex items-center'> <div className='col-span-2 flex items-center'>

View File

@ -1,18 +1,27 @@
--- template/app/src/user/operations.ts --- template/app/src/user/operations.ts
+++ opensaas-sh/app/src/user/operations.ts +++ opensaas-sh/app/src/user/operations.ts
@@ -41,7 +41,10 @@ @@ -2,7 +2,7 @@
import { type UpdateIsUserAdminById, type GetPaginatedUsers } from 'wasp/server/operations';
import { type User } from 'wasp/entities';
import { HttpError } from 'wasp/server';
-import { subscriptionStatusSchema, type SubscriptionStatus } from '../payment/plans';
+import { subscriptionStatusSchema } from '../payment/plans';
import { ensureArgsSchemaOrThrowHttpError } from '../server/validation';
const updateUserAdminByIdInputSchema = z.object({
@@ -33,10 +33,7 @@
}; };
type GetPaginatedUsersOutput = { type GetPaginatedUsersOutput = {
- users: Pick<User, 'id' | 'email' | 'username' | 'subscriptionStatus' | 'paymentProcessorUserId'>[]; - users: Pick<
+ users: Pick< - User,
+ User, - 'id' | 'email' | 'username' | 'subscriptionStatus' | 'paymentProcessorUserId' | 'isAdmin'
+ 'id' | 'email' | 'username' | 'subscriptionStatus' | 'stripeId' - >[];
+ >[]; + users: Pick<User, 'id' | 'email' | 'username' | 'subscriptionStatus' | 'stripeId' | 'isAdmin'>[];
totalPages: number; totalPages: number;
}; };
@@ -85,6 +88,7 @@ @@ -80,6 +77,7 @@
mode: 'insensitive', mode: 'insensitive',
}, },
isAdmin, isAdmin,
@ -20,7 +29,7 @@
}, },
{ {
OR: [ OR: [
@@ -108,7 +112,7 @@ @@ -103,7 +101,7 @@
username: true, username: true,
isAdmin: true, isAdmin: true,
subscriptionStatus: true, subscriptionStatus: true,
@ -29,7 +38,7 @@
}, },
orderBy: { orderBy: {
id: 'desc', id: 'desc',
@@ -124,6 +128,7 @@ @@ -119,6 +117,7 @@
mode: 'insensitive', mode: 'insensitive',
}, },
isAdmin, isAdmin,

View File

@ -8,7 +8,13 @@ function SwitcherOne({ isOn, onChange }: { isOn: boolean; onChange: (value: bool
<div className='relative'> <div className='relative'>
<label htmlFor={id} className='flex cursor-pointer select-none items-center'> <label htmlFor={id} className='flex cursor-pointer select-none items-center'>
<div className='relative'> <div className='relative'>
<input id={id} type='checkbox' className='sr-only' onChange={(e) => onChange(e.target.checked)} /> <input
id={id}
type='checkbox'
className='sr-only'
checked={isOn}
onChange={(e) => onChange(e.target.checked)}
/>
<div className='reblock h-8 w-14 rounded-full bg-meta-9 dark:bg-[#5A616B]'></div> <div className='reblock h-8 w-14 rounded-full bg-meta-9 dark:bg-[#5A616B]'></div>
<div <div
className={cn('absolute left-1 top-1 h-6 w-6 rounded-full bg-white dark:bg-gray-400 transition', { className={cn('absolute left-1 top-1 h-6 w-6 rounded-full bg-white dark:bg-gray-400 transition', {

View File

@ -8,7 +8,13 @@ function SwitcherTwo({ isOn, onChange }: { isOn: boolean; onChange: (value: bool
<div> <div>
<label htmlFor={id} className='flex cursor-pointer select-none items-center'> <label htmlFor={id} className='flex cursor-pointer select-none items-center'>
<div className='relative'> <div className='relative'>
<input type='checkbox' id={id} className='sr-only' onChange={(e) => onChange(e.target.checked)} /> <input
type='checkbox'
id={id}
className='sr-only'
checked={isOn}
onChange={(e) => onChange(e.target.checked)}
/>
<div className='block h-8 w-14 rounded-full bg-meta-9 dark:bg-[#5A616B]'></div> <div className='block h-8 w-14 rounded-full bg-meta-9 dark:bg-[#5A616B]'></div>
<div <div
className={cn( className={cn(