#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int min_jumps(int nums[], int n)
{
if (n <= 1) {
return 0; // No jumps needed if the array has only one element
}
// Initialize variables
int jumps = 0;
int farthest = 0;
int current_end = 0;
for (int i = 0; i < n - 1; i++)
{
// Update the farthest we can reach
farthest = max(farthest, i + nums[i]);
// When we reach the end of the current range, we must jump
if (i == current_end)
{
jumps++;
current_end = farthest;
// If we can already reach the last index, break early
if (current_end >= n - 1)
{
break;
}
}
}
return jumps;
}
int main()
{
int n;
cout << "Enter the size of the array: ";
cin >> n;
int nums[n];
cout << "Enter the elements of the array: ";
for (int i = 0; i < n; i++)
{
cin >> nums[i];
}
int result = min_jumps(nums, n);
cout << "Minimum number of jumps to reach the last index: " << result << endl;
return 0;
}
ssh-keygen -t ed25519 -C "your_email@example.com"
public with sharing class ImpersonationUtil {
public static String getImpersonatorEmail() {
String query = 'SELECT CreatedById FROM AuthSession WHERE UsersId = :UserInfo.getUserId() AND SessionType = \'SubstituteUser\' ORDER BY CreatedDate DESC LIMIT 1';
AuthSession session = Database.query(query);
if (session != null) {
User creator = [SELECT Email FROM User WHERE Id = :session.CreatedById LIMIT 1];
return creator.Email;
}
return null;
}
}
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
// FAP nghĩa là find all path
vector<vector<int>> FAP(int A, int B, vector<vector<int>>& S) {
deque<vector<int>> dq;
vector<vector<int>> all;
dq.push_back({A});
while (!dq.empty()) {
vector<int> path = dq.front();
dq.pop_front();
int end = path.back();
if (end == B) {
all.push_back(path);
} else {
for (int i = 0; i < S[end].size(); i++) {
int nei = S[end][i];
if (find(path.begin(), path.end(), nei) == path.end()) {
vector<int> newpath = path;
newpath.push_back(nei);
dq.push_back(newpath);
}
}
}
}
// In tất cả các đường đi tìm được
cout << "Tất cả các đường đi từ " << A << " đến " << B << ":\n";
for (const auto& p : all) {
for (int i = 0; i < p.size(); i++) {
cout << p[i];
if (i < p.size() - 1) cout << " -> ";
}
cout << endl;
}
return all; // Trả về kết quả tìm được
}
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> S(n + 1); // Sử dụng vector 2D để lưu đồ thị
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
S[u].push_back(v);
S[v].push_back(u); // Đồ thị vô hướng
}
int A, B; // Đỉnh bắt đầu A và đỉnh đích B
cin >> A >> B;
vector<vector<int>> all = FAP(A, B, S);
vector<int> LT(n + 1, 0); // Khởi tạo mảng đếm với kích thước n+1
for (const auto& p : all) {
for (int i = 0; i < p.size(); i++) {
LT[p[i]]++;
}
}
int maxx = *max_element(LT.begin(), LT.end());
for (int i = 0; i < LT.size(); i++) {
if(i == A || i == B){
continue;
}
else if (LT[i] == maxx) {
cout << i << " ";
}
}
return 0;
}
$args = [ \
'title' => 'Test Recurring Event', \
'status' => 'publish', \
'start_date' => '2022-09-01 14:00:00', \
'end_date' => '2022-09-01 17:00:00', \
'timezone' => 'America/New_York', \
'recurrence' => 'RRULE:FREQ=DAILY;COUNT=10', \
];
$recurring_event = tribe_events()->set_args( $args )->create()->ID;
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":star: What's on in Melbourne this week! :star:"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "\n\n Hey Melbourne, happy Monday! Please see below for what's on this week. "
}
},
{
"type": "divider"
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Xero Café :coffee:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "\n :new-thing: *This week we are offering:* \n\n Chocolate Freckle Cookies, Brownies (GF), and Melting Moments Cookies \n\n *Weekly Café Special*: _Turmeric Latte_"
}
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": " Wednesday, 18th September :calendar-date-18:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "\n\n:footprint: *STEPtember Afternoon Tea*: From *2pm* in the L3 kitchen + breakout space! \n\n :walking:*STEPtember Office Walk:* Take 30 minutes to join in the STEPtember office walk\n\n:yoga2:*Wellbeing - Yin Yoga & Breathwork*: Confirm your spot <https://docs.google.com/spreadsheets/d/1iKMQtSaawEdJluOmhdi_r_dAifeIg0JGCu7ZSPuwRbo/edit?gid=0#gid=0/|*here*>. Please note we have a maximum of 15 participants per class, a minimum notice period of 4 hours is required if you can no longer attend."
}
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Thursday, 19th September :calendar-date-19:",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":breakfast: *Breakfast*: Provided by *Kartel Catering* from *8:30am - 10:30am* in the Wominjeka Breakout Space.\n\n"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Later this month:* We have our Grand Final Eve-Eve BBQ Social on the 26th of September! Make sure to wear your team colours (can be NRL or AFL) and come along for some fun! \n\nStay tuned to this channel for more details, and make sure you're subscribed to the <https://calendar.google.com/calendar/u/0?cid=Y19xczkyMjk5ZGlsODJzMjA4aGt1b3RnM2t1MEBncm91cC5jYWxlbmRhci5nb29nbGUuY29t|*Melbourne Social Calendar*> :party-wx:"
}
}
]
}
from bs4 import BeautifulSoup
import requests
import json
# Initialize the list to store API data
api = []
# Base URL for Yahoo News
base_url = 'https://www.yahoo.com'
# Fetch the main page
url = f'{base_url}/news/'
response = requests.get(url)
# Check if the request was successful
if response.status_code == 200:
soup = BeautifulSoup(response.text, 'html.parser')
# Find all news items
for news_item in soup.find_all('ul', class_='stream-items'):
for item in news_item.find_all('li', class_='stream-item'):
# Extract the article link
item_id = item.find('a', class_='js-content-viewer')
if item_id:
link = item_id.get('href')
full_link = f'{base_url}{link}'
# Fetch the article page
response2 = requests.get(full_link)
if response2.status_code == 200:
soup2 = BeautifulSoup(response2.text, 'html.parser')
# Extract article details
itemInfo = soup2.find('div', class_='caas-inner-body')
if itemInfo:
text1 = ''
for text in itemInfo.find_all('div', class_='caas-body'):
text1 += text.text
# Remove "View comments" from the text
text1 = text1.replace("View comments", "").strip()
# Extract additional details if available
image = item.find('img')['src'] if item.find('img') else ''
category = item.find('strong', class_='Tt(c)').text if item.find('strong', class_='Tt(c)') else ''
ell = item.find('span', class_='Ell').text if item.find('span', class_='Ell') else ''
title = item.find('h3', class_='stream-item-title').text if item.find('h3', class_='stream-item-title') else ''
description = item.find('p', class_='finance-ticker-fetch-success_D(n)').text if item.find('p', class_='finance-ticker-fetch-success_D(n)') else ''
# Append data to the api list
api.append({
'link': full_link,
'image': image,
'category': category,
'ell': ell,
'title': title,
'description': description,
'text': text1,
})
# Convert the api list to a JSON-formatted string
api_json = json.dumps(api, indent=4)
# Write the JSON data to a file
with open('news_data.json', 'w') as file:
file.write(api_json)
print("Data has been written to news_data.json")
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
// FAP nghĩa là find all path
void FAP(int A, int B, vector<vector<int>>& S){
deque<vector<int> > dq;
vector<vector<int>> all;
dq.push_back({A});
while (!dq.empty()) {
vector<int> path = dq.front();
dq.pop_front();
int end = path.back();
if (end == B) {
all.push_back(path);
} else {
for (int i = 0; i < S[end].size(); i++) {
int nei = S[end][i];
if (find(path.begin(), path.end(), nei) == path.end()) {
vector<int> newpath = path;
newpath.push_back(nei);
dq.push_back(newpath);
}
}
}
}
// In tất cả các đường đi tìm được
cout << "Tất cả các đường đi từ " << A << " đến " << B << ":\n";
for (const auto& p : all) {
for (int i = 0; i < p.size(); i++) {
cout << p[i];
if (i < p.size() - 1) cout << " -> ";
}
cout << endl;
}
}
int main() {
int n, m;
cin >> n >> m;
vector<vector<int> > S(n + 1); // Sử dụng vector 2D để lưu đồ thị
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
S[u].push_back(v);
S[v].push_back(u); // Đồ thị vô hướng
}
int A, B; // Đỉnh bắt đầu A và đỉnh đích B
cin >> A >> B;
FAP(A, B, S);
return 0;
}
#Open an elevated command prompt: Dism.exe /online /Cleanup-Image /StartComponentCleanup
package com.example.diceroller
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.Alignment
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.example.diceroller.ui.theme.DiceRollerTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
DiceRollerTheme {
DiceRollerApp()
}
}
}
}
@Composable
fun DiceRollerApp() {
DiceWithButtonAndImage()
}
@Composable
fun DiceWithButtonAndImage(modifier: Modifier = Modifier) {
var result by remember { mutableStateOf(1) }
val imageResource = when (result) {
1 -> R.drawable.dice_1
2 -> R.drawable.dice_2
3 -> R.drawable.dice_3
4 -> R.drawable.dice_4
5 -> R.drawable.dice_5
else -> R.drawable.dice_6
}
Column(
modifier = modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter = painterResource(imageResource),
contentDescription = result.toString()
)
Spacer(modifier = Modifier.height(16.dp))
Button(onClick = { result = (1..6).random() }) {
Text(text = "roll dice")
}
}
}
package com.example.sep11
import android.os.Bundle
import android.widget.Space
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.sep11.ui.theme.Sep11Theme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
//display()
//RowExample()
//HelloWorld()
//ImageExample()
simpleButton()
}
}
}
@Composable
fun display(){
Column( modifier = Modifier.padding(top = 150.dp, start = 60.dp)) {
Text(text = "Hello JetPackCompose",
fontSize = 35.sp,
color = Color.Red,
)
Text(text = "Python",
color = Color.Blue,
fontSize = 45.sp,
)
}
}
@Composable
fun RowExample(){
Row(modifier = Modifier.padding(all = 40.dp)){
Text(text = "Java", color = Color.Green, fontSize = 45.sp)
Text(text = "Kotlin", color = Color.Magenta, fontSize = 45.sp)
}
}
@Composable
fun HelloWorld(){
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Text(text = "Hello World", color = Color.Red,
fontWeight = FontWeight.Bold,
)
}
}
@Composable
fun ImageExample(){
Column{
Image(painter = painterResource(id = R.drawable.java),
contentDescription = "Java Logo",
modifier = Modifier.padding(top = 45.dp)
)
Spacer(modifier = Modifier.height(45.dp))
Text(text = "This is a Java Logo")
}
}
@Composable
fun simpleButton(){
val context = LocalContext.current
Button(onClick = {Toast.makeText(context,"Button Clicked", Toast.LENGTH_LONG).show() }) {
Text(text = "Click Here")
}
}
package com.example.diceroller
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.diceroller.ui.theme.DiceRollerTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
DiceRollerTheme {
DiceRollerApp()
}
}
}
}
@Preview
@Composable
fun DiceRollerApp() {
DiceWithButtonAndImage(modifier = Modifier
.fillMaxSize()
.wrapContentSize(Alignment.Center)
)
}
@Composable
fun DiceWithButtonAndImage(modifier: Modifier = Modifier) {
var result by remember { mutableStateOf(1) }
val imageResource = when (result) {
1 -> R.drawable.one
2 -> R.drawable.two
3 -> R.drawable.three
4 -> R.drawable.four
5 -> R.drawable.five
else -> R.drawable.six
}
Column(
modifier = modifier,
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter = painterResource(imageResource),
contentDescription = result.toString()
)
Spacer(modifier = Modifier.height(16.dp))
Button(onClick = { result = (1..6).random() }) {
Text(stringResource(R.string.roll))
}
}
}
package com.example.diceroller
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.Alignment
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.example.diceroller.ui.theme.DiceRollerTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
DiceRollerTheme {
DiceRollerApp()
}
}
}
}
@Composable
fun DiceRollerApp() {
DiceWithButtonAndImage()
}
@Composable
fun DiceWithButtonAndImage(modifier: Modifier = Modifier) {
var result by remember { mutableStateOf(1) }
val imageResource = when (result) {
1 -> R.drawable.dice_1
2 -> R.drawable.dice_2
3 -> R.drawable.dice_3
4 -> R.drawable.dice_4
5 -> R.drawable.dice_5
else -> R.drawable.dice_6
}
Column(
modifier = modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter = painterResource(imageResource),
contentDescription = result.toString()
)
Spacer(modifier = Modifier.height(16.dp))
Button(onClick = { result = (1..6).random() }) {
Text(text = "roll dice")
}
}
}
We cannot edit Wix Service pages - as its the inbuilt booking system. The client will have to build out pages with text and button and we can integrate the FH hyperlinks. We cannot build the content for them. The second page - we can add calendar. but please note FH embeds will NOT lightframe in WIx, due to the CMS limitations
$font-sizes: 12px 14px 16px 18px;
@for $i from 1 through length($font-sizes) {
.text-#{$i} {
font-size: nth($font-sizes, $i); // Retrieves the corresponding font size from the list
}
}
//generates
.text-1 {
font-size: 12px;
}
.text-2 {
font-size: 14px;
}
.text-3 {
font-size: 16px;
}
.text-4 {
font-size: 18px;
}
{data.map((item, index) => (
<div key={index} className=" overflow-hidden w-[50%] sm:w-1/2 md:w-1/3 lg:w-1/4">
{item.image_url && (
<div
className="w-[300px] relative h-56 bg-cover bg-center rounded-2xl before:bg-black/30 before:rounded-2xl before:absolute before:inset-0 before:content-['']"
style={{ backgroundImage: `url(${item.image_url})` }}
aria-label={item.title}
>
<div className="absolute bottom-0 right-0 p-4 flex justify-end items-end text-white w-full h-full ">
<p className="hover:underline font-semibold">{item.title}</p>
</div>
</div>
)}
</div>
))}
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":star: Boost Day is Here! :star:"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hey Wellington! \n\nIt's Boost Day!\n\nCheck out today's fantastic lineup: "
}
},
{
"type": "divider"
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":calendar-date-30: Tuesday, 30th July",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "\n:coffee: *Xero Café*: Café-style beverages and sweet treats.\n:clipboard: *Weekly Café Special*: _Caramel Mocha Latte_.\n:breakfast: *Breakfast*: Provided by *Simply Food* from *8AM - 10AM* in the All Hands.\n:massage:*Wellbeing - Massage*: Book a session <https://www.google.com/|*here*> to relax and unwind."
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "plain_text",
"text": "Have an amazing Boost Day, Wellington!\n\nLove,\n\nWX :party-wx: ",
"emoji": true
}
}
]
}
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":newspaper: STAY IN THE KNOW :newspaper:"
}
},
{
"type": "context",
"elements": [
{
"text": "*February 2024* | Monthly Spotlight",
"type": "mrkdwn"
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "FOR YOUR INFORMATION",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\nStay in the loop about what’s happening at the office such as upcoming visitors, onsite meetings, lunches, and more. Don’t miss out—click to subscribe below."
}
]
}
]
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":google-workspace-calendar: *DEN Happenings* calendar"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Click to subscribe",
"emoji": true
},
"value": "click_me_123",
"url": "https://calendar.google.com/calendar/u/0?cid=eGVyby5jb21fNXI3dXQzZTEyMGYxbWZqNWFwdGc5MHRtMzRAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ",
"action_id": "button-action"
}
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "invite-envelope"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "You're invited!",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/8",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "emoji",
"name": "scribble_heart_rainbow"
},
{
"type": "text",
"text": " Galentine's Day Happy Hour\n"
},
{
"type": "text",
"text": "2/13",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "emoji",
"name": "scribble_heart_rainbow"
},
{
"type": "text",
"text": " Galentine's Day Celebration\n "
},
{
"type": "emoji",
"name": "hatching_chick",
"unicode": "1f423"
},
{
"type": "text",
"text": " Nancy's Baby Shower\n\n"
},
{
"type": "emoji",
"name": "announcement-blue"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "ANNOUNCEMENT",
"style": {
"bold": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "emoji",
"name": "announcement-blue"
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/15",
"style": {
"code": true
}
},
{
"type": "text",
"text": " Our host for the US Stand Up is Taylor Maiman!\n"
}
]
},
{
"type": "rich_text_preformatted",
"border": 0,
"elements": [
{
"type": "text",
"text": "If you're keen on leading one, don't hesitate to reach out to wxhelp@xero.com!"
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "2/15",
"style": {
"code": true
}
},
{
"type": "text",
"text": " Happy Hour Trivia\n"
},
{
"type": "text",
"text": "2/19",
"style": {
"code": true
}
},
{
"type": "text",
"text": " President's Day - Office Closed\n"
},
{
"type": "emoji",
"name": "sticky-note"
},
{
"type": "text",
"text": " You may still access the office via access card"
}
]
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "date",
"unicode": "1f4c5"
},
{
"type": "text",
"text": " | "
},
{
"type": "text",
"text": "TUESDAY BREAKFAST SCHEDULE",
"style": {
"bold": true
}
},
{
"type": "text",
"text": " | "
},
{
"type": "emoji",
"name": "date",
"unicode": "1f4c5"
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/6",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "emoji",
"name": "chinese-lantern"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "OneFold",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/13",
"style": {
"code": true
}
},
{
"type": "text",
"text": " ",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "Pirate Chef\n\n"
},
{
"type": "text",
"text": "2/20",
"style": {
"code": true
}
},
{
"type": "text",
"text": " ",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "The Taqueria\n\n"
},
{
"type": "text",
"text": "2/27",
"style": {
"code": true
}
},
{
"type": "text",
"text": " ",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "Trez Banderas"
}
]
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "date",
"unicode": "1f4c5"
},
{
"type": "text",
"text": " | "
},
{
"type": "text",
"text": "THURSDAY LUNCH SCHEDULE",
"style": {
"bold": true
}
},
{
"type": "text",
"text": " | "
},
{
"type": "emoji",
"name": "date",
"unicode": "1f4c5"
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/1",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "Lazo Empanadas",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/8",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "emoji",
"name": "chinese-lantern"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "Zoe Mama",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/13",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "emoji",
"name": "star-party"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "Bonus Lunch: Pizza ",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/15",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "Chipotle",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/22",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "Hot Chicks Kitchen ",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/29",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "Adobo",
"style": {
"bold": true
}
}
]
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_quote",
"elements": [
{
"type": "text",
"text": "WX offers comprehensive event planning services, including:"
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "\n"
}
]
},
{
"type": "rich_text_list",
"style": "bullet",
"indent": 0,
"border": 0,
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Assistance with logistics and coordination "
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Access to a network of vendors for catering, supply ordering, etc."
}
]
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "\nNote: Even if you don’t need our assistance but are using the office space, kindly inform WX."
}
]
}
]
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": ":pushpin: Have something important to add to our calendar? Get in touch with us at wxhelp@xero.com and let us know. We're here to help!"
}
]
}
]
}
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":newspaper: STAY IN THE KNOW :newspaper:"
}
},
{
"type": "context",
"elements": [
{
"text": "*February 2024* | Monthly Spotlight",
"type": "mrkdwn"
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "FOR YOUR INFORMATION",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\nStay in the loop about what’s happening at the office such as upcoming visitors, onsite meetings, lunches, and more. Don’t miss out—click to subscribe below."
}
]
}
]
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":google-workspace-calendar: *NYC Happenings* calendar"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Click to subscribe",
"emoji": true
},
"value": "click_me_123",
"url": "https://calendar.google.com/calendar/u/0?cid=Y19iMzQyMGZiNWFjMDU5ZTFlMDM2ZGJkMjEwOTBhODc1YmI3YjJlYzQ3NWY3MTRmZWNjZGNlZjMwNDkzNGQ0ODA2QGdyb3VwLmNhbGVuZGFyLmdvb2dsZS5jb20",
"action_id": "button-action"
}
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "office-building"
},
{
"type": "text",
"text": " | "
},
{
"type": "text",
"text": "Building Announcements ",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "| "
},
{
"type": "emoji",
"name": "office-building"
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/13",
"style": {
"code": true
}
},
{
"type": "text",
"text": " Would you like to be our Valentine? Join\nus at the lobby for some sweet treats!\n"
},
{
"type": "text",
"text": "2/19",
"style": {
"code": true
}
},
{
"type": "text",
"text": " President's Day, Property Management Office will be closed"
}
]
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "announcement-blue"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "ANNOUNCEMENT",
"style": {
"bold": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "emoji",
"name": "announcement-blue"
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/15",
"style": {
"code": true
}
},
{
"type": "text",
"text": " Our host for the US Stand Up is Taylor Maiman!\n"
}
]
},
{
"type": "rich_text_preformatted",
"border": 0,
"elements": [
{
"type": "text",
"text": "If you're keen on leading one, don't hesitate to reach out to wxhelp@xero.com!"
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "2/21 & 2/22",
"style": {
"code": true
}
},
{
"type": "text",
"text": " Leadership Onsite"
}
]
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "date",
"unicode": "1f4c5"
},
{
"type": "text",
"text": " | "
},
{
"type": "text",
"text": "THURSDAY LUNCH SCHEDULE",
"style": {
"bold": true
}
},
{
"type": "text",
"text": " | "
},
{
"type": "emoji",
"name": "date",
"unicode": "1f4c5"
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/8",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "emoji",
"name": "chinese-lantern"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "Ollie's Sichuan",
"style": {
"bold": true,
"italic": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/15",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "Lenwich",
"style": {
"bold": true,
"italic": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/22",
"style": {
"code": true
}
},
{
"type": "text",
"text": " Chopt Creative Salad Co",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/29",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "Sophie's Cuban Cuisine",
"style": {
"bold": true
}
}
]
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_quote",
"elements": [
{
"type": "text",
"text": "WX offers comprehensive event planning services, including:"
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "\n"
}
]
},
{
"type": "rich_text_list",
"style": "bullet",
"indent": 0,
"border": 0,
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Assistance with logistics and coordination "
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Access to a network of vendors for catering, supply ordering, etc."
}
]
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "\nNote: Even if you don’t need our assistance but are using the office space, kindly inform WX."
}
]
}
]
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": ":pushpin: Have something important to add to our calendar? Get in touch with us at wxhelp@xero.com and let us know. We're here to help!"
}
]
}
]
}
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":newspaper: STAY IN THE KNOW :newspaper:"
}
},
{
"type": "context",
"elements": [
{
"text": "*February 2024* | Monthly Spotlight",
"type": "mrkdwn"
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "FOR YOUR INFORMATION",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\nStay in the loop about what’s happening at the office such as upcoming visitors, onsite meetings, lunches, and more. Don’t miss out—click to subscribe below."
}
]
}
]
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":google-workspace-calendar: *SFO Happenings* calendar"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Click to subscribe",
"emoji": true
},
"value": "click_me_123",
"url": "https://calendar.google.com/calendar/u/0?cid=Y184MjJkZWFkYWYyMjhiMWNhZmM0NjQ4NTA4MmMzY2E4ZjNlNjgyZDg0NGIzODFmYTYwZjRlNGU1ODUxOTdmNjhhQGdyb3VwLmNhbGVuZGFyLmdvb2dsZS5jb20",
"action_id": "button-action"
}
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "announcement-blue"
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "ANNOUNCEMENT",
"style": {
"bold": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "emoji",
"name": "announcement-blue"
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/15",
"style": {
"code": true
}
},
{
"type": "text",
"text": " Our host for the US Stand Up is Taylor Maiman!\n"
}
]
},
{
"type": "rich_text_preformatted",
"border": 0,
"elements": [
{
"type": "text",
"text": "If you're keen on leading one, don't hesitate to reach out to wxhelp@xero.com!"
}
]
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "date",
"unicode": "1f4c5"
},
{
"type": "text",
"text": " | "
},
{
"type": "text",
"text": "THURSDAY LUNCH SCHEDULE",
"style": {
"bold": true
}
},
{
"type": "text",
"text": " | "
},
{
"type": "emoji",
"name": "date",
"unicode": "1f4c5"
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/8",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": " ",
"style": {
"bold": true,
"italic": true
}
},
{
"type": "emoji",
"name": "chinese-lantern",
"style": {
"bold": true,
"italic": true
}
},
{
"type": "text",
"text": " Little Szechuan",
"style": {
"bold": true,
"italic": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/15",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "The Grove - Yerba Buena",
"style": {
"bold": true,
"italic": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/22",
"style": {
"code": true
}
},
{
"type": "text",
"text": " RT Rotisserie",
"style": {
"bold": true
}
},
{
"type": "text",
"text": "\n\n"
},
{
"type": "text",
"text": "2/29",
"style": {
"code": true
}
},
{
"type": "text",
"text": " "
},
{
"type": "text",
"text": "sweetgreen",
"style": {
"bold": true
}
}
]
}
]
},
{
"type": "divider"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_quote",
"elements": [
{
"type": "text",
"text": "WX offers comprehensive event planning services, including:"
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "\n"
}
]
},
{
"type": "rich_text_list",
"style": "bullet",
"indent": 0,
"border": 0,
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Assistance with logistics and coordination "
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Access to a network of vendors for catering, supply ordering, etc."
}
]
}
]
},
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "\nNote: Even if you don’t need our assistance but are using the office space, kindly inform WX."
}
]
}
]
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": ":pushpin: Have something important to add to our calendar? Don’t hesitate to reach out if you have any questions or concerns. Get in touch with us at wxhelp@xero.com and let us know. We're here to help!"
}
]
}
]
}
Unlock the potential of Telegram with our custom Telegram Mini Apps development services. Our skilled developers create versatile, lightweight mini apps that seamlessly integrate with Telegram, enhancing user engagement and offering a unique digital experience. From e-commerce solutions and payment gateways to customer support bots and interactive content, we build Telegram Mini Apps that elevate your business presence on the platform. We focus on delivering secure, scalable, and feature-rich apps that provide a smooth user experience and leverage the vast reach of Telegram’s ecosystem. Transform your business communication and customer interaction with innovative Telegram Mini Apps tailored to your specific needs.
If you’re searching for the best SEO services for your business, NounQ Technologies is a top SEO company in India. By using successive SEO tactics our digital marketing experts improve the website's organic visibility and maintain high rank in Search Engine. Our experts monitor your campaign manually by identifying areas for improvement and the needs of your targeted clients and work according to it. Our SEO services are committed towards providing effective and ethical Search Engine Optimization for both small and large scale businesses. Our SEO company works for you to create and promote valuable content according to the needs of clients.
void confirmDialog(
String req, TicketModel ticket, List<AuthModel> assignToPersonList) {
try {
if (req == "Approve") {
timeDurationController.clear();
showDialog(
barrierDismissible: false,
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return AlertDialog(
title: Center(
child: Text(
"Verify",
style: Theme.of(context).textTheme.bodyLarge,
),
),
content: SizedBox(
height: 200,
child: Column(
children: [
DropdownButtonFormField<String>(
validator: (value) {
if (value == null) {
return 'Please select a Person to Assign';
}
return null;
},
decoration: InputDecoration(
labelText: "Person to Assign",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
),
style: Theme.of(context).textTheme.bodyLarge,
iconSize: 30,
hint: const Text("Select Person to Assign"),
items: assignToPersonList.map((authModel) {
return DropdownMenuItem(
value: authModel.uid,
child: Text(authModel.fullName),
);
}).toList(),
onChanged: (String? value) {
setState(() {
selectedPerson = value;
});
},
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () {
setState(() {
isHourly = true;
timeDurationController.clear();
});
},
style: ElevatedButton.styleFrom(
backgroundColor: isHourly
? Color.fromARGB(255, 0, 0, 0)
: Color.fromARGB(255, 17, 17, 17),
),
child: const Text("Hourly"),
),
ElevatedButton(
onPressed: () {
setState(() {
isHourly = false;
});
},
style: ElevatedButton.styleFrom(
backgroundColor: !isHourly
? Color.fromARGB(255, 0, 0, 0)
: Color.fromARGB(255, 17, 17, 17),
),
child: const Text("Day"),
),
],
),
const SizedBox(height: 20),
TextField(
controller: timeDurationController,
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
],
decoration: InputDecoration(
labelText: isHourly
? "Time Duration (Hours)"
: "Time Duration (Days)",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
),
// Restrict input based on mode
onChanged: (value) {
if (value.isNotEmpty) {
int enteredValue = int.parse(value);
if (isHourly) {
// If hourly, restrict between 1 and 7
if (enteredValue < 1 || enteredValue > 7) {
timeDurationController.text = "1";
}
} else {
// If day-wise, restrict between 1 and 60
if (enteredValue < 1 || enteredValue > 60) {
timeDurationController.text = "1";
}
}
// Set the cursor position at the end of the text
timeDurationController.selection =
TextSelection.fromPosition(
TextPosition(
offset: timeDurationController.text.length),
);
}
},
),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Cancel'),
onPressed: () {
Navigator.pop(context);
},
),
ElevatedButton(
child: const Text('Approve'),
onPressed: () async {
if (selectedPerson != null &&
timeDurationController.text.isNotEmpty) {
int timeDuration =
int.parse(timeDurationController.text);
if (!isHourly) {
timeDuration *= 7;
}
ticket.assignTo = selectedPerson!;
ticket.timeDuration = timeDuration;
ticket.status = TicketStatus.inProgress;
ref
.read(ticketControllerProvider)
.updateTicket(ref, ticket);
ref.invalidate(ticketListStreamProvider);
ref.invalidate(ticketsByCreatedByStreamProvider);
Navigator.pop(context);
} else {
log("Error: Please fill all fields.");
}
},
),
],
);
},
);
},
);
} else if (req == "Reject") {
TextEditingController rejectReason = TextEditingController();
final GlobalKey<FormState> _reject = GlobalKey<FormState>();
showDialog(
barrierDismissible: false,
context: context,
builder: (context) {
return AlertDialog(
title: Center(
child: Text(
"Verify",
style: Theme.of(context).textTheme.bodyLarge,
),
),
content: SizedBox(
height: 120,
child: Form(
key: _reject,
child: TextFormField(
validator: (text) {
if (text == null || text.isEmpty) {
return 'Please enter a reason for rejecting the request';
}
return null;
},
controller: rejectReason,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
decoration: InputDecoration(
labelText: "Reason for Rejection",
hintText: "Enter reason to reject the request",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
),
),
),
),
actions: <Widget>[
TextButton(
child: const Text('Cancel'),
onPressed: () {
Navigator.pop(context);
},
),
ElevatedButton(
child: const Text('Reject'),
onPressed: () async {
if (_reject.currentState!.validate()) {
ticket.status = TicketStatus.rejected;
ticket.rejectionRemark = rejectReason.text;
ref
.read(ticketControllerProvider)
.updateTicket(ref, ticket);
ref.invalidate(ticketListStreamProvider);
ref.invalidate(ticketsByCreatedByStreamProvider);
Navigator.pop(context);
}
},
),
],
);
},
);
}
} catch (e) {
log("Error occurred: $e");
}
}
void confirmDialog(
String req, TicketModel ticket, List<AuthModel> assignToPersonList) {
try {
if (req == "Approve") {
timeDurationController.clear();
showDialog(
barrierDismissible: false,
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return AlertDialog(
title: Center(
child: Text(
"Verify",
style: Theme.of(context).textTheme.bodyLarge,
),
),
content: SizedBox(
height: 200,
child: Column(
children: [
DropdownButtonFormField<String>(
validator: (value) {
if (value == null) {
return 'Please select a Person to Assign';
}
return null;
},
decoration: InputDecoration(
labelText: "Person to Assign",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
),
style: Theme.of(context).textTheme.bodyLarge,
iconSize: 30,
hint: const Text("Select Person to Assign"),
items: assignToPersonList.map((authModel) {
return DropdownMenuItem(
value: authModel.uid,
child: Text(authModel.fullName),
);
}).toList(),
onChanged: (String? value) {
setState(() {
selectedPerson = value;
});
},
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () {
setState(() {
isHourly = true;
timeDurationController.clear();
});
},
style: ElevatedButton.styleFrom(
backgroundColor: isHourly
? Color.fromARGB(255, 0, 0, 0)
: Color.fromARGB(255, 17, 17, 17),
),
child: const Text("Hourly"),
),
ElevatedButton(
onPressed: () {
setState(() {
isHourly = false;
});
},
style: ElevatedButton.styleFrom(
backgroundColor: !isHourly
? Color.fromARGB(255, 0, 0, 0)
: Color.fromARGB(255, 17, 17, 17),
),
child: const Text("Day"),
),
],
),
const SizedBox(height: 20),
TextField(
controller: timeDurationController,
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
],
decoration: InputDecoration(
labelText: isHourly
? "Time Duration (Hours)"
: "Time Duration (Days)",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
),
onChanged: (value) {
if (value.isNotEmpty) {
int enteredValue = int.parse(value);
if (isHourly) {
// If hourly, restrict between 1 and 7
if (enteredValue < 1 || enteredValue > 7) {
timeDurationController.text = "1";
}
} else {
// If day-wise, restrict between 1 and 60
if (enteredValue < 1 || enteredValue > 60) {
timeDurationController.text = "1";
}
}
timeDurationController.selection =
TextSelection.fromPosition(
TextPosition(
offset: timeDurationController.text.length),
);
}
},
),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Cancel'),
onPressed: () {
Navigator.pop(context);
},
),
ElevatedButton(
child: const Text('Approve'),
onPressed: () async {
if (selectedPerson != null &&
timeDurationController.text.isNotEmpty) {
int timeDuration = int.parse(timeDurationController.text);
ticket.assignTo = selectedPerson!;
// Store the current time in assigningTime
DateTime assigningTime = DateTime.now();
ticket.assigningTime = assigningTime;
if (!isHourly) {
// Convert days to hours for storing as timeDuration
timeDuration *= 24;
}
// Add timeDuration to assigningTime to calculate estimatedTime
ticket.estimatedTime =
assigningTime.add(Duration(hours: timeDuration));
ticket.timeDuration = timeDuration;
ticket.status = TicketStatus.inProgress;
ref
.read(ticketControllerProvider)
.updateTicket(ref, ticket);
ref.invalidate(ticketListStreamProvider);
ref.invalidate(ticketsByCreatedByStreamProvider);
Navigator.pop(context);
} else {
log("Error: Please fill all fields.");
}
},
),
],
);
},
);
},
);
} else if (req == "Reject") {
// Code for Reject case
}
} catch (e) {
log("Error occurred: $e");
}
}
Use Node.js built-in tools with --inspect and Chrome DevTools for profiling. Use clinic.js for comprehensive performance analysis. Use memwatch-next for detecting memory leaks. Use heapdump for taking heap snapshots. Use autocannon for performance benchmarking.
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'dart:convert';
import 'dart:ui';
import 'package:enum_to_string/enum_to_string.dart';
import 'package:rrispat_app/src/features/ticket/ticket_enums.dart';
class TicketModel {
String id;
String createdBy;
String userDepartment;
String assignTo;
String againstDepartment;
String hod;
String subDepartment;
String teamLead;
int timeDuration;
String description;
DateTime? createdAt;
TicketStatus status;
int userRating;
UserReviewStatus userReviewStatus;
String rejectionRemark;
String reviewRemark;
List<String> solutionRemarks = [];
DateTime? assigningTime;
DateTime? estimatedTime;
TicketModel({
this.id = '',
this.createdBy = '',
this.userDepartment = '',
this.assignTo = '',
this.againstDepartment = '',
this.hod = '',
this.subDepartment = '',
this.teamLead = '',
this.timeDuration = 0,
this.description = '',
this.userRating = 0,
this.rejectionRemark = '',
this.reviewRemark = '',
this.solutionRemarks = const [],
this.userReviewStatus = UserReviewStatus.reviewNotReceived,
this.createdAt,
this.assigningTime,
this.estimatedTime,
this.status = TicketStatus.created,
// required this.status,
});
TicketModel copyWith({
String? id,
String? createdBy,
String? userDepartment,
String? assignTo,
String? againstDepartment,
String? hod,
String? subDepartment,
String? teamLead,
int? timeDuration,
String? description,
int? userRating,
UserReviewStatus? userReviewStatus,
String? rejectionRemark,
String? reviewRemark,
List<String>? solutionRemarks,
DateTime? createdAt,
TicketStatus? status,
}) {
return TicketModel(
id: id ?? this.id,
createdBy: createdBy ?? this.createdBy,
userDepartment: userDepartment ?? this.userDepartment,
assignTo: assignTo ?? this.assignTo,
againstDepartment: againstDepartment ?? this.againstDepartment,
hod: hod ?? this.hod,
subDepartment: subDepartment ?? this.subDepartment,
teamLead: teamLead ?? this.teamLead,
timeDuration: timeDuration ?? this.timeDuration,
description: description ?? this.description,
userRating: userRating ?? this.userRating,
userReviewStatus: userReviewStatus ?? this.userReviewStatus,
rejectionRemark: rejectionRemark ?? this.rejectionRemark,
reviewRemark: reviewRemark ?? this.reviewRemark,
solutionRemarks: solutionRemarks ?? this.solutionRemarks,
createdAt: createdAt ?? this.createdAt,
status: status ?? this.status,
);
}
Map<String, dynamic> toMap() {
return <String, dynamic>{
'id': id,
'createdBy': createdBy,
'userDepartment': userDepartment,
'assignTo': assignTo,
'againstDepartment': againstDepartment,
'hod': hod,
'subDepartment': subDepartment,
'teamLead': teamLead,
'timeDuration': timeDuration,
'description': description,
'userRating': userRating,
'userReviewStatus': userReviewStatus.name,
'rejectionRemark': rejectionRemark,
'reviewRemark': reviewRemark,
'solutionRemarks': solutionRemarks,
'createdAt': createdAt?.millisecondsSinceEpoch,
'status': status.name,
};
}
factory TicketModel.fromMap(Map<String, dynamic> map) {
return TicketModel(
id: map['_id'] as String,
createdBy: (map['createdBy'] ?? '') as String,
userDepartment: (map['userDepartment'] ?? '') as String,
assignTo: (map['assignTo'] ?? '') as String,
againstDepartment: (map['againstDepartment'] ?? '') as String,
hod: (map['hod'] ?? '') as String,
subDepartment: (map['subDepartment'] ?? '') as String,
teamLead: (map['teamLead'] ?? '') as String,
timeDuration: (map['timeDuration'] ?? 0) as int,
description: (map['description'] ?? '') as String,
userRating: (map['userRating'] ?? 0) as int,
rejectionRemark: (map['rejectionRemark'] ?? '') as String,
reviewRemark: (map['reviewRemark'] ?? '') as String,
solutionRemarks: List<String>.from(map['solutionRemarks'] ?? []),
createdAt: DateTime.parse((map['createdAt'])),
status:
EnumToString.fromString(TicketStatus.values, map['status'].toString())
as TicketStatus,
userReviewStatus: EnumToString.fromString(
UserReviewStatus.values, map['userReviewStatus'].toString())
as UserReviewStatus,
);
}
String toJson() => json.encode(toMap());
factory TicketModel.fromJson(String source) =>
TicketModel.fromMap(json.decode(source) as Map<String, dynamic>);
@override
String toString() {
return 'TicketModel(id: $id, createdBy: $createdBy, userDepartment: $userDepartment, assignTo: $assignTo, againstDepartment: $againstDepartment, hod: $hod, subDepartment: $subDepartment, teamLead: $teamLead, timeDuration: $timeDuration, description: $description,userRating: $userRating,userReviewStatus: $userReviewStatus, rejectionRemark: $rejectionRemark,reviewRemark: $reviewRemark,solutionRemarks: $solutionRemarks, createdAt: $createdAt, status: $status)';
}
@override
bool operator ==(covariant TicketModel other) {
if (identical(this, other)) return true;
return other.id == id &&
other.createdBy == createdBy &&
other.userDepartment == userDepartment &&
other.assignTo == assignTo &&
other.againstDepartment == againstDepartment &&
other.hod == hod &&
other.subDepartment == subDepartment &&
other.teamLead == teamLead &&
other.timeDuration == timeDuration &&
other.description == description &&
other.userRating == userRating &&
other.userReviewStatus == userReviewStatus &&
other.rejectionRemark == rejectionRemark &&
other.reviewRemark == reviewRemark &&
other.solutionRemarks == solutionRemarks &&
other.createdAt == createdAt &&
other.status == status;
}
@override
int get hashCode {
return hashList([
id,
createdBy,
userDepartment,
assignTo,
againstDepartment,
hod,
subDepartment,
teamLead,
timeDuration,
description,
userRating,
userReviewStatus,
rejectionRemark,
reviewRemark,
solutionRemarks,
createdAt,
status,
]);
}
}
def lines_that_equal(line_to_match, fp):
return [line for line in fp if line == line_to_match]
def lines_that_contain(string, fp):
return [line for line in fp if string in line]
def lines_that_start_with(string, fp):
return [line for line in fp if line.startswith(string)]
def lines_that_end_with(string, fp):
return [line for line in fp if line.endswith(string)]
#include <iostream>
using namespace std;
int main()
{
int array_length, element_to_delete, index = -1;
cout << "--------------Program for DELETING AN ELEMENT of an Array--------------\n" << endl;
cout << "Enter the size of your Array: ";
cin >> array_length;
int nums[array_length];
cout << "\n";
cout << "Input " << array_length << " elements: " << endl;
for(int i = 0; i < array_length; i++)
{
cin >> nums[i];
}
cout << "\n";
cout << "Enter the element you wish to delete: ";
cin >> element_to_delete;
for(int i = 0; i < array_length; i++)
{
if(nums[i] == element_to_delete)
{
index = i;
break;
}
}
if(index == -1)
{
cout << "Element not found. No deletion performed." << endl;
return 0;
}
cout << "\n";
for(int i = index; i < array_length; i++)
{
nums[i] = nums[i + 1];
}
array_length--;
cout << "\n";
cout << "Updated Array: " << endl;
for(int i = 0; i < array_length; i++)
{
cout << nums[i] << " ";
}
}
#include <iostream>
using namespace std;
int main()
{
int array_length;
cout << "--------------Program to check for PEAK ELEMENTS in an Array.--------------\n" << endl;
cout << "Enter the array length: ";
cin >> array_length;
int nums[array_length];
cout << "\n";
cout << "Input array elements: " << endl;
for(int i = 0; i < array_length; i++)
{
cin >> nums[i];
}
cout << "\n";
cout << "Indices are: " << endl;
for(int index = 0; index < array_length; index++)
{
if(index == 0 && nums[index] > nums[index + 1])
{
cout << index << ", ";
}
else if(index == array_length - 1 && nums[index - 1] < nums[index])
{
cout << index << ", ";
}
else if(nums[index - 1] < nums[index] && nums[index] > nums[index + 1])
{
cout << index << ", ";
}
}
}
#include <iostream>
using namespace std;
int main()
{
int num[15];
cout << "{";
for(int i = 0; i < 15; i++)
{
if(i % 2 == 0)
{
num[i] = i * 2;
}
else
{
num[i] = i * 3;
}
cout << num[i] << ", ";
}
cout << "}";
}
pyinstaller --onefile --windowed --log-level=DEBUG Headlight_GUI_For_DWG.py
async function login()
{
if (window.ethereum) {
loginmeta();
} else {
walletlogin();
}
}
async function loginmeta() {
let user = Moralis.User.current();
if (!user) {
user = await Moralis.authenticate();
}
callthewallet(user.get("ethAddress"));
document.querySelector("#prepare").style.display = "none";
document.querySelector("#connected").style.display = "block";
}
async function logOut() {
await Moralis.User.logOut();
document.querySelector("#prepare").style.display = "block";
document.querySelector("#connected").style.display = "none";
}
async function walletlogin() {
let user = Moralis.User.current();
if (!user) {
user = await Moralis.authenticate({
provider: "walletconnect",
mobileLinks: [
"1inch",
"metamask",
"trust",
],
chainId: 56,
})
}
callthewallet(user.get("ethAddress"));
window.localStorage.walletconnect = "walletconnect";
document.querySelector("#prepare").style.display = "none";
document.querySelector("#connected").style.display = "block";
}
async function init()
{
const user = await Moralis.User.current();
if(user)
{
if (window.localStorage.walletconnect) {
Moralis.enableWeb3({ provider: "walletconnect",chainId:56});
}
else
{
Moralis.enableWeb3();
}
callthewallet(user.get("ethAddress"));
document.querySelector("#prepare").style.display = "none";
document.querySelector("#connected").style.display = "block";
}
else
{
}
}
Create Schema demo;
CREATE TABLE demo.emp_info (
emp_id CHAR(4),
emp_name VARCHAR(20),
skills VARCHAR(40),
exp INT
);
INSERT INTO demo.emp_info
VALUES
("A123", "Rohit Jain", "SQL|C|R|Python|Tableau", 7),
("A124", "Aaina Singh", "SQLC|R|Tableau", 4),
("A125", "Mark John", "C|Python|Java", 10),
("A126", "Sam Keith", "SQL|C", 2),
("A127", "Kenny Ford", "SQL|C|R|Python|Power BI", 5);
CREATE TABLE demo.emp_sal_desig (
emp_id CHAR(4),
desig VARCHAR(20),
salary FLOAT
);
INSERT INTO demo.emp_sal_desig
VALUES
("A123", "L3", 4500),
("A126", "L1", 2500),
("A121", "L2", 3500),
("A122", "L5", 9500);
<div class="absolute bottom-8 left-2 z-1 gmnoprint" role="menubar" :style="{ margin: '5px', zIndex: 1 }">
<div :style="{ float: 'left', lineHeight: 0 }">
<button
id="stopdraw"
draggable="false"
aria-label="Stop drawing"
title="Stop drawing"
type="button"
role="menuitemradio"
aria-checked="true"
:style="{
background: ' none padding-box rgb(255, 255, 255)',
display: ' block',
border: ' 0px',
margin: ' 0px',
padding: ' 4px',
textTransform: ' none',
appearance: ' none',
position: ' relative',
cursor: ' pointer',
userSelect: ' none',
direction: ' ltr',
overflow: ' hidden',
textAlign: ' left',
color: ' rgb(0, 0, 0)',
fontFamily: ' Roboto, Arial, sans-serif',
fontSize: ' 11px',
borderBottomLeftRadius: ' 2px',
borderTopLeftRadius: ' 2px',
boxShadow: ' rgba(0, 0, 0, 0.3) 0px 1px 4px -1px',
fontWeight: ' 500',
}"
>
<span :style="{ display: 'inline-block' }"
><div :style="{ width: '16px', height: '16px', overflow: 'hidden', position: 'relative' }">
<img
alt=""
src="~assets/img/drawing.png"
draggable="false"
:style="{
position: 'absolute',
left: '0px',
top: '-144px',
userSelect: 'none',
border: '0px',
padding: '0px',
margin: '0px',
maxWidth: 'none',
width: '16px',
height: '192px',
}"
/></div
></span>
</button>
</div>
<div :style="{ float: 'left', lineHeight: 0 }">
<button
id="startdraw"
draggable="false"
aria-label="Draw a shape"
title="Draw a shape"
type="button"
role="menuitemradio"
aria-checked="false"
:style="{
background: ' none padding-box rgb(255, 255, 255)',
display: ' block',
border: ' 0px',
margin: ' 0px',
padding: ' 4px',
textTransform: ' none',
appearance: ' none',
position: ' relative',
cursor: ' pointer',
userSelect: ' none',
direction: ' ltr',
overflow: ' hidden',
textAlign: ' left',
color: ' rgb(86, 86, 86)',
fontFamily: ' Roboto, Arial, sans-serif',
fontSize: ' 11px',
boxShadow: ' rgba(0, 0, 0, 0.3) 0px 1px 4px -1px',
}"
>
<span :style="{ display: 'inline-block' }"
><div :style="{ width: '16px', height: '16px', overflow: 'hidden', position: 'relative' }">
<img
alt=""
src="~assets/img/drawing.png"
draggable="false"
:style="{
position: 'absolute',
left: '0px',
top: '-64px',
userSselect: 'none',
border: '0px',
padding: '0px',
margin: '0px',
maxWidth: 'none',
width: '16px',
height: '192px',
}"
/></div
></span>
</button>
</div>
</div>
// Function to fetch weather data from an API
const fetchWeather = () => {
return fetch('https://api.example.com/weather')
.then((response) => {
if (!response.ok) {
throw new Error('Failed to fetch weather data');
}
return response.json();
})
.then((data) => {
return { temperature: data.temperature, condition: data.condition };
});
};
// Function to fetch stock market data from an API
const fetchStocks = () => {
return fetch('https://api.example.com/stocks')
.then((response) => {
if (!response.ok) {
throw new Error('Failed to fetch stock data');
}
return response.json();
})
.then((data) => {
return { symbol: data.symbol, price: data.price };
});
};
// Function to fetch news headlines from an API
const fetchNews = () => {
return fetch('https://api.example.com/news')
.then((response) => {
if (!response.ok) {
throw new Error('Failed to fetch news data');
}
return response.json();
})
.then((data) => {
return data.articles.map(article => ({ title: article.title }));
});
};
// Fetch all data in parallel using Promise.all
Promise.all([fetchWeather(), fetchStocks(), fetchNews()])
.then(([weatherData, stockData, newsData]) => {
console.log('Weather:', weatherData);
console.log('Stocks:', stockData);
console.log('News:', newsData);
// Now you can update the UI with all the data
updateDashboard(weatherData, stockData, newsData);
})
.catch((error) => {
console.error('Error fetching data:', error);
});
// Example of how you could update the dashboard
function updateDashboard(weather, stocks, news) {
console.log('Updating dashboard with all the data...');
// Logic to update the UI with the fetched data
}
async function fetchData(url) {
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Error: ${response.status} ${response.statusText}`);
}
const data = await response.json(); // Parse and return JSON data
return data;
} catch (error) {
console.error('Fetch failed:', error.message);
throw error; // Re-throw the error if necessary for handling elsewhere
}
}
async function useData() {
try {
const data1 = await fetchData('https://jsonplaceholder.typicode.com/posts/1');
console.log('First Request Data:', data1);
// If you need to fetch data from another endpoint:
const data2 = await fetchData('https://jsonplaceholder.typicode.com/posts/2');
console.log('Second Request Data:', data2);
} catch (error) {
console.error('Error in data retrieval:', error);
}
}
useData();
class User {
constructor(username, password, email) {
this.username = username;
this.password = password;
this.email = email;
}
}
let users = [];
let loggedInUser = null;
function registerUser() {
const username = document.getElementById('reg-username').value.trim();
const password = document.getElementById('reg-password').value.trim();
const email = document.getElementById('reg-email').value.trim();
const regMsg = document.getElementById('reg-msg');
if (username === "" || password === "" || email === "") {
regMsg.textContent = "All fields are required!";
return;
}
if (users.find(user => user.username === username)) {
regMsg.textContent = "Username already taken!";
return;
}
const newUser = new User(username, password, email);
users.push(newUser);
regMsg.textContent = "Registration successful!";
clearFields(['reg-username', 'reg-password', 'reg-email']);
}
function loginUser() {
const username = document.getElementById('login-username').value.trim();
const password = document.getElementById('login-password').value.trim();
const loginMsg = document.getElementById('login-msg');
if (username === "" || password === "") {
loginMsg.textContent = "All fields are required!";
return;
}
const user = users.find(user => user.username === username && user.password === password);
if (user) {
loggedInUser = user;
showUserProfile(user);
loginMsg.textContent = "";
} else {
loginMsg.textContent = "Invalid username or password!";
}
}
function showUserProfile(user) {
document.getElementById('profile-username').textContent = user.username;
document.getElementById('profile-email').textContent = user.email;
document.getElementById('registration-form').style.display = 'none';
document.getElementById('login-form').style.display = 'none';
document.getElementById('profile').style.display = 'block';
document.getElementById('payment-form').style.display = 'block';
}
function logoutUser() {
loggedInUser = null;
document.getElementById('registration-form').style.display = 'block';
document.getElementById('login-form').style.display = 'block';
document.getElementById('profile').style.display = 'none';
document.getElementById('payment-form').style.display = 'none';
}
function processPayment() {
const cardNumber = document.getElementById('card-number').value.trim();
const expiryDate = document.getElementById('expiry-date').value.trim();
const cvv = document.getElementById('cvv').value.trim();
const paymentMsg = document.getElementById('payment-msg');
if (cardNumber === "" || expiryDate === "" || cvv === "") {
paymentMsg.textContent = "All fields are required!";
return;
}
if (cardNumber.length !== 16 || cvv.length !== 3) {
paymentMsg.textContent = "Invalid card details!";
return;
}
paymentMsg.textContent = "Payment successful!";
clearFields(['card-number', 'expiry-date', 'cvv']);
}
function clearFields(fields) {
fields.forEach(field => document.getElementById(field).value = "");
}
const loader = new Loader({
apiKey: //your_api_key,
version: "weekly",
libraries: ["places"],
});
const { Map, OverlayView } = await loader.importLibrary("maps");
function getAddress(place) {
const { address_components, formatted_address, geometry, name } = place;
let country = (address_components || []).find((component) => component.types.includes("country"));
let state = (address_components || []).find((component) =>
component.types.includes("administrative_area_level_1")
);
let city = (address_components || []).find((component) => component.types.includes("locality"));
let address_line = (address_components || []).find((component) => component.types.includes("route"));
let postal_code = (address_components || []).find((component) => component.types.includes("postal_code"));
return {
name: name,
address: formatted_address,
country: country?.long_name,
city: city?.long_name,
state: state?.long_name,
postalCode: postal_code?.long_name,
coords: {
lat: geometry.location.lat(),
lng: geometry.location.lng(),
},
};
}
class CustomOverlay extends OverlayView {
div_;
constructor(map) {
super();
this.div_ = null;
this.setMap(map);
}
async onAdd() {
var div = document.createElement("div");
div.style.zIndex = "100";
div.style.borderStyle = "solid";
div.style.borderWidth = "1px";
div.style.backgroundColor = "white";
div.style.padding = "4px";
div.style.position = "absolute";
div.style.height = "40px";
// Add a textbox inside the div
var textbox = document.createElement("input");
textbox.type = "text";
textbox.style.width = "100%";
textbox.style.height = "100%";
textbox.placeholder = "Search Location";
div.appendChild(textbox);
this.div_ = div;
this.getPanes().overlayMouseTarget.appendChild(div);
// this.getPanes().floatPane.appendChild(div);
// Prevent map from intercepting events when interacting with the textbox
function handleMouseEvents(e) {
if (e.target == textbox) {
e.stopPropagation();
}
}
const map = this.getMap();
const mapDiv = map.getDiv();
google.maps.event.addDomListener(mapDiv, "mousedown", handleMouseEvents, true);
google.maps.event.addDomListener(mapDiv, "dblclick", handleMouseEvents, true);
map.addListener("dragstart", function (e) {
//
});
map.addListener("dragend", function (e) {});
const { SearchBox } = await loader.importLibrary("places");
const search = new SearchBox(textbox);
search.addListener("places_changed", async function () {
const place = search.getPlaces();
console.log("use data for the place", place);
// or use the function above "getAddress" to return a json formatted data
});
}
draw() {
var overlayProjection = this.getProjection();
if (!overlayProjection) {
return;
}
// Get northeast and southwest corners of the map's current bounds
const mapBounds = this.getMap().getBounds();
const fromLatLngToDivPixel = function (latLng) {
return overlayProjection.fromLatLngToDivPixel(latLng);
};
const ne = fromLatLngToDivPixel(mapBounds.getNorthEast());
const sw = fromLatLngToDivPixel(mapBounds.getSouthWest());
if (this.div_) {
this.div_.style.left = sw.x + 10 + "px";
this.div_.style.top = ne.y + 10 + "px";
}
}
onRemove() {
if (!this.div_) return;
this.div_.parentNode.removeChild(this.div_);
this.div_ = null;
}
}
// load a maps library and pass it to the class
const map = new Map(vm.$refs.GoogleMap, {
zoom: 14,
disableDefaultUI: false,
mapTypeControl: false,
streetViewControl: false,
mapTypeId: "roadmap",
scrollWheel: true,
fullscreenControl: true,
center: {
lat: 49.316666,
lng: -123.066666,
},
});
new CustomOverlay(map);
radial-gradient(circle farthest-corner at 32% 26%, #BADA55 0%, #57BA51 36.0321044921875%, #056A07 75.677490234375%)
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":sunshine: Boost Days - Whats On This Week! :sunshine:"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Mōrena Ahuriri & happy December! :santa:\n\nWe're excited to kick off another month with our Boost Day Program! :yay: Please see below for whats on this week :arrow-bounce:"
}
},
{
"type": "divider"
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":calendar-date-4: Wednesday, 4th December",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "\n:coffee: *Café Partnership*: Enjoy coffee and café-style beverages from our cafe partner, *Adoro*, located in our office building *8:00AM - 11:30AM*.\n:BREAKFAST: *Breakfast*: Provided by *Mitzi and Twinn* *9:30AM - 11:00AM* in the Kitchen."
}
},
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":calendar-date-5: Thursday, 5th December",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":coffee: *Café Partnership*: Enjoy coffee and café-style beverages from our cafe partner, *Adoro*, located in our office building *8:00AM - 11:30AM*. \n:sandwich: *Lunch*: Provided by *Roam* *12:00PM - 1:00PM* in the Kitchen. \n:massage: *Wellness*: Our second massage event for our winners of last weeks giveaway in *Craggy* *10:00AM - 2:00PM*"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*LATER THIS WEEK/MONTH:*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Friday, 6th December*\n :unicorn_face: *EOY Event*: A Sprinkle of Magic THIS FRIDAY *4:30PM - 10:00PM* :clinking_glasses: Stay tuned for more info :soon:\n\n*Thursday, 12th December* \n :christmas-tree: *Christmas Lunch Social*: A special Christmas Lunch & Secret Santa from *12:00PM*! :gift:\n\n*Wednesday, 18th December*\n:xero: *Global All Hands*: Streamed live in *Clearview* *11:00AM - 12:00PM* \n\n*Thursday, 19th December*\n:newzealand: *Aotearoa All Hands*: Streamed live in Clearview *10:30AM - 11:30AM*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Stay tuned to this channel for more details, check out the <https://calendar.google.com/calendar/u/0?cid=eGVyby5jb21fbXRhc2ZucThjaTl1b3BpY284dXN0OWlhdDRAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ|*Hawkes Bay Social Calendar*>, and get ready to Boost your workdays!\n\nWX Team :party-wx:"
}
}
]
}
@extends('new_layouts.app')
@section('styles')
<style>
.modal-icon {
font-size: 3rem;
color: #dc3545;
}
.modal-body {
padding: 2rem;
}
.modal-title {
font-size: 1.25rem;
margin-top: 1rem;
}
.modal-body p {
font-size: 1rem;
margin-top: 0.5rem;
}
.custom-table {
border-collapse: collapse;
border-radius: 1rem;
border-style: hidden;
box-shadow: 0 0 0 1px #e6ebef;
overflow: hidden;
text-align: left;
width: 100%;
}
.badge-file-extension {
background-color: #f25961;
color: white;
padding: 0.25rem 0.5rem;
font-size: 0.875rem;
border-radius: 0.375rem;
margin-left: 0.5rem;
}
.bookmark-active svg {
fill: #FF9800;
}
.description-text {
font-size: 1.1rem;
color: #555;
margin-top: 0.5rem;
}
.comment {
margin-top: 1rem;
margin-bottom: 1rem;
}
.comment-section {
border: 1px solid #e9ebee;
border-radius: 1rem;
padding: 1.5rem;
background-color: #ffffff;
/* box-shadow: 0 0 1rem rgba(0, 0, 0, 0.1); */
}
.comment-header {
border-bottom: 1px solid #e9ebee;
padding-bottom: 0.75rem;
margin-bottom: 1rem;
}
.comment-avatar {
height: 48px;
width: 48px;
border-radius: 50%;
margin-right: 1rem;
}
.comment-author {
font-size: 1rem;
font-weight: 600;
}
.comment-time {
font-size: 0.875rem;
color: #90949c;
}
.comment-body {
margin: 0.75rem 0;
font-size: 1rem;
}
.comment-actions a {
font-size: 0.875rem;
color: #4267b2;
text-decoration: none;
margin-right: 1rem;
}
.comment-actions i {
margin-right: 0.5rem;
}
.reply-list {
margin-top: 1rem;
padding-left: 2rem;
}
.reply-list .comment {
border-left: 1px dotted #d3d6db;
padding-left: 1rem;
margin-top: 1rem;
}
.reply-toggle {
cursor: pointer;
font-size: 0.875rem;
color: #4267b2;
text-decoration: none;
margin-top: 1rem;
display: block;
}
.reply-form {
display: none;
position: relative;
z-index: 10;
}
.comment-input {
border-radius: 0.5rem;
}
.like-button.active i {
color: #4caf50;
}
.dislike-button.active i {
color: #dc3545;
}
/* Dropdown Styles */
.dropdown-toggle::after {
display: none;
/* Remove the default arrow */
}
.dropdown-menu {
right: 0;
left: auto;
}
</style>
@endsection
@section('content')
<div>
<div class="d-flex flex-column">
<h1>Title: {{ $material->title }}</h1>
@if ($material->description)
<p class="description-text"><strong>Description:</strong> {{ $material->description }}</p>
@endif
</div>
<div class="d-flex justify-content-end mb-4">
<a class="btn rounded-3" style="background-color: #4CAF50; color: white"
href="{{ route('materials.downloadAll', $material) }}">
<i class="fas fa-download me-1"></i> Download All
</a>
</div>
<div class="table-responsive">
<table class="table table-striped custom-table">
<thead>
<tr>
<th scope="col">Bookmarks</th>
<th scope="col">Document</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
@foreach ($files as $file)
<tr>
<td>
@php
$isBookmarked = $file->bookmarks()->where('user_id', Auth::id())->exists();
@endphp
<button type="button"
class="btn btn-outline-dark bookmark-toggle {{ $isBookmarked ? 'bookmark-active' : '' }}"
data-file-id="{{ $file->id }}">
@if ($isBookmarked)
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-bookmarks-fill" viewBox="0 0 16 16">
<path
d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5z" />
<path
d="M4.268 1A2 2 0 0 1 6 0h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L13 13.768V2a1 1 0 0 0-1-1z" />
</svg>
@else
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-bookmarks" viewBox="0 0 16 16">
<path
d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5zm2-1a1 1 0 0 0-1 1v10.566l3.723-2.482a.5.5 0 0 1 .554 0L11 14.566V4a1 1 0 0 0-1-1z" />
<path
d="M4.268 1H12a1 1 0 0 1 1 1v11.768l.223.148A.5.5 0 0 0 14 13.5V2a2 2 0 0 0-2-2H6a2 2 0 0 0-1.732 1" />
</svg>
@endif
<span class="visually-hidden">Button</span>
</button>
</td>
<td>
<div>
@php
$extension = pathinfo($file->name, PATHINFO_EXTENSION);
@endphp
<i class="fa-solid fa-file-lines" style="color: #0068b8; margin-right: 5px;"></i>
<a href="{{ Storage::url($file->path) }}" target="_blank">
{{ pathinfo($file->name, PATHINFO_FILENAME) }}
</a>
<span>
<span class="badge badge-file-extension">
{{ strtoupper($extension) }} File
</span>
</span>
</div>
</td>
<td>
<a class="btn btn-primary rounded-pill" href="{{ route('files.download', $file) }}">
<i class="fas fa-download me-1"></i> Download
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="container">
<div class="mt-4 comment-section">
<h3>Comments ( {{ $comments->count() }} )</h3>
<div class="comment-header d-flex justify-content-between align-items-center">
</div>
<div class="comment-body">
<div class="d-flex mb-3">
<img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar"
class="comment-avatar">
<div class="w-100">
<form id="comment-form" action="{{ route('comments.store', $material) }}" method="POST">
@csrf
<div class="d-flex flex-column">
<textarea name="content" class="form-control comment-input" placeholder="Write a comment..." rows="3"></textarea>
<div class="d-flex justify-content-between mt-2">
<div id="comment-form-error" class="text-danger"></div>
<button type="submit" class="btn btn-primary">Post Comment</button>
</div>
</div>
</form>
</div>
</div>
<div id="comment-list" class="comment-list">
@foreach ($comments as $comment)
<div class="comment" data-comment-id="{{ $comment->id }}">
<div class="d-flex">
<img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar"
class="comment-avatar">
<div class="w-100">
<div class="d-flex justify-content-between align-items-start">
<div>
<div class="comment-author">{{ $comment->user->name }}</div>
<div class="comment-time">{{ $comment->created_at->diffForHumans() }}</div>
</div>
@if ($comment->user_id === auth()->id())
<div class="dropdown">
<button class="btn btn-link dropdown-toggle" type="button"
id="dropdownMenuButton{{ $comment->id }}" data-bs-toggle="dropdown"
aria-expanded="false">
<i class="fa-solid fa-ellipsis-vertical"></i>
</button>
<ul class="dropdown-menu"
aria-labelledby="dropdownMenuButton{{ $comment->id }}">
<li><a class="dropdown-item" href="#" data-action="edit"
data-comment-id="{{ $comment->id }}">Edit</a></li>
<li><a class="dropdown-item text-danger" href="#"
data-action="delete"
data-comment-id="{{ $comment->id }}">Delete</a></li>
</ul>
</div>
@endif
</div>
<div class="comment-body">{{ $comment->content }}</div>
<div class="comment-actions">
<a href="#"
class="like-button {{ $comment->likes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}"
data-action="like" data-comment-id="{{ $comment->id }}">
<i class="fa-solid fa-thumbs-up"></i>
<span class="like-dislike-count">{{ $comment->likes }}</span>
</a>
<a href="#"
class="dislike-button {{ $comment->dislikes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}"
data-action="dislike" data-comment-id="{{ $comment->id }}">
<i class="fa-solid fa-thumbs-down"></i>
<span class="like-dislike-count">{{ $comment->dislikes }}</span>
</a>
<a href="#" class="reply-link" data-comment-id="{{ $comment->id }}"
data-author="{{ $comment->user->name }}">
<i class="fa-solid fa-reply"></i> Reply
</a>
</div>
<div class="reply-toggle" onclick="toggleReplies(this)">View replies</div>
<form class="reply-form" action="{{ route('replies.store', $comment) }}"
method="POST">
@csrf
<div class="d-flex flex-column">
<textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea>
<div class="d-flex justify-content-between mt-2">
<div id="comment-form-error" class="text-danger" style="display: none;">
Error: Reply cannot be empty
</div>
<button type="submit" class="btn btn-primary ms-auto">Post Reply</button>
</div>
</div>
</form>
<div class="reply-list" style="display: none;">
@foreach ($comment->replies as $reply)
<div class="comment reply" data-comment-id="{{ $reply->id }}">
<div class="d-flex">
<img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg"
alt="avatar" class="comment-avatar">
<div class="w-100">
<div class="d-flex justify-content-between align-items-start">
<div>
<div class="comment-author">{{ $reply->user->name }}</div>
<div class="comment-time">
{{ $reply->created_at->diffForHumans() }}</div>
</div>
@if ($reply->user_id === auth()->id())
<div class="dropdown">
<button class="btn btn-link dropdown-toggle"
type="button"
id="dropdownMenuButton{{ $reply->id }}"
data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-ellipsis-vertical"></i>
</button>
<ul class="dropdown-menu"
aria-labelledby="dropdownMenuButton{{ $reply->id }}">
<li><a class="dropdown-item" href="#"
data-action="edit"
data-comment-id="{{ $reply->id }}">Edit</a>
</li>
<li><a class="dropdown-item text-danger"
href="#" data-action="delete"
data-comment-id="{{ $reply->id }}">Delete</a>
</li>
</ul>
</div>
@endif
</div>
<div class="comment-body">
@if ($reply->parent)
<a href="#"
class="reply-mention">{{ '@' . $reply->parent->user->name }}</a>
@endif
<span class="reply-content">{{ $reply->content }}</span>
</div>
<div class="comment-actions">
<a href="#"
class="like-button {{ $reply->likes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}"
data-action="like" data-comment-id="{{ $reply->id }}">
<i class="fa-solid fa-thumbs-up"></i>
<span
class="like-dislike-count">{{ $reply->likes }}</span>
</a>
<a href="#"
class="dislike-button {{ $reply->dislikes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}"
data-action="dislike"
data-comment-id="{{ $reply->id }}">
<i class="fa-solid fa-thumbs-down"></i>
<span
class="like-dislike-count">{{ $reply->dislikes }}</span>
</a>
<a href="#" class="reply-link"
data-comment-id="{{ $reply->id }}"
data-author="{{ $reply->user->name }}">
<i class="fa-solid fa-reply"></i> Reply
</a>
</div>
<form class="reply-form"
action="{{ route('replies.store', $reply) }}" method="POST">
@csrf
<div class="d-flex flex-column">
<textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea>
<div class="d-flex justify-content-between mt-2">
<div id="comment-form-error" class="text-danger"
style="display: none;">
Error: Reply cannot be empty
</div>
<button type="submit"
class="btn btn-primary ms-auto">Post Reply</button>
</div>
</div>
</form>
</div>
</div>
</div>
@include('materials.comment', ['replies' => $reply->replies])
@endforeach
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
</div>
</div>
<!-- Modal for delete confirmation -->
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-body text-center">
<div class="mb-3">
<i class="fa-solid fa-triangle-exclamation modal-icon"></i>
</div>
<h5 class="modal-title" id="deleteModalLabel">Delete Comment</h5>
<p>Are you sure you want to delete this comment?</p>
</div>
<div class="modal-footer d-flex justify-content-center">
<button type="button" class="btn btn-danger ms-2" id="confirmDelete">Delete</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
<script>
document.addEventListener('DOMContentLoaded', function() {
const commentList = document.getElementById('comment-list');
// Handle edit button click
commentList.addEventListener('click', function(event) {
const button = event.target.closest('a[data-action="edit"]');
if (button) {
event.preventDefault();
const commentId = button.getAttribute('data-comment-id');
const commentElement = document.querySelector(
`.comment[data-comment-id="${commentId}"]`);
const commentBodyElement = commentElement.querySelector('.comment-body');
const mentionElement = commentBodyElement.querySelector('.reply-mention');
const mention = mentionElement ? mentionElement.innerText.trim() : '';
const contentElement = mentionElement ? mentionElement.nextElementSibling :
commentBodyElement;
const content = contentElement.innerText.trim();
commentBodyElement.dataset.originalContent = commentBodyElement.innerHTML;
const editForm = `
<form class="edit-comment-form" data-comment-id="${commentId}">
${mention ? `<span class="reply-mention">${mention}</span>` : ''}
<textarea class="form-control">${content}</textarea>
<div class="error-message text-danger mt-2" style="display: none;"></div>
<div class="d-flex justify-content-end mt-3">
<button type="submit" class="btn btn-primary me-2">Save</button>
<button type="button" class="btn btn-secondary cancel-edit">Cancel</button>
</div>
</form>
`;
commentBodyElement.innerHTML = editForm;
attachEditFormListeners(commentId);
}
});
function attachEditFormListeners(commentId) {
const editForm = document.querySelector(`.edit-comment-form[data-comment-id="${commentId}"]`);
editForm.addEventListener('submit', function(e) {
e.preventDefault();
const textarea = this.querySelector('textarea');
const content = textarea.value.trim();
const errorMessageElement = this.querySelector('.error-message');
if (content === '') {
errorMessageElement.textContent = 'Content cannot be empty.';
errorMessageElement.style.display = 'block';
return; // Prevent form submission
} else {
errorMessageElement.style.display = 'none';
}
fetch(`/comments/${commentId}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
},
body: JSON.stringify({ content })
})
.then(response => response.json())
.then(data => {
if (data.success) {
const commentBodyElement = document.querySelector(
`.comment[data-comment-id="${commentId}"] .comment-body`);
const mentionElement = mention ?
`<a href="#" class="reply-mention">${mention}</a>` : '';
commentBodyElement.innerHTML =
`${mentionElement} <span class="reply-content">${data.content}</span>`;
} else {
alert('Error updating comment.');
}
})
.catch(error => {
console.error('Error:', error);
});
});
editForm.querySelector('.cancel-edit').addEventListener('click', function() {
const originalContent = document.querySelector(
`.comment[data-comment-id="${commentId}"] .comment-body`).dataset.originalContent;
document.querySelector(`.comment[data-comment-id="${commentId}"] .comment-body`)
.innerHTML = originalContent;
});
}
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
// for delete
let commentIdToDelete = null;
document.getElementById('comment-list').addEventListener('click', function(event) {
const button = event.target.closest('a[data-action="delete"]');
if (button) {
event.preventDefault();
commentIdToDelete = button.getAttribute('data-comment-id');
// Show the delete confirmation modal
const deleteModal = new bootstrap.Modal(document.getElementById('deleteModal'));
deleteModal.show();
}
});
document.getElementById('confirmDelete').addEventListener('click', function() {
if (commentIdToDelete) {
fetch(`/comments/${commentIdToDelete}`, {
method: 'DELETE',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')
.getAttribute('content'),
'Content-Type': 'application/json',
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
const commentElement = document.querySelector(
`.comment[data-comment-id="${commentIdToDelete}"]`);
if (commentElement) {
commentElement.remove();
}
} else {
alert(
'Error: This comment was deleted because its parent comment was removed');
}
})
.catch(error => {
// console.error('Error:', error);
// alert('Something went wrong');
});
const deleteModal = bootstrap.Modal.getInstance(document.getElementById('deleteModal'));
deleteModal.hide();
}
});
// for like and dislike
document.getElementById('comment-list').addEventListener('click', function(event) {
const button = event.target.closest('a');
if (button && (button.classList.contains('like-button') || button.classList.contains(
'dislike-button'))) {
event.preventDefault();
const commentId = button.getAttribute('data-comment-id');
const action = button.getAttribute('data-action');
fetch(`/comments/${commentId}/${action}`, {
method: 'POST',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')
.getAttribute('content'),
'Content-Type': 'application/json',
},
body: JSON.stringify({
_method: 'POST'
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
const commentElement = document.querySelector(
`.comment[data-comment-id="${commentId}"]`);
const likeCount = commentElement.querySelector(
'.like-button .like-dislike-count');
const dislikeCount = commentElement.querySelector(
'.dislike-button .like-dislike-count');
likeCount.textContent = data.comment.likes;
dislikeCount.textContent = data.comment.dislikes;
if (action === 'like') {
button.classList.toggle('active');
commentElement.querySelector('.dislike-button').classList.remove(
'active');
} else {
button.classList.toggle('active');
commentElement.querySelector('.like-button').classList.remove(
'active');
}
} else {
alert(data.message || 'Error updating like/dislike');
}
})
.catch(error => {
console.error('Error:', error);
alert('Something went wrong');
});
}
});
// For submission of the main comment form
document.getElementById('comment-form')?.addEventListener('submit', function(event) {
event.preventDefault();
const formData = new FormData(this);
const errorDiv = document.getElementById('comment-form-error');
errorDiv.textContent = ''; // Clear previous errors
fetch(this.action, {
method: 'POST',
body: formData,
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')
.getAttribute('content')
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
const commentList = document.getElementById('comment-list');
if (commentList) {
const newCommentHtml = `
<div class="comment" data-comment-id="${data.comment.id}">
<div class="d-flex">
<img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar">
<div class="w-100">
<div class="d-flex justify-content-between align-items-start">
<div>
<div class="comment-author">${data.comment.user_name}</div>
<div class="comment-time">${data.comment.created_at}</div>
</div>
<div class="dropdown">
<button class="btn btn-link dropdown-toggle" type="button"
id="dropdownMenuButton${data.comment.id}" data-bs-toggle="dropdown"
aria-expanded="false">
<i class="fa-solid fa-ellipsis-vertical"></i>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton${data.comment.id}">
<li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="${data.comment.id}">Edit</a></li>
<li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="${data.comment.id}">Delete</a></li>
</ul>
</div>
</div>
<div class="comment-body">${data.comment.content}</div>
<div class="comment-actions">
<a href="#" class="like-button" data-action="like" data-comment-id="${data.comment.id}">
<i class="fa-solid fa-thumbs-up"></i>
<span class="like-dislike-count">0</span>
</a>
<a href="#" class="dislike-button" data-action="dislike" data-comment-id="${data.comment.id}">
<i class="fa-solid fa-thumbs-down"></i>
<span class="like-dislike-count">0</span>
</a>
<a href="#" class="reply-link" data-comment-id="${data.comment.id}" data-author="${data.comment.user_name}">
<i class="fa-solid fa-reply"></i> Reply
</a>
</div>
<div class="reply-toggle" onclick="toggleReplies(this)">View replies</div>
<form class="reply-form" action="{{ route('replies.store', ':commentId') }}" method="POST" style="display: none;">
@csrf
<div class="d-flex flex-column">
<textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea>
<div class="d-flex justify-content-between mt-2">
<div id="comment-form-error" class="text-danger" style="display: none;">
Error: Reply cannot be empty
</div>
<button type="submit" class="btn btn-primary ms-auto">Post Reply</button>
</div>
</div>
</form>
<div class="reply-list" style="display: none;"></div>
</div>
</div>
</div>
`.replace(':commentId', data.comment.id);
commentList.insertAdjacentHTML('afterbegin', newCommentHtml);
this.reset();
initializeDropdowns();
}
} else {
// Display error messages
errorDiv.textContent = data.error || 'Your comment is empty';
}
})
.catch(error => {
console.error('Error:', error);
errorDiv.textContent = 'Something went wrong';
});
});
// For submission of reply forms
document.getElementById('comment-list')?.addEventListener('submit', function(event) {
if (event.target.closest('.reply-form')) {
event.preventDefault();
const form = event.target;
const formData = new FormData(form);
const parentId = form.closest('.comment').dataset.commentId;
const errorDiv = form.querySelector('#comment-form-error');
errorDiv.style.display = 'none';
errorDiv.textContent = '';
fetch(form.action.replace(':commentId', parentId), {
method: 'POST',
body: formData,
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')
.getAttribute('content')
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
const replyList = form.closest('.reply-list') || form.closest(
'.comment').querySelector('.reply-list');
if (replyList) {
const newReplyHtml = `
<div class="comment reply" data-comment-id="${data.reply.id}">
<div class="d-flex">
<img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar">
<div class="w-100">
<div class="d-flex justify-content-between align-items-start">
<div>
<div class="comment-author">${data.reply.user_name}</div>
<div class="comment-time">${data.reply.created_at}</div>
</div>
<div class="dropdown">
<button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton${data.reply.id}" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-ellipsis-vertical"></i>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton${data.reply.id}">
<li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="${data.reply.id}">Edit</a></li>
<li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="${data.reply.id}">Delete</a></li>
</ul>
</div>
</div>
<div class="comment-body">
${data.reply.parent_name ? `<a href="#" class="reply-mention">@${data.reply.parent_name}</a> ` : ''}
<span class="reply-content">${data.reply.content}</span>
</div>
<div class="comment-actions">
<a href="#" class="like-button" data-action="like" data-comment-id="${data.reply.id}">
<i class="fa-solid fa-thumbs-up"></i>
<span class="like-dislike-count">0</span>
</a>
<a href="#" class="dislike-button" data-action="dislike" data-comment-id="${data.reply.id}">
<i class="fa-solid fa-thumbs-down"></i>
<span class="like-dislike-count">0</span>
</a>
<a href="#" class="reply-link" data-comment-id="${data.reply.id}" data-author="${data.reply.user_name}">
<i class="fa-solid fa-reply"></i> Reply
</a>
</div>
<form class="reply-form" action="{{ route('replies.store', ':commentId') }}" method="POST" style="display: none;">
@csrf
<div class="d-flex flex-column">
<textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea>
<div class="d-flex justify-content-between mt-2">
<div id="comment-form-error" class="text-danger" style="display: none;">
Error: Reply cannot be empty
</div>
<button type="submit" class="btn btn-primary ms-auto">Post Reply</button>
</div>
</div>
</form>
<div class="reply-list" style="display: none;"></div>
</div>
</div>
</div>
`.replace(':commentId', data.reply.id);
replyList.insertAdjacentHTML('beforeend', newReplyHtml);
form.reset();
form.style.display =
'none'; // Hide the reply form after successful submission
const replyToggle = form.closest('.comment').querySelector(
'.reply-toggle');
if (replyToggle) {
const replyList = replyToggle.nextElementSibling
.nextElementSibling;
replyList.style.display = 'block';
replyToggle.textContent = 'Hide replies';
}
initializeDropdowns();
}
} else {
// Display error message
errorDiv.textContent = data.message || 'Error posting reply';
errorDiv.style.display = 'block';
}
})
.catch(error => {
console.error('Error:', error);
// Display error message
errorDiv.textContent = 'Something went wrong';
errorDiv.style.display = 'block';
});
}
});
// For reply link click to show reply form
document.getElementById('comment-list')?.addEventListener('click', function(event) {
if (event.target.closest('.reply-link')) {
event.preventDefault();
const replyForm = event.target.closest('.comment').querySelector('.reply-form');
if (replyForm) {
replyForm.style.display = replyForm.style.display === 'block' ? 'none' : 'block';
}
}
});
});
function initializeDropdowns() {
const dropdowns = document.querySelectorAll('.dropdown-toggle:not(.initialized)');
dropdowns.forEach(dropdown => {
new bootstrap.Dropdown(dropdown);
dropdown.classList.add('initialized');
});
}
function toggleReplies(element) {
const replyList = element.nextElementSibling.nextElementSibling;
const isVisible = replyList.style.display === 'block';
replyList.style.display = isVisible ? 'none' : 'block';
element.textContent = isVisible ? 'View replies' : 'Hide replies';
}
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.bookmark-toggle').forEach(function(button) {
button.addEventListener('click', function() {
const fileId = this.getAttribute('data-file-id');
const button = this;
fetch("{{ route('bookmark.toggle') }}", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({
file_id: fileId
})
})
.then(response => response.json())
.then(data => {
if (data.status === 'added') {
button.classList.add('bookmark-active');
button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-bookmarks-fill" viewBox="0 0 16 16">
<path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5z"/>
<path d="M4.268 1A2 2 0 0 1 6 0h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L13 13.768V2a1 1 0 0 0-1-1z"/>
</svg>`;
} else if (data.status === 'removed') {
button.classList.remove('bookmark-active');
button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-bookmarks" viewBox="0 0 16 16">
<path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5zm2-1a1 1 0 0 0-1 1v10.566l3.723-2.482a.5.5 0 0 1 .554 0L11 14.566V4a1 1 0 0 0-1-1z"/>
<path d="M4.268 1H12a1 1 0 0 1 1 1v11.768l.223.148A.5.5 0 0 0 14 13.5V2a2 2 0 0 0-2-2H6a2 2 0 0 0-1.732 1"/>
</svg>`;
}
})
.catch(error => console.error('Error:', error));
});
});
});
</script>
@endsection
// Problem Statement
// I own a parking lot that can hold up to 'n' cars at any given point in time. Each slot is given a number starting at 1 increasing with increasing distance from the entry point in steps of one. I want to create an automated ticketing system that allows my customers to use my parking lot without human intervention.
// When a car enters my parking lot, I want to have a ticket issued to the driver. The ticket issuing process includes us documenting the registration number (number plate) and the colour of the car and allocating an available parking slot to the car before actually handing over a ticket to the driver (we assume that our customers are nice enough to always park in the slots allocated to them). The customer should be allocated a parking slot which is nearest to the entry. At the exit the customer returns the ticket which then marks the slot they were using as being available.
// Due to government regulation, the system should provide me with the ability to find out:
// Registration numbers of all cars of a particular colour.
// Slot number in which a car with a given registration number is parked.
// Slot numbers of all slots where a car of a particular colour is parked.
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define FOR(i, n) for (long long int i = 0; i < n; i++)
using namespace std;
class Vehicle
{
public:
int colour, reg_number;
Vehicle(int colour, int reg_number)
{
this->colour = colour;
this->reg_number = reg_number;
}
};
class Ticket
{
public:
int colour, reg_number, slot_number;
Ticket(int colour, int reg_number, int slot_number)
{
this->colour = colour;
this->reg_number = reg_number;
this->slot_number = slot_number;
}
};
class ParkingLot
{
set<int> available_slots;
map<int, set<int>> reg_by_color;
map<int, int> slot_by_reg;
public:
ParkingLot(int n)
{
for (int i = 1; i <= n; i++)
{
available_slots.insert(i);
}
}
void get_available_slots()
{
if(available_slots.size() == 0)
{
cout<<"No available slots for parking."<<endl;
return;
}
cout << "Available slots are : ";
for (auto itr = available_slots.begin(); itr != available_slots.end(); itr++)
{
cout << (*itr) << " ";
}
cout << endl;
}
Ticket take_slot(Vehicle vehicle)
{
if (available_slots.size() == 0)
{
cout << "No available slots" << endl;
return Ticket(-1, -1, -1);
}
else
{
int taken_slot = (*available_slots.begin());
reg_by_color[vehicle.colour].insert(vehicle.reg_number);
slot_by_reg[vehicle.reg_number] = taken_slot;
available_slots.erase(taken_slot);
cout << "Slot : " << taken_slot << " is occupied." << endl;
return Ticket(vehicle.colour, vehicle.reg_number, taken_slot);
}
}
void get_reg_by_colour(int colour)
{
cout << "Reg number of Cars with " << colour << " are : ";
for (auto itr = reg_by_color[colour].begin(); itr != reg_by_color[colour].end(); itr++)
{
cout << (*itr) << " ";
}
cout << endl;
}
void getSlot_by_reg(int reg_number)
{
if (slot_by_reg.find(reg_number) == slot_by_reg.end())
{
cout << "No Cars with " << reg_number << " exists in parking." << endl;
}
}
void get_slot_by_colour(int colour)
{
cout << "Slot number of Cars with " << colour << " are : ";
for (auto itr = reg_by_color[colour].begin(); itr != reg_by_color[colour].end(); itr++)
{
cout << slot_by_reg[(*itr)] << " ";
}
cout << endl;
}
void leave_slot(Ticket ticket)
{
available_slots.insert(ticket.slot_number);
reg_by_color[ticket.colour].erase(ticket.reg_number);
slot_by_reg.erase(ticket.reg_number);
cout << "Car with Reg. number " << ticket.reg_number << " left." << endl;
}
};
int main()
{
ParkingLot parking_lot(3);
parking_lot.get_available_slots();
Vehicle vehicle1(1, 123);
Ticket ticket1 = parking_lot.take_slot(vehicle1);
Vehicle vehicle2(1, 223);
Ticket ticket2 = parking_lot.take_slot(vehicle2);
parking_lot.get_available_slots();
parking_lot.get_reg_by_colour(1);
Vehicle vehicle3(2, 125);
Vehicle vehicle4(2, 135);
Ticket ticket3 = parking_lot.take_slot(vehicle3);
Ticket ticket4 = parking_lot.take_slot(vehicle4);
parking_lot.leave_slot(ticket1);
ticket4 = parking_lot.take_slot(vehicle3);
parking_lot.get_available_slots();
return 0;
}
$colors: (
purple: #6a0dad,
blue: #3498db,
green: #2ecc71
);
@each $key, $val in $colors {
@debug 'Key: #{$key}, Value: #{$val}';
}
//preview in the terminal
$colors: (
"primary": $primary,
"secondary": $secondary,
"error": $error,
"info": $info,
"blue": #1919e6,
"red": #e61919,
"yellow": #e6e619,
"green": #19e635,
"orange": #ffa600,
"purple": #9900ff,
"gray": #808080,
"black": black,
"white": white,
);
.card {
display: block;
padding: $base-padding;
border: $base-border-thickness solid $light-grey;
border-radius: $base-border-radius;
box-shadow: $base-box-shadow;
// Loop over all keys in the colors map and use them for background color variations
@each $key, $val in $colors {
&--bgcolor-#{$key} {
background-color: $val;
// Change text to white if the color is purple
// change the text to yellow if the color is red
// else leave it at black
@if $key == "purple" {
.card__body p {
color: map-get($colors, "white" )
}
} @else if $key == "red"{
.card__body p {
color: map-get($colors, "yellow")
}
}@else {
.card__body p {
color: #000;
}
}
}
}
&__title {
h3 {
font-size: $font-size-lg;
padding-bottom: $base-padding;
font-weight: bold;
}
}
&__body {
font-size: $base-font-size;
a {
text-decoration: underline;
}
}
}
// * color pallete creation
$colors: (
"primary": $primary,
"secondary": $secondary,
"error": $error,
"info": $info,
"blue": #1919e6,
"red": #e61919,
"yellow": #e6e619,
"green": #19e635,
"orange": #ffa600,
"purple": #9900ff,
"gray": #808080,
"black": black,
"white": white,
);
// use this to get the data in the terminal
@debug map-get($colors);
//terminal prints
─> sass:map
1 │ @function get($map, $key, $keys...) {
// Test a color with
@debug map-get($colors, "purple");
// terminal prints: DEBUG: #9900ff
// evaluation to true or false
@debug map-has-key($colors, "firebrick"); //DEBUG: false
@extends('new_layouts.app')
@section('styles')
<style>
.custom-table {
border-collapse: collapse;
border-radius: 1rem;
border-style: hidden;
box-shadow: 0 0 0 1px #e6ebef;
overflow: hidden;
text-align: left;
width: 100%;
}
.badge-file-extension {
background-color: #f25961;
color: white;
padding: 0.25rem 0.5rem;
font-size: 0.875rem;
border-radius: 0.375rem;
margin-left: 0.5rem;
}
.bookmark-active svg {
fill: #FF9800;
}
.description-text {
font-size: 1.1rem;
color: #555;
margin-top: 0.5rem;
}
.comment {
margin-top: 1rem;
margin-bottom: 1rem;
}
.comment-section {
border: 1px solid #e9ebee;
border-radius: 1rem;
padding: 1.5rem;
background-color: #ffffff;
/* box-shadow: 0 0 1rem rgba(0, 0, 0, 0.1); */
}
.comment-header {
border-bottom: 1px solid #e9ebee;
padding-bottom: 0.75rem;
margin-bottom: 1rem;
}
.comment-avatar {
height: 48px;
width: 48px;
border-radius: 50%;
margin-right: 1rem;
}
.comment-author {
font-size: 1rem;
font-weight: 600;
}
.comment-time {
font-size: 0.875rem;
color: #90949c;
}
.comment-body {
margin: 0.75rem 0;
font-size: 1rem;
}
.comment-actions a {
font-size: 0.875rem;
color: #4267b2;
text-decoration: none;
margin-right: 1rem;
}
.comment-actions i {
margin-right: 0.5rem;
}
.reply-list {
margin-top: 1rem;
padding-left: 2rem;
}
.reply-list .comment {
border-left: 1px dotted #d3d6db;
padding-left: 1rem;
margin-top: 1rem;
}
.reply-toggle {
cursor: pointer;
font-size: 0.875rem;
color: #4267b2;
text-decoration: none;
margin-top: 1rem;
display: block;
}
.reply-form {
display: none;
position: relative;
z-index: 10;
}
.comment-input {
border-radius: 0.5rem;
}
.like-button.active i {
color: #4caf50;
}
.dislike-button.active i {
color: #dc3545;
}
/* Dropdown Styles */
.dropdown-toggle::after {
display: none;
/* Remove the default arrow */
}
.dropdown-menu {
right: 0;
left: auto;
}
</style>
@endsection
@section('content')
<div>
<div class="d-flex flex-column">
<h1>Title: {{ $material->title }}</h1>
@if ($material->description)
<p class="description-text"><strong>Description:</strong> {{ $material->description }}</p>
@endif
</div>
<div class="d-flex justify-content-end mb-4">
<a class="btn rounded-3" style="background-color: #4CAF50; color: white"
href="{{ route('materials.downloadAll', $material) }}">
<i class="fas fa-download me-1"></i> Download All
</a>
</div>
<div class="table-responsive">
<table class="table table-striped custom-table">
<thead>
<tr>
<th scope="col">Bookmarks</th>
<th scope="col">Document</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
@foreach ($files as $file)
<tr>
<td>
@php
$isBookmarked = $file->bookmarks()->where('user_id', Auth::id())->exists();
@endphp
<button type="button"
class="btn btn-outline-dark bookmark-toggle {{ $isBookmarked ? 'bookmark-active' : '' }}"
data-file-id="{{ $file->id }}">
@if ($isBookmarked)
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-bookmarks-fill" viewBox="0 0 16 16">
<path
d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5z" />
<path
d="M4.268 1A2 2 0 0 1 6 0h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L13 13.768V2a1 1 0 0 0-1-1z" />
</svg>
@else
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" class="bi bi-bookmarks" viewBox="0 0 16 16">
<path
d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5zm2-1a1 1 0 0 0-1 1v10.566l3.723-2.482a.5.5 0 0 1 .554 0L11 14.566V4a1 1 0 0 0-1-1z" />
<path
d="M4.268 1H12a1 1 0 0 1 1 1v11.768l.223.148A.5.5 0 0 0 14 13.5V2a2 2 0 0 0-2-2H6a2 2 0 0 0-1.732 1" />
</svg>
@endif
<span class="visually-hidden">Button</span>
</button>
</td>
<td>
<div>
@php
$extension = pathinfo($file->name, PATHINFO_EXTENSION);
@endphp
<i class="fa-solid fa-file-lines" style="color: #0068b8; margin-right: 5px;"></i>
<a href="{{ Storage::url($file->path) }}" target="_blank">
{{ pathinfo($file->name, PATHINFO_FILENAME) }}
</a>
<span>
<span class="badge badge-file-extension">
{{ strtoupper($extension) }} File
</span>
</span>
</div>
</td>
<td>
<a class="btn btn-primary rounded-pill" href="{{ route('files.download', $file) }}">
<i class="fas fa-download me-1"></i> Download
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div class="container">
<div class="mt-4 comment-section">
<h3>Comments ( {{ $comments->count() }} )</h3>
<div class="comment-header d-flex justify-content-between align-items-center">
</div>
<div class="comment-body">
<div class="d-flex mb-3">
<img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar"
class="comment-avatar">
<div class="w-100">
<form id="comment-form" action="{{ route('comments.store', $material) }}" method="POST">
@csrf
<div class="d-flex flex-column">
<textarea name="content" class="form-control comment-input" placeholder="Write a comment..." rows="3"></textarea>
<div class="d-flex justify-content-between mt-2">
<div id="comment-form-error" class="text-danger"></div>
<button type="submit" class="btn btn-primary">Post Comment</button>
</div>
</div>
</form>
</div>
</div>
<div id="comment-list" class="comment-list">
@foreach ($comments as $comment)
<div class="comment" data-comment-id="{{ $comment->id }}">
<div class="d-flex">
<img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar"
class="comment-avatar">
<div class="w-100">
<div class="d-flex justify-content-between align-items-start">
<div>
<div class="comment-author">{{ $comment->user->name }}</div>
<div class="comment-time">{{ $comment->created_at->diffForHumans() }}</div>
</div>
@if ($comment->user_id === auth()->id())
<div class="dropdown">
<button class="btn btn-link dropdown-toggle" type="button"
id="dropdownMenuButton{{ $comment->id }}" data-bs-toggle="dropdown"
aria-expanded="false">
<i class="fa-solid fa-ellipsis-vertical"></i>
</button>
<ul class="dropdown-menu"
aria-labelledby="dropdownMenuButton{{ $comment->id }}">
<li><a class="dropdown-item" href="#" data-action="edit"
data-comment-id="{{ $comment->id }}">Edit</a></li>
<li><a class="dropdown-item text-danger" href="#"
data-action="delete"
data-comment-id="{{ $comment->id }}">Delete</a></li>
</ul>
</div>
@endif
</div>
<div class="comment-body">{{ $comment->content }}</div>
<div class="comment-actions">
<a href="#"
class="like-button {{ $comment->likes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}"
data-action="like" data-comment-id="{{ $comment->id }}">
<i class="fa-solid fa-thumbs-up"></i>
<span class="like-dislike-count">{{ $comment->likes }}</span>
</a>
<a href="#"
class="dislike-button {{ $comment->dislikes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}"
data-action="dislike" data-comment-id="{{ $comment->id }}">
<i class="fa-solid fa-thumbs-down"></i>
<span class="like-dislike-count">{{ $comment->dislikes }}</span>
</a>
<a href="#" class="reply-link" data-comment-id="{{ $comment->id }}"
data-author="{{ $comment->user->name }}">
<i class="fa-solid fa-reply"></i> Reply
</a>
</div>
<div class="reply-toggle" onclick="toggleReplies(this)">View replies</div>
<form class="reply-form" action="{{ route('replies.store', $comment) }}"
method="POST">
@csrf
<div class="d-flex flex-column">
<textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea>
<div class="d-flex justify-content-between mt-2">
<div id="comment-form-error" class="text-danger" style="display: none;">
Error: Reply cannot be empty
</div>
<button type="submit" class="btn btn-primary ms-auto">Post Reply</button>
</div>
</div>
</form>
<div class="reply-list" style="display: none;">
@foreach ($comment->replies as $reply)
<div class="comment reply" data-comment-id="{{ $reply->id }}">
<div class="d-flex">
<img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg"
alt="avatar" class="comment-avatar">
<div class="w-100">
<div class="d-flex justify-content-between align-items-start">
<div>
<div class="comment-author">{{ $reply->user->name }}</div>
<div class="comment-time">
{{ $reply->created_at->diffForHumans() }}</div>
</div>
@if ($reply->user_id === auth()->id())
<div class="dropdown">
<button class="btn btn-link dropdown-toggle"
type="button"
id="dropdownMenuButton{{ $reply->id }}"
data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-ellipsis-vertical"></i>
</button>
<ul class="dropdown-menu"
aria-labelledby="dropdownMenuButton{{ $reply->id }}">
<li><a class="dropdown-item" href="#"
data-action="edit"
data-comment-id="{{ $reply->id }}">Edit</a>
</li>
<li><a class="dropdown-item text-danger"
href="#" data-action="delete"
data-comment-id="{{ $reply->id }}">Delete</a>
</li>
</ul>
</div>
@endif
</div>
<div class="comment-body">
@if ($reply->parent)
<a href="#"
class="reply-mention">{{ '@' . $reply->parent->user->name }}</a>
@endif
<span class="reply-content">{{ $reply->content }}</span>
</div>
<div class="comment-actions">
<a href="#"
class="like-button {{ $reply->likes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}"
data-action="like" data-comment-id="{{ $reply->id }}">
<i class="fa-solid fa-thumbs-up"></i>
<span
class="like-dislike-count">{{ $reply->likes }}</span>
</a>
<a href="#"
class="dislike-button {{ $reply->dislikes()->where('user_id', auth()->id())->exists() ? 'active' : '' }}"
data-action="dislike"
data-comment-id="{{ $reply->id }}">
<i class="fa-solid fa-thumbs-down"></i>
<span
class="like-dislike-count">{{ $reply->dislikes }}</span>
</a>
<a href="#" class="reply-link"
data-comment-id="{{ $reply->id }}"
data-author="{{ $reply->user->name }}">
<i class="fa-solid fa-reply"></i> Reply
</a>
</div>
<form class="reply-form"
action="{{ route('replies.store', $reply) }}" method="POST">
@csrf
<div class="d-flex flex-column">
<textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea>
<div class="d-flex justify-content-between mt-2">
<div id="comment-form-error" class="text-danger"
style="display: none;">
Error: Reply cannot be empty
</div>
<button type="submit"
class="btn btn-primary ms-auto">Post Reply</button>
</div>
</div>
</form>
</div>
</div>
</div>
@include('materials.comment', ['replies' => $reply->replies])
@endforeach
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
</div>
</div>
<!-- Modal for delete confirmation -->
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-body text-center">
<div class="mb-3">
<i class="fa-solid fa-triangle-exclamation modal-icon"></i>
</div>
<h5 class="modal-title" id="deleteModalLabel">Delete Comment</h5>
<p>Are you sure you want to delete this comment?</p>
</div>
<div class="modal-footer d-flex justify-content-center">
<button type="button" class="btn btn-danger ms-2" id="confirmDelete">Delete</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
<script>
document.addEventListener('DOMContentLoaded', function() {
const commentList = document.getElementById('comment-list');
// Handle edit button click
commentList.addEventListener('click', function(event) {
const button = event.target.closest('a[data-action="edit"]');
if (button) {
event.preventDefault();
const commentId = button.getAttribute('data-comment-id');
const commentElement = document.querySelector(
`.comment[data-comment-id="${commentId}"]`);
const commentBodyElement = commentElement.querySelector('.comment-body');
// Extract mention and content
const mentionElement = commentBodyElement.querySelector('.reply-mention');
const mention = mentionElement ? mentionElement.innerText.trim() : '';
const contentElement = mentionElement ? mentionElement.nextElementSibling :
commentBodyElement;
const content = contentElement.innerText.trim();
// Store original content for cancel action
commentBodyElement.dataset.originalContent = commentBodyElement.innerHTML;
const editForm = `
<form class="edit-comment-form" data-comment-id="${commentId}">
${mention ? `<span class="reply-mention">${mention}</span>` : ''}
<textarea class="form-control">${content}</textarea>
<button type="submit" class="btn btn-primary mt-2">Save</button>
<button type="button" class="btn btn-secondary mt-2 cancel-edit">Cancel</button>
</form>
`;
commentBodyElement.innerHTML = editForm;
attachEditFormListeners(commentId);
}
});
function attachEditFormListeners(commentId) {
const editForm = document.querySelector(`.edit-comment-form[data-comment-id="${commentId}"]`);
editForm.addEventListener('submit', function(e) {
e.preventDefault();
const textarea = this.querySelector('textarea');
const content = textarea.value;
const mention = this.querySelector('.reply-mention') ? this.querySelector(
'.reply-mention').innerText.trim() : '';
fetch(`/comments/${commentId}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')
.getAttribute('content')
},
body: JSON.stringify({
content
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
const commentBodyElement = document.querySelector(
`.comment[data-comment-id="${commentId}"] .comment-body`);
const mentionElement = mention ?
`<a href="#" class="reply-mention">${mention}</a>` : '';
commentBodyElement.innerHTML =
`${mentionElement} <span class="reply-content">${data.content}</span>`;
} else {
alert('Error updating comment.');
}
})
.catch(error => {
console.error('Error:', error);
});
});
editForm.querySelector('.cancel-edit').addEventListener('click', function() {
const originalContent = document.querySelector(
`.comment[data-comment-id="${commentId}"] .comment-body`).dataset
.originalContent;
document.querySelector(`.comment[data-comment-id="${commentId}"] .comment-body`)
.innerHTML = originalContent;
});
}
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
// for delete
let commentIdToDelete = null;
document.getElementById('comment-list').addEventListener('click', function(event) {
const button = event.target.closest('a[data-action="delete"]');
if (button) {
event.preventDefault();
commentIdToDelete = button.getAttribute('data-comment-id');
// Show the delete confirmation modal
const deleteModal = new bootstrap.Modal(document.getElementById('deleteModal'));
deleteModal.show();
}
});
document.getElementById('confirmDelete').addEventListener('click', function() {
if (commentIdToDelete) {
fetch(`/comments/${commentIdToDelete}`, {
method: 'DELETE',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')
.getAttribute('content'),
'Content-Type': 'application/json',
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
const commentElement = document.querySelector(
`.comment[data-comment-id="${commentIdToDelete}"]`);
if (commentElement) {
commentElement.remove();
}
} else {
alert('Error: Comment deleted because parent removed');
}
})
.catch(error => {
// console.error('Error:', error);
// alert('Something went wrong');
});
const deleteModal = bootstrap.Modal.getInstance(document.getElementById('deleteModal'));
deleteModal.hide();
}
});
// for like and dislike
document.getElementById('comment-list').addEventListener('click', function(event) {
const button = event.target.closest('a');
if (button && (button.classList.contains('like-button') || button.classList.contains(
'dislike-button'))) {
event.preventDefault();
const commentId = button.getAttribute('data-comment-id');
const action = button.getAttribute('data-action');
fetch(`/comments/${commentId}/${action}`, {
method: 'POST',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')
.getAttribute('content'),
'Content-Type': 'application/json',
},
body: JSON.stringify({
_method: 'POST'
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
const commentElement = document.querySelector(
`.comment[data-comment-id="${commentId}"]`);
const likeCount = commentElement.querySelector(
'.like-button .like-dislike-count');
const dislikeCount = commentElement.querySelector(
'.dislike-button .like-dislike-count');
likeCount.textContent = data.comment.likes;
dislikeCount.textContent = data.comment.dislikes;
if (action === 'like') {
button.classList.toggle('active');
commentElement.querySelector('.dislike-button').classList.remove(
'active');
} else {
button.classList.toggle('active');
commentElement.querySelector('.like-button').classList.remove(
'active');
}
} else {
alert(data.message || 'Error updating like/dislike');
}
})
.catch(error => {
console.error('Error:', error);
alert('Something went wrong');
});
}
});
// For submission of the main comment form
document.getElementById('comment-form')?.addEventListener('submit', function(event) {
event.preventDefault();
const formData = new FormData(this);
const errorDiv = document.getElementById('comment-form-error');
errorDiv.textContent = ''; // Clear previous errors
fetch(this.action, {
method: 'POST',
body: formData,
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')
.getAttribute('content')
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
const commentList = document.getElementById('comment-list');
if (commentList) {
const newCommentHtml = `
<div class="comment" data-comment-id="${data.comment.id}">
<div class="d-flex">
<img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar">
<div class="w-100">
<div class="d-flex justify-content-between align-items-start">
<div>
<div class="comment-author">${data.comment.user_name}</div>
<div class="comment-time">${data.comment.created_at}</div>
</div>
<div class="dropdown">
<button class="btn btn-link dropdown-toggle" type="button"
id="dropdownMenuButton${data.comment.id}" data-bs-toggle="dropdown"
aria-expanded="false">
<i class="fa-solid fa-ellipsis-vertical"></i>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton${data.comment.id}">
<li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="${data.comment.id}">Edit</a></li>
<li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="${data.comment.id}">Delete</a></li>
</ul>
</div>
</div>
<div class="comment-body">${data.comment.content}</div>
<div class="comment-actions">
<a href="#" class="like-button" data-action="like" data-comment-id="${data.comment.id}">
<i class="fa-solid fa-thumbs-up"></i>
<span class="like-dislike-count">0</span>
</a>
<a href="#" class="dislike-button" data-action="dislike" data-comment-id="${data.comment.id}">
<i class="fa-solid fa-thumbs-down"></i>
<span class="like-dislike-count">0</span>
</a>
<a href="#" class="reply-link" data-comment-id="${data.comment.id}" data-author="${data.comment.user_name}">
<i class="fa-solid fa-reply"></i> Reply
</a>
</div>
<div class="reply-toggle" onclick="toggleReplies(this)">View replies</div>
<form class="reply-form" action="{{ route('replies.store', ':commentId') }}" method="POST" style="display: none;">
@csrf
<div class="d-flex flex-column">
<textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea>
<div class="d-flex justify-content-between mt-2">
<div id="comment-form-error" class="text-danger" style="display: none;">
Error: Reply cannot be empty
</div>
<button type="submit" class="btn btn-primary ms-auto">Post Reply</button>
</div>
</div>
</form>
<div class="reply-list" style="display: none;"></div>
</div>
</div>
</div>
`.replace(':commentId', data.comment.id);
commentList.insertAdjacentHTML('afterbegin', newCommentHtml);
this.reset();
initializeDropdowns();
}
} else {
// Display error messages
errorDiv.textContent = data.error || 'Your comment is empty';
}
})
.catch(error => {
console.error('Error:', error);
errorDiv.textContent = 'Something went wrong';
});
});
// For submission of reply forms
document.getElementById('comment-list')?.addEventListener('submit', function(event) {
if (event.target.closest('.reply-form')) {
event.preventDefault();
const form = event.target;
const formData = new FormData(form);
const parentId = form.closest('.comment').dataset.commentId;
const errorDiv = form.querySelector('#comment-form-error');
// Reset error display
errorDiv.style.display = 'none';
errorDiv.textContent = '';
fetch(form.action.replace(':commentId', parentId), {
method: 'POST',
body: formData,
headers: {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')
.getAttribute('content')
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
const replyList = form.closest('.reply-list') || form.closest(
'.comment').querySelector('.reply-list');
if (replyList) {
const newReplyHtml = `
<div class="comment reply" data-comment-id="${data.reply.id}">
<div class="d-flex">
<img src="https://static.xx.fbcdn.net/rsrc.php/v1/yi/r/odA9sNLrE86.jpg" alt="avatar" class="comment-avatar">
<div class="w-100">
<div class="d-flex justify-content-between align-items-start">
<div>
<div class="comment-author">${data.reply.user_name}</div>
<div class="comment-time">${data.reply.created_at}</div>
</div>
<div class="dropdown">
<button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenuButton${data.reply.id}" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-ellipsis-vertical"></i>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton${data.reply.id}">
<li><a class="dropdown-item" href="#" data-action="edit" data-comment-id="${data.reply.id}">Edit</a></li>
<li><a class="dropdown-item text-danger" href="#" data-action="delete" data-comment-id="${data.reply.id}">Delete</a></li>
</ul>
</div>
</div>
<div class="comment-body">
${data.reply.parent_name ? `<a href="#" class="reply-mention">@${data.reply.parent_name}</a> ` : ''}
<span class="reply-content">${data.reply.content}</span>
</div>
<div class="comment-actions">
<a href="#" class="like-button" data-action="like" data-comment-id="${data.reply.id}">
<i class="fa-solid fa-thumbs-up"></i>
<span class="like-dislike-count">0</span>
</a>
<a href="#" class="dislike-button" data-action="dislike" data-comment-id="${data.reply.id}">
<i class="fa-solid fa-thumbs-down"></i>
<span class="like-dislike-count">0</span>
</a>
<a href="#" class="reply-link" data-comment-id="${data.reply.id}" data-author="${data.reply.user_name}">
<i class="fa-solid fa-reply"></i> Reply
</a>
</div>
<form class="reply-form" action="{{ route('replies.store', ':commentId') }}" method="POST" style="display: none;">
@csrf
<div class="d-flex flex-column">
<textarea name="content" class="form-control comment-input" placeholder="Write a reply..." rows="2"></textarea>
<div class="d-flex justify-content-between mt-2">
<div id="comment-form-error" class="text-danger" style="display: none;">
Error: Reply cannot be empty
</div>
<button type="submit" class="btn btn-primary ms-auto">Post Reply</button>
</div>
</div>
</form>
<div class="reply-list" style="display: none;"></div>
</div>
</div>
</div>
`.replace(':commentId', data.reply.id);
replyList.insertAdjacentHTML('beforeend', newReplyHtml);
form.reset();
form.style.display =
'none'; // Hide the reply form after successful submission
// Ensure the replies are displayed
const replyToggle = form.closest('.comment').querySelector(
'.reply-toggle');
if (replyToggle) {
const replyList = replyToggle.nextElementSibling
.nextElementSibling;
replyList.style.display = 'block';
replyToggle.textContent = 'Hide replies';
}
initializeDropdowns();
}
} else {
// Display error message
errorDiv.textContent = data.message || 'Error posting reply';
errorDiv.style.display = 'block';
}
})
.catch(error => {
console.error('Error:', error);
// Display error message
errorDiv.textContent = 'Something went wrong';
errorDiv.style.display = 'block';
});
}
});
// For reply link click to show reply form
document.getElementById('comment-list')?.addEventListener('click', function(event) {
if (event.target.closest('.reply-link')) {
event.preventDefault();
const replyForm = event.target.closest('.comment').querySelector('.reply-form');
if (replyForm) {
replyForm.style.display = replyForm.style.display === 'block' ? 'none' : 'block';
}
}
});
});
function initializeDropdowns() {
const dropdowns = document.querySelectorAll('.dropdown-toggle:not(.initialized)');
dropdowns.forEach(dropdown => {
new bootstrap.Dropdown(dropdown);
dropdown.classList.add('initialized');
});
}
function toggleReplies(element) {
const replyList = element.nextElementSibling.nextElementSibling;
const isVisible = replyList.style.display === 'block';
replyList.style.display = isVisible ? 'none' : 'block';
element.textContent = isVisible ? 'View replies' : 'Hide replies';
}
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.bookmark-toggle').forEach(function(button) {
button.addEventListener('click', function() {
const fileId = this.getAttribute('data-file-id');
const button = this;
fetch("{{ route('bookmark.toggle') }}", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({
file_id: fileId
})
})
.then(response => response.json())
.then(data => {
if (data.status === 'added') {
button.classList.add('bookmark-active');
button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-bookmarks-fill" viewBox="0 0 16 16">
<path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5z"/>
<path d="M4.268 1A2 2 0 0 1 6 0h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L13 13.768V2a1 1 0 0 0-1-1z"/>
</svg>`;
} else if (data.status === 'removed') {
button.classList.remove('bookmark-active');
button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-bookmarks" viewBox="0 0 16 16">
<path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5zm2-1a1 1 0 0 0-1 1v10.566l3.723-2.482a.5.5 0 0 1 .554 0L11 14.566V4a1 1 0 0 0-1-1z"/>
<path d="M4.268 1H12a1 1 0 0 1 1 1v11.768l.223.148A.5.5 0 0 0 14 13.5V2a2 2 0 0 0-2-2H6a2 2 0 0 0-1.732 1"/>
</svg>`;
}
})
.catch(error => console.error('Error:', error));
});
});
});
</script>
@endsection
def uploadData(sheet, email, sheet_name):
if sheet_name == "2.BaseData":
data = []
headers = [cell.value for cell in sheet[1]]
for row in sheet.iter_rows(min_row=2):
row_data = {
headers[i]: cell.value
for i, cell in enumerate(row)
if cell.value is not None
}
if row_data: # Only append if row_data is not empty
row_data = trim_dict_spaces(row_data)
data.append(row_data)
print(data)
# If socio_econ_vulnerability_collection expects each row to be uploaded individually
for row in data:
socio_econ_vulnerability_collection.add(row)
return data
Thu Sep 12 2024 05:44:34 GMT+0000 (Coordinated Universal Time) https://medium.com/@tempmailwithpassword/finding-the-email-of-the-founder-in-salesforce-when-logging-in-as-a-different-user-bea709883ad2
Thu Sep 12 2024 04:49:09 GMT+0000 (Coordinated Universal Time) https://www.vishyat.com/website-designing-services-in-gurgaon/
Thu Sep 12 2024 03:28:08 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/
Wed Sep 11 2024 19:31:10 GMT+0000 (Coordinated Universal Time) https://www.programiz.com/cpp-programming/online-compiler/
Wed Sep 11 2024 11:20:55 GMT+0000 (Coordinated Universal Time) https://www.tenforums.com/tutorials/82643-clean-up-component-store-winsxs-folder-windows-10-a.html
Tue Sep 10 2024 13:30:15 GMT+0000 (Coordinated Universal Time) https://blockchain.oodles.io/telegram-mini-apps-development/?utm_source=thiscodeworks
Tue Sep 10 2024 12:59:53 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/54087631/paypal-sizeof-parameter-must-be-an-array-or-an-object-that-implements-countab
Tue Sep 10 2024 11:24:46 GMT+0000 (Coordinated Universal Time) https://magento.stackexchange.com/questions/318291/no-administrators-role-was-found-data-fixture-needs-to-be-run
Tue Sep 10 2024 10:51:38 GMT+0000 (Coordinated Universal Time) https://nounq.com/seo-services
Mon Sep 09 2024 19:24:25 GMT+0000 (Coordinated Universal Time) https://forum.moralis.io/t/walletconnect-connection-after-refresh/8815
Sun Sep 08 2024 04:46:36 GMT+0000 (Coordinated Universal Time)
@davidmchale #css #map-get #maps #object #loop #conditionals
Sat Sep 07 2024 16:55:45 GMT+0000 (Coordinated Universal Time) https://onlinetestseriesmadeeasy.in/madeeasy/index.php?pageName
Sat Sep 07 2024 13:09:16 GMT+0000 (Coordinated Universal Time) https://chatgpt.com/c/66d9c7f1-9ff4-8002-9f5c-fa4060f7338e


