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

Rinarepeat #9

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
59 changes: 59 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
client id = 205724776903-1dves8h84q74td4jthh1ra28f0rjpkvt.apps.googleusercontent.com
client secret = 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

[useHook](https://usehooks.com/)

step by step midtrans
- buka midtrans
- pilih environment -> Sandbox
- buka setting
- access keys
[integration guide midtrans](https://docs.midtrans.com/docs/snap-snap-integration-guide)
- Built-in interface (SNAP)
[nanoid](https://www.npmjs.com/package/nanoid)


react redux
npm i redux

redux toolkit


- skeleton code
- default branch ke dev
- clone

//? mau ngoding
- git checkout -b 'nama feature baru'
- ngoding
- git add . ,git commit, git push origin nama feature tsb

//? github gui
- new pull request
- compare dev <- feature tsb
- pr, merge

//? lanjut ngoding
- git checkout dev
- git pull origin dev
- git checkout -b 'nama feature baru'
- ngoding
- git add . ,git commit, git push origin nama feature tsb

//? github gui
- new pull request
- compare dev <- feature tsb
- pr, merge

//? lanjut ngoding
- git checkout dev
- git pull origin dev
- git checkout -b 'nama feature baru'
- ngoding
- git add . ,git commit, git push origin nama feature tsb

//? dst

//? akhir ketika mau deploy
- pr, compare main <- dev
- merge ke main
162 changes: 162 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,164 @@
[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-718a45dd9cf7e7f842a935f5ebbe5719a5e09af4491e668f4dbf3b35d5cca122.svg)](https://classroom.github.com/online_ide?assignment_repo_id=13208385&assignment_repo_type=AssignmentRepo)
# Individual Project Phase 2

### endpoints
- `POST /register`
- `POST /login`

- `GET /foods`
- `GET /carts`
- `PATCH /users/me/upgrade`
- `GET /payment/midtrans/token`
- `POST /foods/:id`
- `DELETE /carts/:id`

### POST /register
- Request
- body:
```json
{
"name": "string",
"email": "string",
"password": "string"
}
```

- Response (201 - Created)
```json
{
"id": "integer",
"name": "string",
"email": "string"
}
```

Response (400 - BadRequest)
```json
{
"message": "Email must be email format"
},
OR
{
"message": "Email is required"
},
OR
{
"message": "Password is required"
},
OR
{
"message": "Password must be at least 6 characters"
}
```

### POST /login
- Request
- body:
```json
{
"email": "string",
"password": "string"
}
```

Response (200 - OK)
```json
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NCwiaWF0IjoxNzA1NTc1MzAzfQ.4_YsasXUrapTp-enB6Hb_5i-1oSzcVOqyw6icsLMnD4"
}
```

Response (401 - Unauthorized)
```json
{
"message": "Invalid email/password"
},
OR
{
"message": "Invalid email/password"
}
```

### GET /foods
Response (200 - Ok)
```json
[
{
"id": 1,
"name": "Margherita",
"veg": true,
"price": 35000,
"description": "Cheese",
"quantity": 1,
"img": "https://api.pizzahut.io/v1/content/en-in/in-1/images/pizza/margherita.90f9451fd66871fb6f9cf7d506053f18.1.jpg?width=550",
"categoryId": 7,
"createdAt": "2024-01-16T09:55:18.472Z",
"updatedAt": "2024-01-16T09:55:18.472Z"
},
...
]
```

### GET /carts
Response (200 - Ok)
```json
[
{
"id": 7,
"name": "Margherita",
"price": 35000,
"createdAt": "2024-01-18T06:43:35.567Z",
"updatedAt": "2024-01-18T06:43:35.567Z"
}
]
```

### POST /foods/:id
- Request:
- params
```json
{
"id": "integer"
}
```

Response (201 - Created)
```json
{
"id": 8,
"name": "Margherita",
"price": 35000,
"updatedAt": "2024-01-18T11:06:05.033Z",
"createdAt": "2024-01-18T11:06:05.033Z"
}
```

Response (404 - Not Found)
```json
{
"message": "Data not found"
}
```

### DELETE /carts/:id
Request:
- params
```json
{
"id": "integer"
}
```

Response (200 - Ok)
```json
{
"message": "Success delete item"
}
```

Response (404 - Not Found)
```json
{
"message": "Data not found"
}
```
20 changes: 20 additions & 0 deletions client/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
4 changes: 4 additions & 0 deletions client/.firebase/hosting.ZGlzdA.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
index.html,1705632859112,b4edfe9e425ed8c25a7497085ed7f61a7a732cdd1c96a58c0d54f4648523bf76
vite.svg,1701838868400,699a02e0e68a579f687d364bbbe7633161244f35af068220aee37b1b33dfb3c7
assets/index-mIr2F93V.css,1705632859112,fd52cd7dc4034f7652e02d18c9f96aed76786f1eb22cf5421e6ca9a13ae35c02
assets/index-3cSxATYZ.js,1705632859112,fbd9a270f5a8776d7679f784d652b32685d8c514e39431c02d21de781f08449a
5 changes: 5 additions & 0 deletions client/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "iprepeat65-rina"
}
}
28 changes: 28 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?


# Contentlayer
.contentlayer
8 changes: 8 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# React + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
16 changes: 16 additions & 0 deletions client/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
36 changes: 36 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
<link
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
rel="stylesheet"
/>
<script src="https://cdn.tailwindcss.com"></script>
<link
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
rel="stylesheet"
/>
<link
href="https://cdn.jsdelivr.net/npm/daisyui@4.4.19/dist/full.min.css"
rel="stylesheet"
type="text/css"
/>
<script src="https://cdn.tailwindcss.com"></script>
<!-- script midtrans -->
<script type="text/javascript"
src="https://app.sandbox.midtrans.com/snap/snap.js"
data-client-key="SB-Mid-client-c4B7gUt3bKXq3cMG"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
</head>
<body>
<div id="root"></div>
<script src="https://accounts.google.com/gsi/client" async></script>
<script type="module" src="/src/main.jsx"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
</body>
</html>
Loading