+ )
+}
+
+export default CreateLesson
+
+
+export const getServerSideProps: GetServerSideProps = async (ctx) => {
+ const courseId = ctx.params?.cid as string
+ return {
+ props: {
+ courseId
+ }
+ }
+}
\ No newline at end of file
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index b8e9030..94b6255 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -48,6 +48,7 @@ model User {
password String?
roles String[]
stripe_account_id String?
+ Course Course[]
}
model VerificationToken {
@@ -58,3 +59,26 @@ model VerificationToken {
@@unique([identifier, token])
}
+
+model Course {
+ id String @id @default(auto()) @map("_id") @db.ObjectId
+ name String
+ description String
+ price Float @default(9.99)
+ paid Boolean @default(true)
+ category String
+ imagePreview String
+ user User @relation(fields: [userId], references: [id])
+ userId String @db.ObjectId
+ Lesson Lesson[]
+}
+
+model Lesson {
+ id String @id @default(auto()) @map("_id") @db.ObjectId
+ name String
+ description String
+ video String
+ courseId String @db.ObjectId
+ course Course @relation(fields: [courseId], references: [id])
+ free_preview Boolean? @default(false)
+}
diff --git a/services/api/axios.ts b/services/api/axios.ts
index fd8edb8..14a1553 100644
--- a/services/api/axios.ts
+++ b/services/api/axios.ts
@@ -2,5 +2,6 @@ import Axios from 'axios'
export const axios = Axios.create({
- baseURL:"http://localhost:3000/api"
+ baseURL:"http://localhost:3000/api",
+ withCredentials:true
})
\ No newline at end of file
diff --git a/services/api/index.ts b/services/api/index.ts
index e69de29..2298f9f 100644
--- a/services/api/index.ts
+++ b/services/api/index.ts
@@ -0,0 +1,3 @@
+export * from './auth'
+export * from './instructor'
+export * from './stripe'
\ No newline at end of file
diff --git a/services/api/instructor/index.ts b/services/api/instructor/index.ts
index 77d5bb0..3009fc7 100644
--- a/services/api/instructor/index.ts
+++ b/services/api/instructor/index.ts
@@ -1,13 +1,27 @@
import { axios } from '../axios'
-
+import { Course } from '@prisma/client'
export const makeInstructorApi = async () => {
- const res = await axios.post('/instructor/make-instructor')
+ const res = await axios.post('/stripe/make-instructor')
return res.data
}
-export const varifyInstructorApi = async () => {
- const res = await axios.post("/instructor/make-instructor")
+export interface CreateCourseDto extends Omit {
+ imagePreview: File
+}
+
+
+export const createCourseApi = async (data: CreateCourseDto) => {
+ const formdata = new FormData()
+ Object.entries(data).forEach(([key, value]) => {
+ formdata.append(`${key}`, value)
+ })
+ const res = await axios.post("/instructor/createcourse", formdata)
+}
+
+export const getMyCreatedCoursesApi = async () => {
+ const res = await axios.get("/instructor/get-my-created-courses")
return res.data
-}
\ No newline at end of file
+}
+
diff --git a/services/api/stripe/index.ts b/services/api/stripe/index.ts
new file mode 100644
index 0000000..495de8a
--- /dev/null
+++ b/services/api/stripe/index.ts
@@ -0,0 +1,8 @@
+import { axios } from '../axios'
+
+
+
+export const verifyInstructorApi = async () => {
+ const { data } = await axios.post("/stripe/verify-instructor")
+ return data
+}
\ No newline at end of file
diff --git a/styles/globals.css b/styles/globals.css
index 0a26ec3..4b97ab6 100644
--- a/styles/globals.css
+++ b/styles/globals.css
@@ -7,6 +7,5 @@
a {
color: blue;
border-bottom: 1px solid blue;
- padding-bottom: 2px;
font-size: 0.7rem;
}
\ No newline at end of file
diff --git a/tailwind.config.js b/tailwind.config.js
index 4fa388f..5e89aeb 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -1,19 +1,45 @@
+const { violet, blackA, mauve, green } = require('@radix-ui/colors');
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
+ './pages/_app.{js,ts,jsx,tsx}',
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
'./app/**/*.{js,ts,jsx,tsx}',
'./ui/**/*.{js,ts,jsx,tsx}',
+ './layouts/**/*.{js,ts,jsx,tsx}',
+ './molecules/**/*.{js,ts,jsx,tsx}',
],
theme: {
extend: {
+ colors: {
+ ...mauve,
+ ...violet,
+ ...green,
+ ...blackA,
+ },
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
'gradient-conic':
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
},
+ keyframes: {
+ overlayShow: {
+ from: { opacity: 0 },
+ to: { opacity: 1 },
+ },
+ contentShow: {
+ from: { opacity: 0, transform: 'translate(-50%, -48%) scale(0.96)' },
+ to: { opacity: 1, transform: 'translate(-50%, -50%) scale(1)' },
+ },
+ },
+ animation: {
+ overlayShow: 'overlayShow 150ms cubic-bezier(0.16, 1, 0.3, 1)',
+ contentShow: 'contentShow 150ms cubic-bezier(0.16, 1, 0.3, 1)',
+ },
},
},
- plugins: [],
+ plugins: [
+ require('@tailwindcss/line-clamp'),
+ ],
}
diff --git a/ui/Badge/Badge.tsx b/ui/Badge/Badge.tsx
new file mode 100644
index 0000000..c8ca2f9
--- /dev/null
+++ b/ui/Badge/Badge.tsx
@@ -0,0 +1,16 @@
+import clsx from 'clsx'
+import React from 'react'
+interface BadgeProps {
+ text: string
+ className?: string
+}
+export const Badge = ({
+ text, className
+}: BadgeProps) => {
+ return (
+
{text}
+ )
+}
\ No newline at end of file
diff --git a/ui/Badge/index.ts b/ui/Badge/index.ts
new file mode 100644
index 0000000..cfde89a
--- /dev/null
+++ b/ui/Badge/index.ts
@@ -0,0 +1 @@
+export * from './Badge'
\ No newline at end of file
diff --git a/ui/Button/Button.tsx b/ui/Button/Button.tsx
index bfb6049..05701b2 100644
--- a/ui/Button/Button.tsx
+++ b/ui/Button/Button.tsx
@@ -1,10 +1,19 @@
+import { String } from 'aws-sdk/clients/apigateway'
import React from 'react'
+import clsx from 'clsx'
interface IButton extends React.ButtonHTMLAttributes {
text: string
+ className?: String
}
-const Button = ({ text, ...props }: IButton) => {
+const Button = ({ text, className, ...props }: IButton) => {
return (
- {text}
+
+ {text}
+
)
}
diff --git a/ui/Dialog/Dialog.tsx b/ui/Dialog/Dialog.tsx
new file mode 100644
index 0000000..f84da8e
--- /dev/null
+++ b/ui/Dialog/Dialog.tsx
@@ -0,0 +1,35 @@
+import React from 'react'
+import * as RadiDialog from '@radix-ui/react-dialog'
+import clsx from 'clsx'
+interface DialogProps {
+ open: boolean,
+ onChange: (open: boolean) => void,
+ title?: string
+ children: React.ReactElement
+ className?: string
+}
+export const Dialog = ({ onChange, open, children, title, className }: DialogProps) => {
+ return (
+ { onChange(open) }}>
+
+
+
+ {
+ title ?
+
+ {title}
+
+ :
+ null
+ }
+ {children}
+
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/ui/Dialog/index.ts b/ui/Dialog/index.ts
new file mode 100644
index 0000000..aca62ab
--- /dev/null
+++ b/ui/Dialog/index.ts
@@ -0,0 +1 @@
+export * from './Dialog'
\ No newline at end of file
diff --git a/ui/Select/Select.tsx b/ui/Select/Select.tsx
new file mode 100644
index 0000000..0aee003
--- /dev/null
+++ b/ui/Select/Select.tsx
@@ -0,0 +1,7 @@
+import React from 'react'
+
+export const Select = () => {
+ return (
+
Select
+ )
+}
\ No newline at end of file
diff --git a/ui/Select/index.ts b/ui/Select/index.ts
new file mode 100644
index 0000000..ec5ec83
--- /dev/null
+++ b/ui/Select/index.ts
@@ -0,0 +1 @@
+export * from './Select'
\ No newline at end of file
diff --git a/ui/index.ts b/ui/index.ts
index fda236b..7c3a7c6 100644
--- a/ui/index.ts
+++ b/ui/index.ts
@@ -1,2 +1,5 @@
export * from './Input'
-export * from './Button'
\ No newline at end of file
+export * from './Button'
+export * from './Select'
+export * from './Badge'
+export * from './Dialog'
\ No newline at end of file
diff --git a/utils/currencyFormaterClient.ts b/utils/currencyFormaterClient.ts
new file mode 100644
index 0000000..b0bfdcb
--- /dev/null
+++ b/utils/currencyFormaterClient.ts
@@ -0,0 +1,11 @@
+interface CurrencyFormaterClientProps {
+ amount: number,
+ currency?: string
+}
+export const currencyFormaterClient = ({
+ amount,
+ currency = "USD"
+}: CurrencyFormaterClientProps) => {
+ let toreturn=`$${amount}`
+ return `${toreturn}`;
+}
\ No newline at end of file