rename draft to unlisted

This commit is contained in:
2025-11-28 20:14:00 -03:00
parent a74334b69c
commit c48f289514
8 changed files with 47 additions and 14 deletions

View File

@@ -53,8 +53,7 @@ class Course(BaseModel):
name: str name: str
access_period: int access_period: int
cert: Cert cert: Cert
draft: bool = False unlisted: bool = False
demo: bool = False
rawfile: bytes | None = None rawfile: bytes | None = None
@@ -88,7 +87,7 @@ def put_course(course_id: str):
update_expr='SET #name = :name, \ update_expr='SET #name = :name, \
access_period = :access_period, \ access_period = :access_period, \
cert = :cert, \ cert = :cert, \
draft = :draft, \ unlisted = :unlisted, \
updated_at = :updated_at', updated_at = :updated_at',
expr_attr_names={ expr_attr_names={
'#name': 'name', '#name': 'name',
@@ -97,7 +96,7 @@ def put_course(course_id: str):
':name': course.name, ':name': course.name,
':cert': course.cert.model_dump(), ':cert': course.cert.model_dump(),
':access_period': course.access_period, ':access_period': course.access_period,
':draft': course.draft, ':unlisted': course.unlisted,
':updated_at': now(), ':updated_at': now(),
}, },
cond_expr='attribute_exists(sk)', cond_expr='attribute_exists(sk)',

View File

@@ -1,8 +1,12 @@
from typing import Annotated
from aws_lambda_powertools.event_handler.api_gateway import Router from aws_lambda_powertools.event_handler.api_gateway import Router
from aws_lambda_powertools.event_handler.exceptions import ( from aws_lambda_powertools.event_handler.exceptions import (
NotFoundError, NotFoundError,
) )
from aws_lambda_powertools.event_handler.openapi.params import Body
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
from layercake.extra_types import CpfStr, NameStr
from boto3clients import dynamodb_client from boto3clients import dynamodb_client
from config import USER_TABLE from config import USER_TABLE
@@ -23,3 +27,11 @@ def get_user(user_id: str):
KeyPair(user_id, '0'), KeyPair(user_id, '0'),
exc_cls=NotFoundError, exc_cls=NotFoundError,
) )
@router.patch('/<user_id>')
def update(
user_id: str,
name: Annotated[NameStr, Body(embed=True)],
cpf: Annotated[CpfStr, Body(embed=True)],
): ...

View File

@@ -52,7 +52,7 @@ export async function loader({ context, request, params }: Route.LoaderArgs) {
const courses = createSearch({ const courses = createSearch({
index: 'saladeaula_courses', index: 'saladeaula_courses',
sort: ['created_at:desc'], sort: ['created_at:desc'],
filter: 'draft NOT EXISTS', filter: 'unlisted NOT EXISTS',
hitsPerPage: 100, hitsPerPage: 100,
env: context.cloudflare.env env: context.cloudflare.env
}) })

View File

@@ -13,7 +13,8 @@ export default [
route('settings', 'routes/settings/layout.tsx', [ route('settings', 'routes/settings/layout.tsx', [
index('routes/settings/profile.tsx'), index('routes/settings/profile.tsx'),
route('emails', 'routes/settings/emails/index.tsx'), route('emails', 'routes/settings/emails/index.tsx'),
route('password', 'routes/settings/password.tsx') route('password', 'routes/settings/password.tsx'),
route('orgs', 'routes/settings/orgs.tsx')
]), ]),
route('konviva', 'routes/konviva.ts'), route('konviva', 'routes/konviva.ts'),
route('player/:id', 'routes/player.tsx'), route('player/:id', 'routes/player.tsx'),

View File

@@ -50,6 +50,7 @@ const links = [
{ to: '', title: 'Perfil', end: true }, { to: '', title: 'Perfil', end: true },
{ to: 'emails', title: 'Emails' }, { to: 'emails', title: 'Emails' },
{ to: 'password', title: 'Senha' } { to: 'password', title: 'Senha' }
// { to: 'orgs', title: 'Empresas' }
] ]
export default function Layout({ loaderData: { data } }: Route.ComponentProps) { export default function Layout({ loaderData: { data } }: Route.ComponentProps) {

View File

@@ -0,0 +1,20 @@
import {
Card,
CardDescription,
CardHeader,
CardTitle
} from '@repo/ui/components/ui/card'
export default function Route() {
return (
<Card>
<CardHeader>
<CardTitle className="text-lg">Empresas</CardTitle>
<CardDescription>
As empresas associadas à sua conta poderão disponibilizar cursos para
você enquanto estiverem associadas.
</CardDescription>
</CardHeader>
</Card>
)
}

View File

@@ -64,7 +64,7 @@ const formSchema = z
rawfile: z rawfile: z
.instanceof(File, { message: 'Anexe um arquivo HTML' }) .instanceof(File, { message: 'Anexe um arquivo HTML' })
.optional(), .optional(),
draft: z.boolean() unlisted: z.boolean()
}) })
.refine( .refine(
(data) => { (data) => {
@@ -92,7 +92,7 @@ export type Course = {
name: string name: string
access_period: number access_period: number
cert?: Cert cert?: Cert
draft?: boolean unlisted?: boolean
} }
export function meta({}: Route.MetaArgs) { export function meta({}: Route.MetaArgs) {
@@ -164,7 +164,7 @@ function Editing() {
const form = useForm({ const form = useForm({
resolver: zodResolver(formSchema), resolver: zodResolver(formSchema),
defaultValues: { defaultValues: {
draft: false, unlisted: false,
given_cert: !!course?.cert, given_cert: !!course?.cert,
never_expires: !course?.cert?.exp_interval, never_expires: !course?.cert?.exp_interval,
...course ...course
@@ -373,7 +373,7 @@ function Editing() {
<FormField <FormField
control={form.control} control={form.control}
name="draft" name="unlisted"
render={({ field: { onChange, value, ...field } }) => ( render={({ field: { onChange, value, ...field } }) => (
<FormItem className="flex items-center gap-2"> <FormItem className="flex items-center gap-2">
<FormControl> <FormControl>
@@ -383,7 +383,7 @@ function Editing() {
{...field} {...field}
/> />
</FormControl> </FormControl>
<FormLabel>Ocultar o curso no catálogo</FormLabel> <FormLabel>Não listar no catálogo de cursos</FormLabel>
</FormItem> </FormItem>
)} )}
/> />

View File

@@ -134,14 +134,14 @@ function List({ term, hits = [] }: { term: string; hits: Course[] }) {
) )
} }
function Course({ id, name, access_period, cert, draft }: Course) { function Course({ id, name, access_period, cert, unlisted }: Course) {
return ( return (
<NavLink to={`/edit/${id}`} className="hover:scale-105 transition"> <NavLink to={`/edit/${id}`} className="hover:scale-105 transition">
{({ isPending }) => ( {({ isPending }) => (
<Card <Card
className={cn( className={cn(
'overflow-hidden relative h-96', 'overflow-hidden relative h-96',
draft && 'border-dashed' unlisted && 'border-dashed'
)} )}
> >
{isPending && ( {isPending && (
@@ -188,7 +188,7 @@ function Course({ id, name, access_period, cert, draft }: Course) {
</li> </li>
)} )}
{draft && ( {unlisted && (
<li className="flex items-center"> <li className="flex items-center">
<HatGlassesIcon className="size-4" /> <HatGlassesIcon className="size-4" />
</li> </li>