structuring

This commit is contained in:
2025-02-19 20:23:34 +01:00
parent 4af62033c6
commit 4fa5d97ae9
10 changed files with 38 additions and 79 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ import {
import { PlusCircle, Trash } from 'lucide-react'; import { PlusCircle, Trash } from 'lucide-react';
import { format, parse } from 'date-fns'; import { format, parse } from 'date-fns';
import PostDialog, { today } from '@/components/postDialog'; import PostDialog, { today } from './postDialog';
import axios from 'axios'; import axios from 'axios';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { Schedule } from '@/utils'; import { Schedule } from '@/utils';
@@ -18,11 +18,11 @@ import { Button } from '@/components/ui/button';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { format } from 'date-fns'; import { format } from 'date-fns';
import { CalendarIcon } from 'lucide-react'; import { CalendarIcon } from 'lucide-react';
import { Calendar } from './ui/calendar'; import { Calendar } from '@/components/ui/calendar';
import TimeSelect from './timeSelect'; import TimeSelect from './timeSelect';
import { CalendarEventExternal } from '@schedule-x/calendar'; import { CalendarEventExternal } from '@schedule-x/calendar';
import { Textarea } from './ui/textarea'; import { Textarea } from '@/components/ui/textarea';
import { Label } from './ui/label'; import { Label } from '@/components/ui/label';
import { useState } from 'react'; import { useState } from 'react';
import axios from 'axios'; import axios from 'axios';
import { Schedule } from '@/utils'; import { Schedule } from '@/utils';
@@ -1,8 +1,8 @@
'use client'; 'use client';
import { PlatformKind } from '@/utils'; import { PlatformKind } from '@/utils';
import { Card, CardContent, CardHeader, CardTitle } from './ui/card'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { PlatformIcon } from './icons'; import { PlatformIcon } from '@/components/icons';
export default function AccountStatus({ export default function AccountStatus({
accounts, accounts,
@@ -1,7 +1,7 @@
'use client'; 'use client';
import { Checkbox } from './ui/checkbox'; import { Checkbox } from '@/components/ui/checkbox';
import { Card, CardContent, CardHeader, CardTitle } from './ui/card'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
export default function Ideas({ export default function Ideas({
ideas, ideas,
+5 -5
View File
@@ -1,7 +1,7 @@
import AccountStatus from '@/components/accountStatus'; import AccountStatus from './accountStatus';
import Engagement from '@/components/engagement'; import Engagement from './engagement';
import Ideas from '@/components/ideas'; import Ideas from './ideas';
import RecentPosts from '@/components/recentPosts'; import RecentPosts from './recentPosts';
import App from '@/components/app'; import App from '@/components/app';
import { Calendar } from '@/components/ui/calendar'; import { Calendar } from '@/components/ui/calendar';
import { cookies } from 'next/headers'; import { cookies } from 'next/headers';
@@ -12,7 +12,7 @@ async function getSession(sessionId: string) {
try { try {
return ( return (
await axios.get(`http:/localhost:3000/api/session/?id=${sessionId}`) await axios.get(`http:/localhost:3000/api/session/?id=${sessionId}`)
).data; ).data.dashboard;
} catch { } catch {
redirect('/login'); redirect('/login');
} }
@@ -1,6 +1,6 @@
import { PlatformKind } from '@/utils'; import { PlatformKind } from '@/utils';
import { Card, CardContent, CardHeader, CardTitle } from './ui/card'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { PlatformIcon } from './icons'; import { PlatformIcon } from '@/components/icons';
import { format } from 'date-fns'; import { format } from 'date-fns';
export default function RecentPosts({ export default function RecentPosts({
+23 -22
View File
@@ -16,30 +16,27 @@ export default function Login() {
const [email, setEmail] = useState(''); const [email, setEmail] = useState('');
const [password, setPassword] = useState(''); const [password, setPassword] = useState('');
const handleLogin = () => { const handleLogin = async () => {
async () => { try {
try { const { sessionId } = (
const { sessionId } = ( await axios.post('/api/session/', {
await axios.post('/api/session/', { email,
email, password,
password, })
}) ).data;
).data;
cookies.set('session_id', sessionId); cookies.set('session_id', sessionId);
router.replace('/dashboard'); router.replace('/dashboard');
} catch (err: any) { } catch (err: any) {
toast({ toast({
title: 'Uh oh! Something went wrong.', title: 'Uh oh! Something went wrong.',
description: err.response description: err.response
? err.response.data.message ? err.response.data.message
: String(err), : String(err),
}); });
} }
};
}; };
return ( return (
<div className="bg-white dark:bg-black w-full h-screen flex justify-center items-center"> <div className="bg-white dark:bg-black w-full h-screen flex justify-center items-center">
<div className="text-center"> <div className="text-center">
@@ -60,7 +57,11 @@ export default function Login() {
type="password" type="password"
placeholder="Your password" placeholder="Your password"
onChange={(event) => setPassword(event.target.value)} onChange={(event) => setPassword(event.target.value)}
onClick={handleLogin} onKeyDown={async (e) => {
if (e.key === 'Enter') {
await handleLogin();
}
}}
/> />
<Button className="mt-5 w-80 mx-auto" onClick={handleLogin}> <Button className="mt-5 w-80 mx-auto" onClick={handleLogin}>
-42
View File
@@ -1,47 +1,5 @@
import { PlatformKind } from '@/utils'; import { PlatformKind } from '@/utils';
export function XMark() {
return (
<svg
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="xmark"
className="svg-inline--fa fa-xmark text-red-500 mr-2"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 384 512"
width="14"
>
<path
fill="currentColor"
d="M377 105c9.4-9.4 9.4-24.6 0-33.9l-22.6-22.6c-9.4-9.4-24.6-9.4-33.9 0L192 177.9 63.4 48.5c-9.4-9.4-24.6-9.4-33.9 0L6.9 71.1c-9.4 9.4-9.4 24.6 0 33.9L135.3 256 6.9 377c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0L192 334.1 320.6 463.5c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L248.7 256 377 105z"
></path>
</svg>
);
}
export function Check() {
return (
<svg
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="check"
className="svg-inline--fa fa-check text-green-500 mr-2"
role="img"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 448 512"
width="14"
>
<path
fill="currentColor"
d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"
></path>
</svg>
);
}
interface PlatformProps extends React.SVGProps<SVGSVGElement> { interface PlatformProps extends React.SVGProps<SVGSVGElement> {
platform: PlatformKind; platform: PlatformKind;
} }