Skip to content

Commit 4de2643

Browse files
committed
Merge branch 'filip-refactor-users-table' into filip-dry-subscription-status
2 parents 7ddcac2 + 145a02b commit 4de2643

File tree

17 files changed

+285
-237
lines changed

17 files changed

+285
-237
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
--- template/app/src/file-upload/operations.ts
22
+++ opensaas-sh/app/src/file-upload/operations.ts
3-
@@ -18,6 +18,18 @@
4-
throw new HttpError(401);
5-
}
3+
@@ -25,6 +25,18 @@
4+
5+
const { fileType, fileName } = ensureArgsSchemaOrThrowHttpError(createFileInputSchema, rawArgs);
66

77
+ const numberOfFilesByUser = await context.entities.File.count({
88
+ where: {
@@ -16,6 +16,6 @@
1616
+ throw new HttpError(403, 'Thanks for trying Open SaaS. This demo only allows 2 file uploads per user.');
1717
+ }
1818
+
19-
const userInfo = context.user.id;
20-
21-
const { uploadUrl, key } = await getUploadFileSignedURLFromS3({ fileType, userInfo });
19+
const { uploadUrl, key } = await getUploadFileSignedURLFromS3({
20+
fileType,
21+
fileName,

opensaas-sh/app_diff/src/payment/plans.ts.diff

Lines changed: 0 additions & 11 deletions
This file was deleted.

opensaas-sh/app_diff/src/user/operations.ts.diff

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
--- template/app/src/user/operations.ts
22
+++ opensaas-sh/app/src/user/operations.ts
3-
@@ -38,7 +38,10 @@
4-
subscriptionStatus?: SubscriptionStatus[];
3+
@@ -41,7 +41,10 @@
54
};
5+
66
type GetPaginatedUsersOutput = {
77
- users: Pick<User, 'id' | 'email' | 'username' | 'subscriptionStatus' | 'paymentProcessorUserId'>[];
88
+ users: Pick<
@@ -12,28 +12,15 @@
1212
totalPages: number;
1313
};
1414

15-
@@ -51,8 +54,10 @@
16-
}
17-
18-
const allSubscriptionStatusOptions = args.subscriptionStatus as Array<string | null> | undefined;
19-
- const hasNotSubscribed = allSubscriptionStatusOptions?.find((status) => status === null)
20-
- let subscriptionStatusStrings = allSubscriptionStatusOptions?.filter((status) => status !== null) as string[] | undefined
21-
+ const hasNotSubscribed = allSubscriptionStatusOptions?.find((status) => status === null);
22-
+ let subscriptionStatusStrings = allSubscriptionStatusOptions?.filter((status) => status !== null) as
23-
+ | string[]
24-
+ | undefined;
25-
26-
const queryResults = await context.entities.User.findMany({
27-
skip: args.skip,
28-
@@ -65,6 +70,7 @@
15+
@@ -85,6 +88,7 @@
2916
mode: 'insensitive',
3017
},
31-
isAdmin: args.isAdmin,
18+
isAdmin,
3219
+ isMockUser: true,
3320
},
3421
{
3522
OR: [
36-
@@ -88,7 +94,7 @@
23+
@@ -108,7 +112,7 @@
3724
username: true,
3825
isAdmin: true,
3926
subscriptionStatus: true,
@@ -42,10 +29,10 @@
4229
},
4330
orderBy: {
4431
id: 'desc',
45-
@@ -104,6 +110,7 @@
32+
@@ -124,6 +128,7 @@
4633
mode: 'insensitive',
4734
},
48-
isAdmin: args.isAdmin,
35+
isAdmin,
4936
+ isMockUser: true,
5037
},
5138
{

template/app/src/admin/dashboards/users/UsersTable.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import DropdownEditDelete from './DropdownEditDelete';
77
import { updateIsUserAdminById } from 'wasp/client/operations';
88
import { type User } from 'wasp/entities';
99

10-
const AdminSwitch = ({ id, isAdmin }: Pick<User, 'id' | 'isAdmin'>) => {
11-
return <SwitcherOne isOn={isAdmin} onChange={() => updateIsUserAdminById({ id: id, isAdmin: !isAdmin })} />;
12-
};
10+
function AdminSwitch({ id, isAdmin }: Pick<User, 'id' | 'isAdmin'>) {
11+
return (
12+
<SwitcherOne isOn={isAdmin} onChange={(value) => updateIsUserAdminById({ id: id, isAdmin: value })} />
13+
);
14+
}
1315

1416
const UsersTable = () => {
1517
const [currentPage, setCurrentPage] = useState(1);
@@ -218,7 +220,7 @@ const UsersTable = () => {
218220
</div>
219221
</div>
220222
);
221-
};
223+
}
222224

223225
function ChevronDownIcon() {
224226
return (

template/app/src/admin/elements/forms/FormElementsPage.tsx

Lines changed: 62 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -170,57 +170,15 @@ const FormElements = ({ user }: { user: AuthUser }) => {
170170
<label className='mb-3 block text-black dark:text-white'>Select Country</label>
171171
<div className='relative z-20 bg-white dark:bg-form-input'>
172172
<span className='absolute top-1/2 left-4 z-30 -translate-y-1/2'>
173-
<svg
174-
width='20'
175-
height='20'
176-
viewBox='0 0 20 20'
177-
fill='none'
178-
xmlns='http://www.w3.org/2000/svg'
179-
>
180-
<g opacity='0.8'>
181-
<path
182-
fillRule='evenodd'
183-
clipRule='evenodd'
184-
d='M10.0007 2.50065C5.85852 2.50065 2.50065 5.85852 2.50065 10.0007C2.50065 14.1428 5.85852 17.5007 10.0007 17.5007C14.1428 17.5007 17.5007 14.1428 17.5007 10.0007C17.5007 5.85852 14.1428 2.50065 10.0007 2.50065ZM0.833984 10.0007C0.833984 4.93804 4.93804 0.833984 10.0007 0.833984C15.0633 0.833984 19.1673 4.93804 19.1673 10.0007C19.1673 15.0633 15.0633 19.1673 10.0007 19.1673C4.93804 19.1673 0.833984 15.0633 0.833984 10.0007Z'
185-
fill='#637381'
186-
></path>
187-
<path
188-
fillRule='evenodd'
189-
clipRule='evenodd'
190-
d='M0.833984 9.99935C0.833984 9.53911 1.20708 9.16602 1.66732 9.16602H18.334C18.7942 9.16602 19.1673 9.53911 19.1673 9.99935C19.1673 10.4596 18.7942 10.8327 18.334 10.8327H1.66732C1.20708 10.8327 0.833984 10.4596 0.833984 9.99935Z'
191-
fill='#637381'
192-
></path>
193-
<path
194-
fillRule='evenodd'
195-
clipRule='evenodd'
196-
d='M7.50084 10.0008C7.55796 12.5632 8.4392 15.0301 10.0006 17.0418C11.5621 15.0301 12.4433 12.5632 12.5005 10.0008C12.4433 7.43845 11.5621 4.97153 10.0007 2.95982C8.4392 4.97153 7.55796 7.43845 7.50084 10.0008ZM10.0007 1.66749L9.38536 1.10547C7.16473 3.53658 5.90275 6.69153 5.83417 9.98346C5.83392 9.99503 5.83392 10.0066 5.83417 10.0182C5.90275 13.3101 7.16473 16.4651 9.38536 18.8962C9.54325 19.069 9.76655 19.1675 10.0007 19.1675C10.2348 19.1675 10.4581 19.069 10.6159 18.8962C12.8366 16.4651 14.0986 13.3101 14.1671 10.0182C14.1674 10.0066 14.1674 9.99503 14.1671 9.98346C14.0986 6.69153 12.8366 3.53658 10.6159 1.10547L10.0007 1.66749Z'
197-
fill='#637381'
198-
></path>
199-
</g>
200-
</svg>
173+
<GlobeIcon />
201174
</span>
202175
<select className='relative z-20 w-full appearance-none rounded border border-stroke bg-transparent py-3 px-12 outline-none transition focus:border-primary active:border-primary dark:border-form-strokedark dark:bg-form-input'>
203176
<option value=''>USA</option>
204177
<option value=''>UK</option>
205178
<option value=''>Canada</option>
206179
</select>
207180
<span className='absolute top-1/2 right-4 z-10 -translate-y-1/2'>
208-
<svg
209-
width='24'
210-
height='24'
211-
viewBox='0 0 24 24'
212-
fill='none'
213-
xmlns='http://www.w3.org/2000/svg'
214-
>
215-
<g opacity='0.8'>
216-
<path
217-
fillRule='evenodd'
218-
clipRule='evenodd'
219-
d='M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z'
220-
fill='#637381'
221-
></path>
222-
</g>
223-
</svg>
181+
<ChevronDownIcon />
224182
</span>
225183
</div>
226184
</div>
@@ -232,39 +190,13 @@ const FormElements = ({ user }: { user: AuthUser }) => {
232190
<span className='m-1.5 flex items-center justify-center rounded border-[.5px] border-stroke bg-gray py-1.5 px-2.5 text-sm font-medium dark:border-strokedark dark:bg-white/30'>
233191
Design
234192
<span className='cursor-pointer pl-2 hover:text-danger'>
235-
<svg
236-
width='12'
237-
height='12'
238-
viewBox='0 0 12 12'
239-
fill='none'
240-
xmlns='http://www.w3.org/2000/svg'
241-
>
242-
<path
243-
fillRule='evenodd'
244-
clipRule='evenodd'
245-
d='M9.35355 3.35355C9.54882 3.15829 9.54882 2.84171 9.35355 2.64645C9.15829 2.45118 8.84171 2.45118 8.64645 2.64645L6 5.29289L3.35355 2.64645C3.15829 2.45118 2.84171 2.45118 2.64645 2.64645C2.45118 2.84171 2.45118 3.15829 2.64645 3.35355L5.29289 6L2.64645 8.64645C2.45118 8.84171 2.45118 9.15829 2.64645 9.35355C2.84171 9.54882 3.15829 9.54882 3.35355 9.35355L6 6.70711L8.64645 9.35355C8.84171 9.54882 9.15829 9.54882 9.35355 9.35355C9.54882 9.15829 9.54882 8.84171 9.35355 8.64645L6.70711 6L9.35355 3.35355Z'
246-
fill='currentColor'
247-
></path>
248-
</svg>
193+
<XIcon />
249194
</span>
250195
</span>
251196
<span className='m-1.5 flex items-center justify-center rounded border-[.5px] border-stroke bg-gray py-1.5 px-2.5 text-sm font-medium dark:border-strokedark dark:bg-white/30'>
252197
Development
253198
<span className='cursor-pointer pl-2 hover:text-danger'>
254-
<svg
255-
width='12'
256-
height='12'
257-
viewBox='0 0 12 12'
258-
fill='none'
259-
xmlns='http://www.w3.org/2000/svg'
260-
>
261-
<path
262-
fillRule='evenodd'
263-
clipRule='evenodd'
264-
d='M9.35355 3.35355C9.54882 3.15829 9.54882 2.84171 9.35355 2.64645C9.15829 2.45118 8.84171 2.45118 8.64645 2.64645L6 5.29289L3.35355 2.64645C3.15829 2.45118 2.84171 2.45118 2.64645 2.64645C2.45118 2.84171 2.45118 3.15829 2.64645 3.35355L5.29289 6L2.64645 8.64645C2.45118 8.84171 2.45118 9.15829 2.64645 9.35355C2.84171 9.54882 3.15829 9.54882 3.35355 9.35355L6 6.70711L8.64645 9.35355C8.84171 9.54882 9.15829 9.54882 9.35355 9.35355C9.54882 9.15829 9.54882 8.84171 9.35355 8.64645L6.70711 6L9.35355 3.35355Z'
265-
fill='currentColor'
266-
></path>
267-
</svg>
199+
<XIcon />
268200
</span>
269201
</span>
270202
</div>
@@ -277,22 +209,7 @@ const FormElements = ({ user }: { user: AuthUser }) => {
277209
<option value=''>Option</option>
278210
</select>
279211
<span className='absolute top-1/2 right-4 z-10 -translate-y-1/2'>
280-
<svg
281-
width='24'
282-
height='24'
283-
viewBox='0 0 24 24'
284-
fill='none'
285-
xmlns='http://www.w3.org/2000/svg'
286-
>
287-
<g opacity='0.8'>
288-
<path
289-
fillRule='evenodd'
290-
clipRule='evenodd'
291-
d='M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z'
292-
fill='#637381'
293-
></path>
294-
</g>
295-
</svg>
212+
<ChevronDownIcon />
296213
</span>
297214
</div>
298215
</div>
@@ -309,10 +226,65 @@ function SwitchExamples() {
309226
const [isSecondOn, setIsSecondOn] = useState<boolean>(false);
310227
return (
311228
<div className='flex flex-col gap-5.5 p-6.5'>
312-
<SwitcherOne isOn={isFirstOn} onChange={() => setIsFirstOn(!isFirstOn)} />
313-
<SwitcherTwo isOn={isSecondOn} onChange={() => setIsSecondOn(!isSecondOn)} />
229+
<SwitcherOne isOn={isFirstOn} onChange={setIsFirstOn} />
230+
<SwitcherTwo isOn={isSecondOn} onChange={setIsSecondOn} />
314231
</div>
315232
);
316233
}
317234

235+
function GlobeIcon() {
236+
return (
237+
<svg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'>
238+
<g opacity='0.8'>
239+
<path
240+
fillRule='evenodd'
241+
clipRule='evenodd'
242+
d='M10.0007 2.50065C5.85852 2.50065 2.50065 5.85852 2.50065 10.0007C2.50065 14.1428 5.85852 17.5007 10.0007 17.5007C14.1428 17.5007 17.5007 14.1428 17.5007 10.0007C17.5007 5.85852 14.1428 2.50065 10.0007 2.50065ZM0.833984 10.0007C0.833984 4.93804 4.93804 0.833984 10.0007 0.833984C15.0633 0.833984 19.1673 4.93804 19.1673 10.0007C19.1673 15.0633 15.0633 19.1673 10.0007 19.1673C4.93804 19.1673 0.833984 15.0633 0.833984 10.0007Z'
243+
fill='#637381'
244+
></path>
245+
<path
246+
fillRule='evenodd'
247+
clipRule='evenodd'
248+
d='M0.833984 9.99935C0.833984 9.53911 1.20708 9.16602 1.66732 9.16602H18.334C18.7942 9.16602 19.1673 9.53911 19.1673 9.99935C19.1673 10.4596 18.7942 10.8327 18.334 10.8327H1.66732C1.20708 10.8327 0.833984 10.4596 0.833984 9.99935Z'
249+
fill='#637381'
250+
></path>
251+
<path
252+
fillRule='evenodd'
253+
clipRule='evenodd'
254+
d='M7.50084 10.0008C7.55796 12.5632 8.4392 15.0301 10.0006 17.0418C11.5621 15.0301 12.4433 12.5632 12.5005 10.0008C12.4433 7.43845 11.5621 4.97153 10.0007 2.95982C8.4392 4.97153 7.55796 7.43845 7.50084 10.0008ZM10.0007 1.66749L9.38536 1.10547C7.16473 3.53658 5.90275 6.69153 5.83417 9.98346C5.83392 9.99503 5.83392 10.0066 5.83417 10.0182C5.90275 13.3101 7.16473 16.4651 9.38536 18.8962C9.54325 19.069 9.76655 19.1675 10.0007 19.1675C10.2348 19.1675 10.4581 19.069 10.6159 18.8962C12.8366 16.4651 14.0986 13.3101 14.1671 10.0182C14.1674 10.0066 14.1674 9.99503 14.1671 9.98346C14.0986 6.69153 12.8366 3.53658 10.6159 1.10547L10.0007 1.66749Z'
255+
fill='#637381'
256+
></path>
257+
</g>
258+
</svg>
259+
);
260+
}
261+
262+
function ChevronDownIcon() {
263+
return (
264+
<svg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'>
265+
<g opacity='0.8'>
266+
<path
267+
fillRule='evenodd'
268+
clipRule='evenodd'
269+
d='M5.29289 8.29289C5.68342 7.90237 6.31658 7.90237 6.70711 8.29289L12 13.5858L17.2929 8.29289C17.6834 7.90237 18.3166 7.90237 18.7071 8.29289C19.0976 8.68342 19.0976 9.31658 18.7071 9.70711L12.7071 15.7071C12.3166 16.0976 11.6834 16.0976 11.2929 15.7071L5.29289 9.70711C4.90237 9.31658 4.90237 8.68342 5.29289 8.29289Z'
270+
fill='#637381'
271+
></path>
272+
</g>
273+
</svg>
274+
);
275+
}
276+
277+
function XIcon() {
278+
return (
279+
<svg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'>
280+
<path
281+
fillRule='evenodd'
282+
clipRule='evenodd'
283+
d='M9.35355 3.35355C9.54882 3.15829 9.54882 2.84171 9.35355 2.64645C9.15829 2.45118 8.84171 2.45118 8.64645 2.64645L6 5.29289L3.35355 2.64645C3.15829 2.45118 2.84171 2.45118 2.64645 2.64645C2.45118 2.84171 2.45118 3.15829 2.64645 3.35355L5.29289 6L2.64645 8.64645C2.45118 8.84171 2.45118 9.15829 2.64645 9.35355C2.84171 9.54882 3.15829 9.54882 3.35355 9.35355L6 6.70711L8.64645 9.35355C8.84171 9.54882 9.15829 9.54882 9.35355 9.35355C9.54882 9.15829 9.54882 8.84171 9.35355 8.64645L6.70711 6L9.35355 3.35355Z'
284+
fill='currentColor'
285+
></path>
286+
</svg>
287+
);
288+
}
289+
318290
export default FormElements;
Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1+
import { useId } from 'react';
12
import { cn } from '../../../client/cn';
2-
import { ChangeEventHandler } from 'react';
33

4-
const SwitcherOne = ({
5-
isOn,
6-
onChange,
7-
}: {
8-
isOn: boolean;
9-
onChange: ChangeEventHandler<HTMLInputElement>;
10-
}) => {
4+
function SwitcherOne({ isOn, onChange }: { isOn: boolean; onChange: (value: boolean) => void }) {
5+
const id = useId();
6+
117
return (
128
<div className='relative'>
13-
<label className='flex cursor-pointer select-none items-center'>
9+
<label htmlFor={id} className='flex cursor-pointer select-none items-center'>
1410
<div className='relative'>
15-
<input type='checkbox' className='sr-only' onChange={onChange} />
11+
<input id={id} type='checkbox' className='sr-only' onChange={(e) => onChange(e.target.checked)} />
1612
<div className='reblock h-8 w-14 rounded-full bg-meta-9 dark:bg-[#5A616B]'></div>
1713
<div
1814
className={cn('absolute left-1 top-1 h-6 w-6 rounded-full bg-white dark:bg-gray-400 transition', {
@@ -23,6 +19,6 @@ const SwitcherOne = ({
2319
</label>
2420
</div>
2521
);
26-
};
22+
}
2723

2824
export default SwitcherOne;

template/app/src/admin/elements/forms/SwitcherTwo.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
import { ChangeEventHandler } from 'react';
1+
import { useId } from 'react';
22
import { cn } from '../../../client/cn';
33

4-
const SwitcherTwo = ({
5-
isOn,
6-
onChange,
7-
}: {
8-
isOn: boolean;
9-
onChange: ChangeEventHandler<HTMLInputElement>;
10-
}) => {
4+
function SwitcherTwo({ isOn, onChange }: { isOn: boolean; onChange: (value: boolean) => void }) {
5+
const id = useId();
6+
117
return (
128
<div>
13-
<label className='flex cursor-pointer select-none items-center'>
9+
<label htmlFor={id} className='flex cursor-pointer select-none items-center'>
1410
<div className='relative'>
15-
<input type='checkbox' id='toggle3' className='sr-only' onChange={onChange} />
11+
<input type='checkbox' id={id} className='sr-only' onChange={(e) => onChange(e.target.checked)} />
1612
<div className='block h-8 w-14 rounded-full bg-meta-9 dark:bg-[#5A616B]'></div>
1713
<div
1814
className={cn(
@@ -33,7 +29,7 @@ const SwitcherTwo = ({
3329
</label>
3430
</div>
3531
);
36-
};
32+
}
3733

3834
const XIcon = () => {
3935
return (

0 commit comments

Comments
 (0)