Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make invitation code readonly #89

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions routes/~_dashboard/~patients/PatientForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { type User } from '@/modules/firebase/models'
export const patientFormSchema = z.object({
email: z.string().email().min(1, 'Email is required'),
displayName: z.string(),
invitationCode: z.string(),
clinician: z.string().min(1, 'Clinician is required'),
dateOfBirth: z.date().optional(),
})
Expand All @@ -41,10 +40,7 @@ interface PatientFormProps {
email: string | null
}>
userInfo?: Pick<UserInfo, 'email' | 'displayName' | 'uid'>
user?: Pick<
User,
'organization' | 'invitationCode' | 'clinician' | 'dateOfBirth'
>
user?: Pick<User, 'organization' | 'clinician' | 'dateOfBirth'>
onSubmit: (data: PatientFormSchema) => Promise<void>
clinicianPreselectId?: string
}
Expand All @@ -62,7 +58,6 @@ export const PatientForm = ({
defaultValues: {
email: userInfo?.email ?? '',
displayName: userInfo?.displayName ?? '',
invitationCode: user?.invitationCode ?? '',
clinician: user?.clinician ?? clinicianPreselectId ?? '',
dateOfBirth: user?.dateOfBirth ? new Date(user.dateOfBirth) : undefined,
},
Expand Down Expand Up @@ -100,14 +95,6 @@ export const PatientForm = ({
/>
)}
/>
{isEdit && (
<Field
control={form.control}
name="invitationCode"
label="Invitation code"
render={({ field }) => <Input {...field} />}
/>
)}
<Field
control={form.control}
name="clinician"
Expand Down
1 change: 1 addition & 0 deletions routes/~_dashboard/~patients/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
return {
lastActiveDate: user.lastActiveDate,
latestQuestionnaireDate: latestQuestionnaires.at(0)?.authored,
invitationCode: user.invitationCode,

Check warning on line 235 in routes/~_dashboard/~patients/utils.ts

View check run for this annotation

Codecov / codecov/patch

routes/~_dashboard/~patients/utils.ts#L235

Added line #L235 was not covered by tests
isInvitation: resourceType === 'invitation',
}
}
Expand Down
18 changes: 8 additions & 10 deletions routes/~_dashboard/~patients/~$id/UserActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
// SPDX-License-Identifier: MIT
//

import {
Card,
CardHeader,
CardTitle,
} from '@stanfordspezi/spezi-web-design-system/components/Card'
import { Card } from '@stanfordspezi/spezi-web-design-system/components/Card'
import { formatNilDateTime } from '@stanfordspezi/spezi-web-design-system/utils/date'
import { Clock, FileQuestion, Mail } from 'lucide-react'
import { Clock, FileQuestion, Mail, BookLock } from 'lucide-react'
import { type ReactNode } from 'react'
import { type UserActivity as UserActivityType } from '@/routes/~_dashboard/~patients/utils'

Expand All @@ -38,11 +34,13 @@

export const UserActivity = ({ activity }: UserActivityProps) => (
<Card className="xl:min-w-max xl:self-start">
<CardHeader>
<CardTitle>User activity</CardTitle>
</CardHeader>
<div className="px-5 pb-4 marker:text-primary">
<div className="px-5 py-4 marker:text-primary">

Check warning on line 37 in routes/~_dashboard/~patients/~$id/UserActivity.tsx

View check run for this annotation

Codecov / codecov/patch

routes/~_dashboard/~patients/~$id/UserActivity.tsx#L37

Added line #L37 was not covered by tests
<ul className="flex list-disc flex-col gap-4">
<ActivityRow
icon={<BookLock className="size-5" />}
label="Invitation code"
value={activity.invitationCode}
/>

Check warning on line 43 in routes/~_dashboard/~patients/~$id/UserActivity.tsx

View check run for this annotation

Codecov / codecov/patch

routes/~_dashboard/~patients/~$id/UserActivity.tsx#L39-L43

Added lines #L39 - L43 were not covered by tests
{activity.isInvitation && (
<ActivityRow
icon={<Mail className="size-5" />}
Expand Down
1 change: 0 additions & 1 deletion routes/~_dashboard/~patients/~$id/~index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ const PatientPage = () => {
email: form.email,
}
const userData = {
invitationCode: form.invitationCode,
clinician: form.clinician,
organization: clinician.organization,
dateOfBirth: form.dateOfBirth?.toISOString() ?? null,
Expand Down
Loading