Fluxos diversos

This commit is contained in:
Lucas Santana 2024-12-19 18:33:01 -03:00
parent fd908391bd
commit f182fc72fd
9 changed files with 711 additions and 129 deletions

View File

@ -1,10 +1,14 @@
<!doctype html>
<html lang="en">
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/book.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<meta name="description" content="Histórias Mágicas - Plataforma educacional de histórias interativas para escolas" />
<title>Histórias Mágicas | Educação através de histórias interativas</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<div id="root"></div>

712
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,27 +6,31 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint .",
"preview": "vite preview"
"preview": "vite preview",
"typecheck": "tsc --noEmit",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"format": "prettier --write \"src/**/*.{ts,tsx}\""
},
"dependencies": {
"@supabase/supabase-js": "^2.39.7",
"lucide-react": "^0.344.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"@supabase/supabase-js": "^2.39.7"
"react-router-dom": "^6.28.0",
"resend": "^3.2.0"
},
"devDependencies": {
"@eslint/js": "^9.9.1",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@types/react": "^18.3.17",
"@types/react-dom": "^18.3.5",
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.18",
"autoprefixer": "^10.4.20",
"eslint": "^9.9.1",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.11",
"globals": "^15.9.0",
"postcss": "^8.4.35",
"tailwindcss": "^3.4.1",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.17",
"typescript": "^5.5.3",
"typescript-eslint": "^8.3.0",
"vite": "^5.4.2"

View File

@ -5,19 +5,34 @@ import { StoryImage } from './story/StoryImage';
import { StoryControls } from './story/StoryControls';
interface Props {
theme: Theme;
user: User;
theme?: Theme;
user?: User;
demo?: boolean;
}
export function StoryViewer({ theme, user }: Props) {
export function StoryViewer({ theme, user, demo = false }: Props) {
const [isPlaying, setIsPlaying] = useState(false);
const [currentPage, setCurrentPage] = useState(0);
const story = {
title: `${user.name} e a Aventura ${theme.title}`,
const demoStory = {
title: "Uma Aventura Educacional",
pages: [
{
text: `Era uma vez, em um lugar muito especial do Brasil, vivia ${user.name}, uma criança muito curiosa de ${user.age} anos. Um dia, enquanto explorava ${theme.category === 'environment' ? 'a natureza' : 'sua cultura'}, algo mágico aconteceu...`,
text: "Bem-vindo à demonstração do Histórias Mágicas! Aqui você pode ver como funciona nossa plataforma...",
image: "https://images.unsplash.com/photo-1472162072942-cd5147eb3902?auto=format&fit=crop&q=80&w=800&h=600",
},
{
text: "Com histórias interativas e educativas, seus alunos aprenderão de forma divertida e envolvente...",
image: "https://images.unsplash.com/photo-1519681393784-d120267933ba?auto=format&fit=crop&q=80&w=800&h=600",
},
],
};
const story = demo ? demoStory : {
title: `${user?.name} e a Aventura ${theme?.title}`,
pages: [
{
text: `Era uma vez, em um lugar muito especial do Brasil, vivia ${user?.name}, uma criança muito curiosa de ${user?.age} anos...`,
image: `https://images.unsplash.com/photo-1472162072942-cd5147eb3902?auto=format&fit=crop&q=80&w=800&h=600`,
},
{

View File

@ -31,7 +31,13 @@ export function useDatabase() {
setLoading(true);
const { data, error } = await supabase
.from('teachers')
.select('*')
.select(`
id,
name,
email,
subject,
status
`)
.eq('school_id', schoolId);
if (error) throw error;
@ -45,6 +51,34 @@ export function useDatabase() {
}
};
const inviteTeacher = async (schoolId: string, teacherData: {
name: string;
email: string;
subject?: string;
message?: string;
}) => {
try {
setLoading(true);
const { data, error } = await supabase
.rpc('invite_teacher', {
p_school_id: schoolId,
p_name: teacherData.name,
p_email: teacherData.email,
p_subject: teacherData.subject || null,
p_message: teacherData.message || null
});
if (error) throw error;
return data;
} catch (err) {
setError('Erro ao enviar convite');
console.error(err);
return null;
} finally {
setLoading(false);
}
};
// Funções para turmas
const getClassesBySchool = async (schoolId: string) => {
try {
@ -202,6 +236,7 @@ export function useDatabase() {
getStoriesByStudent,
createStory,
updateStory,
addPageToStory
addPageToStory,
inviteTeacher,
};
}

View File

@ -4,7 +4,13 @@ const supabaseUrl = import.meta.env.VITE_SUPABASE_URL
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY
if (!supabaseUrl || !supabaseAnonKey) {
throw new Error('Supabase URL and Anon Key must be defined')
throw new Error('Variáveis de ambiente do Supabase não configuradas')
}
export const supabase = createClient(supabaseUrl, supabaseAnonKey)
export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
auth: {
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: true
}
})

View File

@ -1,10 +1,11 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import { App } from './App';
import { RouterProvider } from 'react-router-dom';
import { router } from './routes';
import './index.css';
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
<RouterProvider router={router} />
</StrictMode>
);

View File

@ -2,7 +2,11 @@
export default {
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {},
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
},
},
plugins: [],
};

View File

@ -5,12 +5,17 @@ import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
optimizeDeps: {
include: ['@supabase/supabase-js']
include: ['@supabase/supabase-js', 'resend']
},
build: {
commonjsOptions: {
include: [/node_modules/],
transformMixedEsModules: true
}
},
resolve: {
alias: {
'node-fetch': 'isomorphic-fetch'
}
}
});