-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
158 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
VITE_SUPABASE_URL=http://127.0.0.1:54321 | ||
VITE_SUPABASE_ANON_KEY= | ||
VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { createFileRoute } from '@tanstack/react-router'; | ||
import { Header } from '../../components'; | ||
import { BasicIcon } from '../../components/icons/BasicIcon'; | ||
import { AuthGuard } from '../../utils/auth'; | ||
import { supabase } from '../../utils/supabase'; | ||
|
||
const styles = { | ||
container: { | ||
flex: 1, | ||
backgroundColor: '#333', | ||
}, | ||
searchSection: { | ||
display: 'flex', | ||
alignItems: 'center', | ||
padding: 4, | ||
backgroundColor: '#333', | ||
}, | ||
searchInput: { | ||
flex: 1, | ||
marginLeft: 8, | ||
marginRight: 8, | ||
backgroundColor: '#f0f0f0', | ||
borderRadius: 5, | ||
padding: 4, | ||
}, | ||
categories: { | ||
display: 'inline', | ||
padding: 5, | ||
}, | ||
categoryButton: { | ||
paddingLeft: 8, | ||
paddingRight: 8, | ||
margin: 2, | ||
backgroundColor: '#888', | ||
borderRadius: 12, | ||
color: 'black', | ||
}, | ||
grid: { | ||
padding: 10, | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
gap: 10, | ||
}, | ||
card: { | ||
width: '50%', | ||
marginBottom: 10, | ||
padding: 10, | ||
backgroundColor: '#555', | ||
borderRadius: 10, | ||
color: 'white', | ||
}, | ||
productName: { | ||
fontSize: 16, | ||
color: 'white', | ||
}, | ||
productInfo: { | ||
fontSize: 14, | ||
color: 'gray', | ||
}, | ||
icon: { | ||
alignSelf: 'flex-end', | ||
}, | ||
fab: { | ||
position: 'absolute', | ||
bottom: 20, | ||
right: 20, | ||
backgroundColor: '#6200ee', | ||
width: 60, | ||
height: 60, | ||
borderRadius: 30, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
}; | ||
|
||
export const Route = createFileRoute('/sales/add_sell')({ | ||
beforeLoad: AuthGuard, | ||
loader: async () => { | ||
const { data, error } = await supabase | ||
.from('sales') | ||
.select('*') | ||
if (error !== null) { | ||
throw error | ||
} | ||
|
||
return { sales: data } | ||
}, | ||
component: EventSale | ||
}) | ||
function EventSale() { | ||
const { sales } = Route.useLoaderData() | ||
return ( | ||
<> | ||
<Header /> | ||
<div style={styles.container}> | ||
<div style={styles.searchSection}> | ||
<BasicIcon size={24}> | ||
<circle cx="12" cy="12" r="14" /> | ||
</BasicIcon> | ||
<input style={styles.searchInput} placeholder="搜尋" /> | ||
<BasicIcon size={24}> | ||
<circle cx="12" cy="12" r="14" /> | ||
</BasicIcon> | ||
</div> | ||
<div style={styles.categories}> | ||
<button style={styles.categoryButton}>全部</button> | ||
<button style={styles.categoryButton}>五金</button> | ||
<button style={styles.categoryButton}>飲料</button> | ||
<button style={styles.categoryButton}>贈品</button> | ||
</div> | ||
<div style={styles.grid}> | ||
{ | ||
sales.map((p) => ( | ||
<div key={p.id} style={styles.card}> | ||
<h1 style={styles.productName}>{p.product}</h1> | ||
<p style={styles.productInfo}>價格: {p.price} 元</p> | ||
</div> | ||
)) | ||
}{ | ||
sales.map((p) => ( | ||
<div key={p.id} style={styles.card}> | ||
<h1 style={styles.productName}>{p.product}</h1> | ||
<p style={styles.productInfo}>價格: {p.price} 元</p> | ||
</div> | ||
)) | ||
} | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} | ||
|